Skip to content

Commit

Permalink
use final variables
Browse files Browse the repository at this point in the history
  • Loading branch information
bseber committed Jun 21, 2024
1 parent 03f9aca commit 9aa6964
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class AbsenceTypeIT extends TestContainersBase {
@Test
void ensureAbsenceTypeCreation() {

TenantId tenantId = new TenantId("default");
final TenantId tenantId = new TenantId("default");
when(tenantContextHolder.getCurrentTenantId()).thenReturn(Optional.of(tenantId));

rabbitTemplate.convertAndSend("vacationtype.topic", "updated", VacationTypeUpdatedEventDTO.builder()
Expand Down Expand Up @@ -90,7 +90,7 @@ void ensureAbsenceTypeCreation() {
});
});

InOrder inOrder = Mockito.inOrder(tenantContextHolder);
final InOrder inOrder = Mockito.inOrder(tenantContextHolder);
inOrder.verify(tenantContextHolder).setTenantId(tenantId);
inOrder.verify(tenantContextHolder).clear();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void setUp() {

@Test
void onApplicationAllowedEvent() {
TenantId tenantId = new TenantId("tenantId");
final TenantId tenantId = new TenantId("tenantId");

final ApplicationAllowedEventDTO event = ApplicationAllowedEventDTO.builder()
.id(UUID.randomUUID())
Expand All @@ -77,14 +77,14 @@ void onApplicationAllowedEvent() {
);
verify(absenceWriteService).addAbsence(absence);

InOrder inOrder = Mockito.inOrder(tenantContextHolder);
final InOrder inOrder = Mockito.inOrder(tenantContextHolder);
inOrder.verify(tenantContextHolder).setTenantId(tenantId);
inOrder.verify(tenantContextHolder).clear();
}

@Test
void onApplicationCreatedFromSickNoteEvent() {
TenantId tenantId = new TenantId("tenantId");
final TenantId tenantId = new TenantId("tenantId");

final ApplicationCreatedFromSickNoteEventDTO event = ApplicationCreatedFromSickNoteEventDTO.builder()
.id(UUID.randomUUID())
Expand All @@ -110,14 +110,14 @@ void onApplicationCreatedFromSickNoteEvent() {
);
verify(absenceWriteService).addAbsence(absence);

InOrder inOrder = Mockito.inOrder(tenantContextHolder);
final InOrder inOrder = Mockito.inOrder(tenantContextHolder);
inOrder.verify(tenantContextHolder).setTenantId(tenantId);
inOrder.verify(tenantContextHolder).clear();
}

@Test
void onApplicationCancelledEvent() {
TenantId tenantId = new TenantId("tenantId");
final TenantId tenantId = new TenantId("tenantId");

final ApplicationCancelledEventDTO event = ApplicationCancelledEventDTO.builder()
.id(UUID.randomUUID())
Expand All @@ -143,14 +143,14 @@ void onApplicationCancelledEvent() {
);
verify(absenceWriteService).deleteAbsence(absence);

InOrder inOrder = Mockito.inOrder(tenantContextHolder);
final InOrder inOrder = Mockito.inOrder(tenantContextHolder);
inOrder.verify(tenantContextHolder).setTenantId(tenantId);
inOrder.verify(tenantContextHolder).clear();
}

@Test
void onApplicationWithAbsentWorkingDays() {
TenantId tenantId = new TenantId("tenantId");
final TenantId tenantId = new TenantId("tenantId");

final ApplicationAllowedEventDTO event = ApplicationAllowedEventDTO.builder()
.id(UUID.randomUUID())
Expand All @@ -167,7 +167,7 @@ void onApplicationWithAbsentWorkingDays() {

verifyNoInteractions(absenceWriteService);

InOrder inOrder = Mockito.inOrder(tenantContextHolder);
final InOrder inOrder = Mockito.inOrder(tenantContextHolder);
inOrder.verify(tenantContextHolder).setTenantId(tenantId);
inOrder.verify(tenantContextHolder).clear();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ void ensureSickNoteCreatedUpdatedDeleted() {

final SickNotePersonDTO boss = SickNotePersonDTO.builder().personId(1L).username("boss").build();

TenantId tenantId = new TenantId(TENANT_ID);
final TenantId tenantId = new TenantId(TENANT_ID);
when(tenantContextHolder.getCurrentTenantId()).thenReturn(Optional.of(tenantId));

// CREATE sick note absence
Expand Down Expand Up @@ -127,7 +127,7 @@ void ensureSickNoteCreatedUpdatedDeleted() {
.hasSize(1)
.containsOnly(Map.entry(now, List.of(expected)));

InOrder inOrder = Mockito.inOrder(tenantContextHolder);
final InOrder inOrder = Mockito.inOrder(tenantContextHolder);
inOrder.verify(tenantContextHolder).setTenantId(tenantId);
inOrder.verify(tenantContextHolder).clear();
});
Expand All @@ -153,7 +153,8 @@ void ensureSickNoteCreatedUpdatedDeleted() {
assertThat(absences)
.hasSize(2)
.containsOnly(Map.entry(now, List.of(expected)), Map.entry(now.plusDays(1), List.of(expected)));
InOrder inOrder = Mockito.inOrder(tenantContextHolder);

final InOrder inOrder = Mockito.inOrder(tenantContextHolder);
inOrder.verify(tenantContextHolder).setTenantId(tenantId);
inOrder.verify(tenantContextHolder).clear();
});
Expand All @@ -178,7 +179,7 @@ void ensureSickNoteCreatedUpdatedDeleted() {
.hasSize(1)
.containsOnly(Map.entry(now, List.of()));

InOrder inOrder = Mockito.inOrder(tenantContextHolder);
final InOrder inOrder = Mockito.inOrder(tenantContextHolder);
inOrder.verify(tenantContextHolder).setTenantId(tenantId);
inOrder.verify(tenantContextHolder).clear();
});
Expand All @@ -195,7 +196,7 @@ void ensureConvertedToApplicationDeletesSickNote() {
final SickNotePersonDTO boss = SickNotePersonDTO.builder().personId(1L).username("boss").build();
final UserId userId = new UserId("boss");

TenantId tenantId = new TenantId(TENANT_ID);
final TenantId tenantId = new TenantId(TENANT_ID);
when(tenantContextHolder.getCurrentTenantId()).thenReturn(Optional.of(tenantId));

final AbsenceWrite absence = new AbsenceWrite(1L, userId, startOfDay, startOfDay, FULL, SICK);
Expand All @@ -222,7 +223,7 @@ void ensureConvertedToApplicationDeletesSickNote() {
.containsOnly(Map.entry(now, List.of()));
});

InOrder inOrder = Mockito.inOrder(tenantContextHolder);
final InOrder inOrder = Mockito.inOrder(tenantContextHolder);
inOrder.verify(tenantContextHolder).setTenantId(tenantId);
inOrder.verify(tenantContextHolder).clear();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void ensureAbsenceTypeUpdateIsIgnoredWhenCategoryCannotBeMapped() {
sut.on(eventDto);
verifyNoInteractions(absenceTypeService);

InOrder inOrder = Mockito.inOrder(tenantContextHolder);
final InOrder inOrder = Mockito.inOrder(tenantContextHolder);
inOrder.verify(tenantContextHolder).setTenantId(TENANT_ID);
inOrder.verify(tenantContextHolder).clear();
}
Expand All @@ -77,7 +77,7 @@ void ensureAbsenceTypeUpdateIsIgnoredWhenColorCannotBeMapped() {
sut.on(eventDto);
verifyNoInteractions(absenceTypeService);

InOrder inOrder = Mockito.inOrder(tenantContextHolder);
final InOrder inOrder = Mockito.inOrder(tenantContextHolder);
inOrder.verify(tenantContextHolder).setTenantId(TENANT_ID);
inOrder.verify(tenantContextHolder).clear();
}
Expand Down Expand Up @@ -113,7 +113,7 @@ void ensureAbsenceTypeUpdateImpl(AbsenceTypeCategory category, AbsenceColor colo
labels
));

InOrder inOrder = Mockito.inOrder(tenantContextHolder);
final InOrder inOrder = Mockito.inOrder(tenantContextHolder);
inOrder.verify(tenantContextHolder).setTenantId(TENANT_ID);
inOrder.verify(tenantContextHolder).clear();
}
Expand Down

0 comments on commit 9aa6964

Please sign in to comment.