Skip to content
Snippets Groups Projects
Commit 26c8272e authored by OZGCloud's avatar OZGCloud
Browse files

OZG-6867 Move parameter syncTimestamp to the end

parent 217a39e2
No related branches found
No related tags found
No related merge requests found
...@@ -90,12 +90,12 @@ class SyncService { ...@@ -90,12 +90,12 @@ class SyncService {
public void syncAddedOrganisationsEinheiten(long syncTimestamp) { public void syncAddedOrganisationsEinheiten(long syncTimestamp) {
repository.findAllWithoutSyncResult().forEach( repository.findAllWithoutSyncResult().forEach(
organisationsEinheit -> syncAddedOrganisationsEinheit(syncTimestamp, organisationsEinheit)); organisationsEinheit -> syncAddedOrganisationsEinheit(organisationsEinheit, syncTimestamp));
} }
void syncAddedOrganisationsEinheit(long syncTimestamp, OrganisationsEinheit organisationsEinheit) { void syncAddedOrganisationsEinheit(OrganisationsEinheit organisationsEinheit, long syncTimestamp) {
addAsGroupInKeycloak(organisationsEinheit).ifPresent( addAsGroupInKeycloak(organisationsEinheit).ifPresent(
addedGroupId -> updateAfterSuccessfulGroupCreation(organisationsEinheit, syncTimestamp, addedGroupId)); addedGroupId -> updateAfterSuccessfulGroupCreation(organisationsEinheit, addedGroupId, syncTimestamp));
} }
Optional<String> addAsGroupInKeycloak(OrganisationsEinheit organisationsEinheit) { Optional<String> addAsGroupInKeycloak(OrganisationsEinheit organisationsEinheit) {
...@@ -106,7 +106,7 @@ class SyncService { ...@@ -106,7 +106,7 @@ class SyncService {
return addGroupInKeycloak(addGroupData); return addGroupInKeycloak(addGroupData);
} }
void updateAfterSuccessfulGroupCreation(OrganisationsEinheit organisationsEinheit, long syncTimestamp, String keycloakId) { void updateAfterSuccessfulGroupCreation(OrganisationsEinheit organisationsEinheit, String keycloakId, long syncTimestamp) {
var updatedOrganisationsEinheit = organisationsEinheit.toBuilder() var updatedOrganisationsEinheit = organisationsEinheit.toBuilder()
.keycloakId(keycloakId) .keycloakId(keycloakId)
.syncResult(SyncResult.OK) .syncResult(SyncResult.OK)
......
...@@ -450,7 +450,7 @@ class SyncServiceTest { ...@@ -450,7 +450,7 @@ class SyncServiceTest {
@BeforeEach @BeforeEach
void setUp() { void setUp() {
when(repository.findAllWithoutSyncResult()).thenReturn(Stream.of(organisationsEinheiten)); when(repository.findAllWithoutSyncResult()).thenReturn(Stream.of(organisationsEinheiten));
doNothing().when(service).syncAddedOrganisationsEinheit(anyLong(), any()); doNothing().when(service).syncAddedOrganisationsEinheit(any(), anyLong());
} }
@Test @Test
...@@ -464,14 +464,14 @@ class SyncServiceTest { ...@@ -464,14 +464,14 @@ class SyncServiceTest {
void shouldSynchronizeFirstOrganisationsEinheit() { void shouldSynchronizeFirstOrganisationsEinheit() {
callService(); callService();
verify(service).syncAddedOrganisationsEinheit(syncTimestamp, withoutSyncResult1); verify(service).syncAddedOrganisationsEinheit(withoutSyncResult1, syncTimestamp);
} }
@Test @Test
void shouldSynchronizeSecondOrganisationsEinheit() { void shouldSynchronizeSecondOrganisationsEinheit() {
callService(); callService();
verify(service).syncAddedOrganisationsEinheit(syncTimestamp, withoutSyncResult2); verify(service).syncAddedOrganisationsEinheit(withoutSyncResult2, syncTimestamp);
} }
private void callService() { private void callService() {
...@@ -499,11 +499,11 @@ class SyncServiceTest { ...@@ -499,11 +499,11 @@ class SyncServiceTest {
@Test @Test
void shouldUpdateAfterSuccessfulGroupCreation() { void shouldUpdateAfterSuccessfulGroupCreation() {
doReturn(Optional.of(addedGroupId)).when(service).addAsGroupInKeycloak(organisationsEinheit); doReturn(Optional.of(addedGroupId)).when(service).addAsGroupInKeycloak(organisationsEinheit);
doNothing().when(service).updateAfterSuccessfulGroupCreation(organisationsEinheit, syncTimestamp, addedGroupId); doNothing().when(service).updateAfterSuccessfulGroupCreation(organisationsEinheit, addedGroupId, syncTimestamp);
callService(); callService();
verify(service).updateAfterSuccessfulGroupCreation(organisationsEinheit, syncTimestamp, addedGroupId); verify(service).updateAfterSuccessfulGroupCreation(organisationsEinheit, addedGroupId, syncTimestamp);
} }
@Test @Test
...@@ -512,11 +512,11 @@ class SyncServiceTest { ...@@ -512,11 +512,11 @@ class SyncServiceTest {
callService(); callService();
verify(service, never()).updateAfterSuccessfulGroupCreation(any(), anyLong(), any()); verify(service, never()).updateAfterSuccessfulGroupCreation(any(), any(), anyLong());
} }
private void callService() { private void callService() {
service.syncAddedOrganisationsEinheit(syncTimestamp, organisationsEinheit); service.syncAddedOrganisationsEinheit(organisationsEinheit, syncTimestamp);
} }
} }
...@@ -591,7 +591,7 @@ class SyncServiceTest { ...@@ -591,7 +591,7 @@ class SyncServiceTest {
@Test @Test
void shouldSaveUpdatedOrganisationsEinheit() { void shouldSaveUpdatedOrganisationsEinheit() {
service.updateAfterSuccessfulGroupCreation(organisationsEinheit, syncTimestamp, keycloakId); service.updateAfterSuccessfulGroupCreation(organisationsEinheit, keycloakId, syncTimestamp);
verify(repository).save(organisationsEinheitArgumentCaptor.capture()); verify(repository).save(organisationsEinheitArgumentCaptor.capture());
assertThat(organisationsEinheitArgumentCaptor.getValue()) assertThat(organisationsEinheitArgumentCaptor.getValue())
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment