Skip to content
Snippets Groups Projects
Commit 1006d621 authored by OZGCloud's avatar OZGCloud
Browse files

OZG-4713 OZG-4926 Move fields to nested classes

parent a00b7402
No related branches found
No related tags found
No related merge requests found
......@@ -28,9 +28,6 @@ public class AktenzeichenChangeHistoryBuilderTest {
private final Command command = commandFinishedAt(LocalDateTime.of(2023, 6, 1, 12, 0));
private final List<Command> commands = List.of(previousCommand, command);
private final CommandWithPrevious commandWithoutPrevious = CommandWithPreviousTestFactory.createBuilder().command(previousCommand).previous(null).build();
private final CommandWithPrevious commandWithPrevious = CommandWithPreviousTestFactory.createBuilder().command(command).previous(previousCommand).build();
@Spy
private AktenzeichenChangeHistoryBuilder builder = AktenzeichenChangeHistoryBuilder.builder()
.withCommands(commands)
......@@ -90,6 +87,8 @@ public class AktenzeichenChangeHistoryBuilderTest {
private static final String EXPECTED_AKTENZEICHEN_BEFORE_CHANGE = LoremIpsum.getInstance().getWords(2);
private static final String EXPECTED_AKTENZEICHEN_AFTER_CHANGE = LoremIpsum.getInstance().getWords(2);
private final CommandWithPrevious commandWithPrevious = CommandWithPreviousTestFactory.createBuilder().command(command).previous(previousCommand).build();
@BeforeEach
void init() {
when(builder.getAktenzeichenBeforeChange(commandWithPrevious)).thenReturn(EXPECTED_AKTENZEICHEN_BEFORE_CHANGE);
......@@ -125,6 +124,9 @@ public class AktenzeichenChangeHistoryBuilderTest {
@Nested
class TestGetAktenzeichenBeforeChange {
private final CommandWithPrevious commandWithoutPrevious = CommandWithPreviousTestFactory.createBuilder().command(previousCommand).previous(null).build();
private final CommandWithPrevious commandWithPrevious = CommandWithPreviousTestFactory.createBuilder().command(command).previous(previousCommand).build();
@Test
void shouldReturnEmptyIfPreviousIsNull() {
var aktenzeichen = builder.getAktenzeichenBeforeChange(commandWithoutPrevious);
......@@ -148,6 +150,8 @@ public class AktenzeichenChangeHistoryBuilderTest {
private static final String EXPECTED_AKTENZEICHEN = LoremIpsum.getInstance().getWords(2);
private final CommandWithPrevious commandWithPrevious = CommandWithPreviousTestFactory.createBuilder().command(command).previous(previousCommand).build();
@BeforeEach
void init() {
doReturn(EXPECTED_AKTENZEICHEN).when(builder).getAktenzeichen(command);
......
......@@ -33,9 +33,6 @@ public class AssignedUserChangeHistoryBuilderTest {
private final Command command = commandFinishedAt(LocalDateTime.of(2023, 6, 1, 12, 0));
private final List<Command> commands = List.of(previousCommand, command);
private final CommandWithPrevious commandWithoutPrevious = CommandWithPreviousTestFactory.createBuilder().command(previousCommand).previous(null).build();
private final CommandWithPrevious commandWithPrevious = CommandWithPreviousTestFactory.createBuilder().command(command).previous(previousCommand).build();
@Mock
private UserProfileCache userProfileCache;
......@@ -99,6 +96,8 @@ public class AssignedUserChangeHistoryBuilderTest {
private static final String ASSIGNED_USER_BEFORE_CHANGE = LoremIpsum.getInstance().getWords(2);
private static final String ASSIGNED_USER_AFTER_CHANGE = LoremIpsum.getInstance().getWords(2);
private final CommandWithPrevious commandWithPrevious = CommandWithPreviousTestFactory.createBuilder().command(command).previous(previousCommand).build();
@BeforeEach
void init() {
doReturn(ASSIGNED_USER_BEFORE_CHANGE).when(builder).getAssignedUserBeforeChange(commandWithPrevious);
......@@ -136,6 +135,9 @@ public class AssignedUserChangeHistoryBuilderTest {
private static final String EXPECTED_ASSIGNED_USER = LoremIpsum.getInstance().getWords(2);
private final CommandWithPrevious commandWithoutPrevious = CommandWithPreviousTestFactory.createBuilder().command(previousCommand).previous(null).build();
private final CommandWithPrevious commandWithPrevious = CommandWithPreviousTestFactory.createBuilder().command(command).previous(previousCommand).build();
@Test
void shouldReturnEmptyStringIfPreviousIsNull() {
var assignedUser = builder.getAssignedUserBeforeChange(commandWithoutPrevious);
......@@ -175,8 +177,7 @@ public class AssignedUserChangeHistoryBuilderTest {
private static final String EXPECTED_ASSIGNED_USER = LoremIpsum.getInstance().getWords(2);
@Mock
UserProfileCache userProfileCache;
private final CommandWithPrevious commandWithPrevious = CommandWithPreviousTestFactory.createBuilder().command(command).previous(previousCommand).build();
@Test
void shouldGetAssignedUserFromCommand() {
......
......@@ -25,6 +25,7 @@ import com.thedeanda.lorem.LoremIpsum;
import de.ozgcloud.alfa.common.command.Command;
import de.ozgcloud.alfa.common.command.CommandTestFactory;
import de.ozgcloud.alfa.common.user.UserProfileTestFactory;
import de.ozgcloud.alfa.historie.ChangeHistoryBuilder.CommandWithChangeValues;
public class ChangeHistoryBuilderTest {
......@@ -34,17 +35,6 @@ public class ChangeHistoryBuilderTest {
private final Command command = commandFinishedAt(LocalDateTime.of(2023, 6, 1, 12, 0));
private final List<Command> commands = List.of(previousCommand, command);
private final CommandWithPrevious commandWithoutPrevious = CommandWithPreviousTestFactory.createBuilder().command(previousCommand).previous(null).build();
private final CommandWithPrevious commandWithPrevious = CommandWithPreviousTestFactory.createBuilder().command(command).previous(previousCommand).build();
private final List<CommandWithPrevious> commandsWithPrevious = List.of(commandWithoutPrevious, commandWithPrevious);
private final ChangeHistoryBuilder.CommandWithChangeValues previousCommandWithChangeValues = new ChangeHistoryBuilder.CommandWithChangeValues(
previousCommand, "a", "b");
private final ChangeHistoryBuilder.CommandWithChangeValues commandWithChangeValues = new ChangeHistoryBuilder.CommandWithChangeValues(
command, "b", "c");
private final List<ChangeHistoryBuilder.CommandWithChangeValues> commandsWithChangeValues = List.of(previousCommandWithChangeValues,
commandWithChangeValues);
@Spy
private TestChangeHistoryBuilder builder = new TestChangeHistoryBuilder()
.withCommands(commands)
......@@ -52,6 +42,14 @@ public class ChangeHistoryBuilderTest {
@Nested
class TestBuild {
private final CommandWithChangeValues previousCommandWithChangeValues = new CommandWithChangeValues(
previousCommand, "a", "b");
private final CommandWithChangeValues commandWithChangeValues = new CommandWithChangeValues(
command, "b", "c");
private final List<CommandWithChangeValues> commandsWithChangeValues = List.of(previousCommandWithChangeValues,
commandWithChangeValues);
@Test
void shouldCallInOrder() {
var orderVerifier = Mockito.inOrder(builder);
......@@ -106,6 +104,17 @@ public class ChangeHistoryBuilderTest {
@Nested
class TestToCommandsWithChangeValues {
private final CommandWithPrevious commandWithoutPrevious = CommandWithPreviousTestFactory.createBuilder().command(previousCommand).previous(null).build();
private final CommandWithPrevious commandWithPrevious = CommandWithPreviousTestFactory.createBuilder().command(command).previous(previousCommand).build();
private final List<CommandWithPrevious> commandsWithPrevious = List.of(commandWithoutPrevious, commandWithPrevious);
private final ChangeHistoryBuilder.CommandWithChangeValues previousCommandWithChangeValues = new ChangeHistoryBuilder.CommandWithChangeValues(
previousCommand, "a", "b");
private final ChangeHistoryBuilder.CommandWithChangeValues commandWithChangeValues = new ChangeHistoryBuilder.CommandWithChangeValues(
command, "b", "c");
private final List<ChangeHistoryBuilder.CommandWithChangeValues> commandsWithChangeValues = List.of(previousCommandWithChangeValues,
commandWithChangeValues);
@BeforeEach
void init() {
doReturn(previousCommandWithChangeValues).when(builder).toCommandWithChangeValues(commandWithoutPrevious);
......@@ -127,7 +136,7 @@ public class ChangeHistoryBuilderTest {
assertThat(historieEntries).containsExactly(previousCommandWithChangeValues, commandWithChangeValues);
}
private Stream<ChangeHistoryBuilder.CommandWithChangeValues> callBuilder() {
private Stream<CommandWithChangeValues> callBuilder() {
return builder.toCommandsWithChangeValues(commandsWithPrevious.stream());
}
}
......@@ -135,18 +144,21 @@ public class ChangeHistoryBuilderTest {
@Nested
class TestToVorgangChange {
private final ChangeHistoryBuilder.CommandWithChangeValues commandWithChangeValues = new ChangeHistoryBuilder.CommandWithChangeValues(
previousCommand, "a", "b");
@Test
void shouldSeValueBeforeChange() {
var vorgangChange = callBuilder();
assertThat(vorgangChange.getValueBeforeChange()).isNotBlank().isEqualTo(previousCommandWithChangeValues.valueBeforeChange());
assertThat(vorgangChange.getValueBeforeChange()).isNotBlank().isEqualTo(commandWithChangeValues.valueBeforeChange());
}
@Test
void shouldSeValueAfterChange() {
var vorgangChange = callBuilder();
assertThat(vorgangChange.getValueAfterChange()).isNotBlank().isEqualTo(previousCommandWithChangeValues.valueAfterChange());
assertThat(vorgangChange.getValueAfterChange()).isNotBlank().isEqualTo(commandWithChangeValues.valueAfterChange());
}
@Test
......@@ -178,7 +190,7 @@ public class ChangeHistoryBuilderTest {
}
private VorgangChange callBuilder() {
return builder.toVorgangChange(previousCommandWithChangeValues);
return builder.toVorgangChange(commandWithChangeValues);
}
}
......
......@@ -31,9 +31,6 @@ public class StatusChangeHistoryBuilderTest {
private final Command command = commandFinishedAt(LocalDateTime.of(2023, 6, 1, 12, 0));
private final List<Command> commands = List.of(previousCommand, command);
private final CommandWithPrevious commandWithoutPrevious = CommandWithPreviousTestFactory.createBuilder().command(previousCommand).previous(null).build();
private final CommandWithPrevious commandWithPrevious = CommandWithPreviousTestFactory.createBuilder().command(command).previous(previousCommand).build();
@Spy
private StatusChangeHistoryBuilder builder = StatusChangeHistoryBuilder.builder()
.withCommands(commands)
......@@ -89,6 +86,8 @@ public class StatusChangeHistoryBuilderTest {
private static final String EXPECTED_STATUS_BEFORE_CHANGE = LoremIpsum.getInstance().getWords(2);
private static final String EXPECTED_STATUS_AFTER_CHANGE = LoremIpsum.getInstance().getWords(2);
private final CommandWithPrevious commandWithPrevious = CommandWithPreviousTestFactory.createBuilder().command(command).previous(previousCommand).build();
@BeforeEach
void init() {
doReturn(EXPECTED_STATUS_BEFORE_CHANGE).when(builder).getStatusBeforeChange(commandWithPrevious);
......@@ -124,6 +123,9 @@ public class StatusChangeHistoryBuilderTest {
@Nested
class TestGetStatusBeforeChange {
private final CommandWithPrevious commandWithoutPrevious = CommandWithPreviousTestFactory.createBuilder().command(previousCommand).previous(null).build();
private final CommandWithPrevious commandWithPrevious = CommandWithPreviousTestFactory.createBuilder().command(command).previous(previousCommand).build();
@Test
void shouldReturnStatusBeforeChange() {
var status = "Status";
......@@ -145,6 +147,8 @@ public class StatusChangeHistoryBuilderTest {
@Nested
class TestGetStatusAfterChange {
private final CommandWithPrevious commandWithPrevious = CommandWithPreviousTestFactory.createBuilder().command(command).previous(previousCommand).build();
@Test
void shouldReturnStatusAfterChange() {
var status = "Status";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment