Commit eb2152a4 authored by cheremnov's avatar cheremnov
Browse files

Merge branch 'master' into feature/#145.rename-serial-number

# Conflicts:
#	ump/ump-quiz-ms/src/test/java/com/asvoip/ump/quiz/ITUtil.java
parents 538e5179 74f5f23b
......@@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>ump-documentation-ms</artifactId>
<version>1.11-SNAPSHOT</version>
<version>1.12-SNAPSHOT</version>
<packaging>jar</packaging>
<name>UMP Documentation MS</name>
<description>UMP Documentation Microservice</description>
......
......@@ -24,14 +24,14 @@ public class QuizAnswer extends AbstractId<UUID> {
/**
* Id вопроса.
*/
@NotNull(message = "Не заполнено обязательное поле \" quizQuestionId\"")
@NotNull(message = "Не заполнено обязательное поле \"quizQuestionId\"")
private UUID quizQuestionId;
/**
* Порядоковый номер ответа.
*/
@NotNull(message = "Не заполнено обязательное поле \" serialNumber\"")
private Long serialNumber;
@NotNull(message = "Не заполнено обязательное поле \"position\"")
private Long position;
/**
* Ответ.
......
......@@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>ump-quiz-ms</artifactId>
<version>1.8-SNAPSHOT</version>
<version>1.9-SNAPSHOT</version>
<packaging>jar</packaging>
<name>UMP Quiz MS</name>
<description>UMP Quiz MicroService</description>
......
......@@ -14,7 +14,7 @@ public class QuizAnswerDtoToEntityConverterImpl
public QuizAnswerEntity convert(QuizAnswer input) {
final QuizAnswerEntity output = super.convert(input);
output.setQuizQuestionId(input.getQuizQuestionId());
output.setSerialNumber(input.getSerialNumber());
output.setPosition(input.getPosition());
output.setAnswer(input.getAnswer());
output.setScore(input.getScore());
return output;
......
......@@ -14,7 +14,7 @@ public class QuizAnswerEntityToDtoConverterImpl
public QuizAnswer convert(QuizAnswerEntity input) {
final QuizAnswer output = super.convert(input);
output.setQuizQuestionId(input.getQuizQuestionId());
output.setSerialNumber(input.getSerialNumber());
output.setPosition(input.getPosition());
output.setAnswer(input.getAnswer());
output.setScore(input.getScore());
return output;
......
......@@ -23,15 +23,15 @@ public class QuizAnswerEntity extends AbstractUuidIdEntity {
protected static final String TABLE_NAME = "quiz_answer";
private static final String COLUMN_QUIZ_QUESTION_ID = "quiz_question_id";
private static final String COLUMN_SERIAL_NUMBER = "serial_number";
private static final String COLUMN_POSITION = "position";
private static final String COLUMN_ANSWER = "answer";
private static final String COLUMN_SCORE = "score";
@Column(name = COLUMN_QUIZ_QUESTION_ID, nullable = false)
private UUID quizQuestionId;
@Column(name = COLUMN_SERIAL_NUMBER, nullable = false)
private Long serialNumber;
@Column(name = COLUMN_POSITION, nullable = false)
private Long position;
@Column(name = COLUMN_ANSWER, nullable = false)
private String answer;
......
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">
<changeSet author="abrosimov" id="v-0.1/2022-02-28--01-rename-column">
<dropUniqueConstraint constraintName="uk_quiz_question_id_serial_number"
tableName="quiz_answer" />
<renameColumn columnDataType="Long"
newColumnName="position"
oldColumnName="serial_number"
tableName="quiz_answer"/>
<addUniqueConstraint columnNames="quiz_question_id, position"
constraintName="uk_quiz_question_id_position"
tableName="quiz_answer" />
</changeSet>
</databaseChangeLog>
......@@ -16,4 +16,6 @@
relativeToChangelogFile="true"/>
<include author="alexman" file="2022-02-12--01-unique-add.xml"
relativeToChangelogFile="true"/>
<include author="abrosimov" file="2022-02-28--01-rename-column.xml"
relativeToChangelogFile="true"/>
</databaseChangeLog>
......@@ -35,7 +35,7 @@ QuizAnswer - вариант ответа вопроса квиза, содерж
* id
* quizQuestionId
* order
* position - порядковый номер
* answer
* score - очки ответа
......
......@@ -3,6 +3,7 @@ package com.asvoip.ump.quiz;
import com.asvoip.ump.dto.ListResult;
import com.asvoip.ump.quiz.dto.QuestionType;
import com.asvoip.ump.quiz.dto.QuizQuestion;
import com.asvoip.ump.quiz.dto.QuizAnswer;
import com.asvoip.ump.quiz.entity.QuizAnswerEntity;
import com.asvoip.ump.quiz.entity.QuizEntity;
import com.asvoip.ump.quiz.entity.QuizQuestionEntity;
......@@ -65,7 +66,7 @@ public final class ITUtil {
public static final UUID ID_107 =
UUID.fromString("a71eb578-93da-4b09-c819-936097b00107");
public static final UUID QUIZ_QUESTION_ID_107 = ITUtil.ID_103;
public static final Long SERIAL_NUMBER_107 = 1L;
public static final Long POSITION_107 = 1L;
public static final String ANSWER_107 = "Answer 107";
public static final Long SCORE_107 = 10L;
......@@ -123,17 +124,29 @@ public final class ITUtil {
OffsetDateTime.parse("2021-06-08T15:30:00+00:00");
public static QuizAnswerEntity createQuizAnswerEntity(
UUID id, UUID quizQuestionId, Long serialNumber,
UUID id, UUID quizQuestionId, Long position,
String answer, Long score) {
final QuizAnswerEntity quizAnswerEntity = new QuizAnswerEntity();
quizAnswerEntity.setId(id);
quizAnswerEntity.setQuizQuestionId(quizQuestionId);
quizAnswerEntity.setSerialNumber(serialNumber);
quizAnswerEntity.setPosition(position);
quizAnswerEntity.setAnswer(answer);
quizAnswerEntity.setScore(score);
return quizAnswerEntity;
}
public static QuizAnswer createQuizAnswer(
UUID id, UUID quizQuestionId, Long position,
String answer, Long score) {
final QuizAnswer quizAnswer = new QuizAnswer();
quizAnswer.setId(id);
quizAnswer.setQuizQuestionId(quizQuestionId);
quizAnswer.setPosition(position);
quizAnswer.setAnswer(answer);
quizAnswer.setScore(score);
return quizAnswer;
}
public static QuizQuestionEntity createQuizQuestionEntity(
UUID id, UUID quizId, Long position, UUID quizQuestionTypeId, String question) {
final QuizQuestionEntity quizQuestionEntity = new QuizQuestionEntity();
......@@ -198,7 +211,7 @@ public final class ITUtil {
final ListResult<QuizAnswerEntity> listResult = new ListResult<>();
final ArrayList<QuizAnswerEntity> list = new ArrayList<>();
list.add(createQuizAnswerEntity(
ITUtil.ID_107, ITUtil.QUIZ_QUESTION_ID_107, ITUtil.SERIAL_NUMBER_107,
ITUtil.ID_107, ITUtil.QUIZ_QUESTION_ID_107, ITUtil.POSITION_107,
ITUtil.ANSWER_107, ITUtil.SCORE_107));
list.add(createQuizAnswerEntity(
ITUtil.ID_108, ITUtil.QUIZ_QUESTION_ID_108, ITUtil.SERIAL_NUMBER_108,
......
......@@ -53,7 +53,7 @@ public class QuizAnswerControllerIT extends AbstractSpringBootIT {
@Test
public void get() throws Exception {
final QuizAnswerEntity quizAnswerEntity = ITUtil.createQuizAnswerEntity(
ITUtil.ID_107, ITUtil.QUIZ_QUESTION_ID_107, ITUtil.SERIAL_NUMBER_107,
ITUtil.ID_107, ITUtil.QUIZ_QUESTION_ID_107, ITUtil.POSITION_107,
ITUtil.ANSWER_107, ITUtil.SCORE_107);
Mockito.when(quizAnswerService.get(ITUtil.ID_107))
.thenReturn(Optional.of(quizAnswerEntity));
......@@ -67,7 +67,7 @@ public class QuizAnswerControllerIT extends AbstractSpringBootIT {
.andExpect(jsonPath("$.status").value(StatusType.SUCCESSFUL.name()))
.andExpect(jsonPath("$.data.id").value(ITUtil.ID_107.toString()))
.andExpect(jsonPath("$.data.quizQuestionId").value(ITUtil.QUIZ_QUESTION_ID_107.toString()))
.andExpect(jsonPath("$.data.serialNumber").value(ITUtil.SERIAL_NUMBER_107))
.andExpect(jsonPath("$.data.position").value(ITUtil.POSITION_107))
.andExpect(jsonPath("$.data.answer").value(ITUtil.ANSWER_107))
.andExpect(jsonPath("$.data.score").value(ITUtil.SCORE_107));
}
......@@ -96,7 +96,7 @@ public class QuizAnswerControllerIT extends AbstractSpringBootIT {
.content("{\n" +
"\t\"data\": {\n" +
"\t\t\"quizQuestionId\": \"" + ITUtil.QUIZ_QUESTION_ID_107 + "\",\n" +
"\t\t\"serialNumber\": \"" + ITUtil.SERIAL_NUMBER_107 + "\",\n" +
"\t\t\"position\": \"" + ITUtil.POSITION_107 + "\",\n" +
"\t\t\"answer\": \"" + ITUtil.ANSWER_107 + "\",\n" +
"\t\t\"score\": \"" + ITUtil.SCORE_107 + "\"\n" +
"\t}\n" +
......@@ -108,7 +108,7 @@ public class QuizAnswerControllerIT extends AbstractSpringBootIT {
.andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(jsonPath("$.status").value(StatusType.SUCCESSFUL.name()))
.andExpect(jsonPath("$.data.quizQuestionId").value(ITUtil.QUIZ_QUESTION_ID_107.toString()))
.andExpect(jsonPath("$.data.serialNumber").value(ITUtil.SERIAL_NUMBER_107))
.andExpect(jsonPath("$.data.position").value(ITUtil.POSITION_107))
.andExpect(jsonPath("$.data.answer").value(ITUtil.ANSWER_107))
.andExpect(jsonPath("$.data.score").value(ITUtil.SCORE_107));
}
......@@ -116,7 +116,7 @@ public class QuizAnswerControllerIT extends AbstractSpringBootIT {
@Test
public void put() throws Exception {
final QuizAnswerEntity quizAnswerEntity = ITUtil.createQuizAnswerEntity(
ITUtil.ID_107, ITUtil.QUIZ_QUESTION_ID_107, ITUtil.SERIAL_NUMBER_107,
ITUtil.ID_107, ITUtil.QUIZ_QUESTION_ID_107, ITUtil.POSITION_107,
ITUtil.ANSWER_107, ITUtil.SCORE_107);
Mockito.when(quizAnswerService.get(ITUtil.ID_107)).thenReturn(Optional.of(quizAnswerEntity));
......@@ -127,7 +127,7 @@ public class QuizAnswerControllerIT extends AbstractSpringBootIT {
.content("{\n" +
"\t\"data\": {\n" +
"\t\t\"quizQuestionId\": \"" + ITUtil.QUIZ_QUESTION_ID_107 + "\",\n" +
"\t\t\"serialNumber\": \"" + ITUtil.SERIAL_NUMBER_107 + "\",\n" +
"\t\t\"position\": \"" + ITUtil.POSITION_107 + "\",\n" +
"\t\t\"answer\": \"" + ITUtil.ANSWER_107 + "\",\n" +
"\t\t\"score\": \"" + ITUtil.SCORE_107 + "\"\n" +
"\t}\n" +
......@@ -140,7 +140,7 @@ public class QuizAnswerControllerIT extends AbstractSpringBootIT {
.andExpect(jsonPath("$.status").value(StatusType.SUCCESSFUL.name()))
.andExpect(jsonPath("$.data.id").value(ITUtil.ID_107.toString()))
.andExpect(jsonPath("$.data.quizQuestionId").value(ITUtil.QUIZ_QUESTION_ID_107.toString()))
.andExpect(jsonPath("$.data.serialNumber").value(ITUtil.SERIAL_NUMBER_107))
.andExpect(jsonPath("$.data.position").value(ITUtil.POSITION_107))
.andExpect(jsonPath("$.data.answer").value(ITUtil.ANSWER_107))
.andExpect(jsonPath("$.data.score").value(ITUtil.SCORE_107));
......@@ -156,7 +156,7 @@ public class QuizAnswerControllerIT extends AbstractSpringBootIT {
.content("{\n" +
"\t\"data\": {\n" +
"\t\t\"quizQuestionId\": \"" + ITUtil.QUIZ_QUESTION_ID_107 + "\",\n" +
"\t\t\"serialNumber\": \"" + ITUtil.SERIAL_NUMBER_107 + "\",\n" +
"\t\t\"position\": \"" + ITUtil.POSITION_107 + "\",\n" +
"\t\t\"answer\": \"" + ITUtil.ANSWER_107 + "\",\n" +
"\t\t\"score\": \"" + ITUtil.SCORE_107 + "\"\n" +
"\t}\n" +
......@@ -220,8 +220,8 @@ public class QuizAnswerControllerIT extends AbstractSpringBootIT {
.andExpect(jsonPath("$.listResult.list[0].id").value(ITUtil.ID_107.toString()))
.andExpect(jsonPath("$.listResult.list[0].quizQuestionId")
.value(ITUtil.QUIZ_QUESTION_ID_107.toString()))
.andExpect(jsonPath("$.listResult.list[0].serialNumber")
.value(ITUtil.SERIAL_NUMBER_107))
.andExpect(jsonPath("$.listResult.list[0].position")
.value(ITUtil.POSITION_107))
.andExpect(jsonPath("$.listResult.list[0].answer")
.value(ITUtil.ANSWER_107))
.andExpect(jsonPath("$.listResult.list[0].score")
......@@ -229,7 +229,7 @@ public class QuizAnswerControllerIT extends AbstractSpringBootIT {
.andExpect(jsonPath("$.listResult.list[1].id").value(ITUtil.ID_108.toString()))
.andExpect(jsonPath("$.listResult.list[1].quizQuestionId")
.value(ITUtil.QUIZ_QUESTION_ID_108.toString()))
.andExpect(jsonPath("$.listResult.list[1].serialNumber")
.andExpect(jsonPath("$.listResult.list[1].position")
.value(ITUtil.SERIAL_NUMBER_108))
.andExpect(jsonPath("$.listResult.list[1].answer")
.value(ITUtil.ANSWER_108))
......
package com.asvoip.ump.quiz.converter;
import com.asvoip.ump.it.AbstractSpringBootIT;
import com.asvoip.ump.quiz.ITUtil;
import com.asvoip.ump.quiz.dto.QuizAnswer;
import com.asvoip.ump.quiz.entity.QuizAnswerEntity;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
@SuppressWarnings("checkstyle:AbbreviationAsWordInName")
class QuizAnswerDtoToEntityConverterImplIT extends AbstractSpringBootIT {
@Autowired
private QuizAnswerDtoToEntityConverterImpl quizAnswerDtoToEntityConverter;
@Test
void convert() {
final QuizAnswerEntity quizAnswerEntity =
ITUtil.createQuizAnswerEntity(ITUtil.ID_107, ITUtil.QUIZ_QUESTION_TYPE_ID_103,
ITUtil.POSITION_107, ITUtil.ANSWER_107, ITUtil.SCORE_107);
final QuizAnswer quizAnswer = ITUtil.createQuizAnswer(ITUtil.ID_107,
ITUtil.QUIZ_QUESTION_TYPE_ID_103, ITUtil.POSITION_107, ITUtil.ANSWER_107, ITUtil.SCORE_107);
final QuizAnswerEntity quizAnswerEntityTest =
quizAnswerDtoToEntityConverter.convert(quizAnswer);
Assertions.assertEquals(quizAnswerEntity, quizAnswerEntityTest);
}
}
package com.asvoip.ump.quiz.converter;
import com.asvoip.ump.it.AbstractSpringBootIT;
import com.asvoip.ump.quiz.ITUtil;
import com.asvoip.ump.quiz.dto.QuizAnswer;
import com.asvoip.ump.quiz.entity.QuizAnswerEntity;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
@SuppressWarnings("checkstyle:AbbreviationAsWordInName")
class QuizAnswerEntityToDtoConverterImplIT extends AbstractSpringBootIT {
@Autowired
private QuizAnswerEntityToDtoConverterImpl quizAnswerEntityToDtoConverter;
@Test
void convert() {
final QuizAnswerEntity quizAnswerEntity =
ITUtil.createQuizAnswerEntity(ITUtil.ID_107, ITUtil.QUIZ_QUESTION_TYPE_ID_103,
ITUtil.POSITION_107, ITUtil.ANSWER_107, ITUtil.SCORE_107);
final QuizAnswer quizAnswer = quizAnswerEntityToDtoConverter.convert(quizAnswerEntity);
Assertions.assertEquals(ITUtil.ID_107, quizAnswer.getId());
Assertions.assertEquals(ITUtil.QUIZ_QUESTION_TYPE_ID_103, quizAnswer.getQuizQuestionId());
Assertions.assertEquals(ITUtil.POSITION_107, quizAnswer.getPosition());
Assertions.assertEquals(ITUtil.ANSWER_107, quizAnswer.getAnswer());
Assertions.assertEquals(ITUtil.SCORE_107, quizAnswer.getScore());
}
}
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment