use of io.imunity.furms.domain.site_agent.CorrelationId in project furms by unity-idm.
the class SiteAgentConnectionServiceImplTest method shouldNotDeleteWhenSiteIdAndSiteExternalIdAreNotRelated.
@Test
void shouldNotDeleteWhenSiteIdAndSiteExternalIdAreNotRelated() {
SiteId id = new SiteId("id");
SiteExternalId externalId = new SiteExternalId("externalId");
CorrelationId correlationId = CorrelationId.randomID();
String json = "json";
SiteAgentPendingMessage message = SiteAgentPendingMessage.builder().siteExternalId(new SiteExternalId("externalId1")).jsonContent(json).build();
when(repository.find(correlationId)).thenReturn(Optional.of(message));
when(siteRepository.findById(id.id)).thenReturn(Optional.of(Site.builder().externalId(externalId).build()));
assertThrows(IllegalArgumentException.class, () -> service.delete(id, correlationId));
verify(siteAgentPendingMessageRemoverConnector, times(0)).remove(correlationId, json);
verify(repository, times(0)).delete(correlationId);
}
use of io.imunity.furms.domain.site_agent.CorrelationId in project furms by unity-idm.
the class SiteAgentConnectionServiceImplTest method shouldNotRetryWhenSiteIdAndSiteExternalIdAreNotRelated.
@Test
void shouldNotRetryWhenSiteIdAndSiteExternalIdAreNotRelated() {
SiteId id = new SiteId("id");
SiteExternalId externalId = new SiteExternalId("externalId");
CorrelationId correlationId = CorrelationId.randomID();
String json = "json";
SiteAgentPendingMessage message = SiteAgentPendingMessage.builder().siteExternalId(new SiteExternalId("externalId1")).jsonContent(json).build();
when(repository.find(correlationId)).thenReturn(Optional.of(message));
when(siteRepository.findById(id.id)).thenReturn(Optional.of(Site.builder().externalId(externalId).build()));
assertThrows(IllegalArgumentException.class, () -> service.retry(id, correlationId));
verify(siteAgentRetryService, times(0)).retry(externalId, json);
verify(repository, times(0)).overwriteSentTime(correlationId, ZonedDateTime.now(clock).toLocalDateTime());
}
use of io.imunity.furms.domain.site_agent.CorrelationId in project furms by unity-idm.
the class SSHKeyOperationServiceTest method shouldUpdateAndRemoveKey.
@Test
void shouldUpdateAndRemoveKey() {
CorrelationId correlationId = CorrelationId.randomID();
SSHKey key = SSHKey.builder().id("key").value("ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDvFdnmjLkBdvUqojB/fWMGol4PyhUHgRCn6/Hiaz/pnedck" + "Spgh+RvDor7UsU8bkOQBYc0Yr1ETL1wUR1vIFxqTm23JmmJsyO5EJgUw92nVIc0gj1u5q6xRKg3ONnxEXhJD/78OSp/Z" + "Y8dJw4fnEYl22LfvGXIuCZbvtKNv1Az19y9LU57kDBi3B2ZBDn6rjI6sTeO2jDzb0m0HR1jbLzBO43sxqnVHC7yf9DM7Tp" + "bbgd1Q2km5eySfit/5E3EJBYY4PvankHzGts1NCblK8rX6w+MlV5L1pVZkstVF6hn9gMSM0fInvpJobhQ5KzcL8sJTKO5AL" + "mb9xUkdFjZk9bL demo@demo.pl").ownerId(new PersistentId("id")).sites(Sets.newHashSet("site")).build();
when(sshKeysRepository.findById("key")).thenReturn(Optional.of(key));
when(sshKeyOperationRepository.findByCorrelationId(correlationId)).thenReturn(SSHKeyOperationJob.builder().id("id").correlationId(correlationId).operation(SSHKeyOperation.REMOVE).status(SSHKeyOperationStatus.ACK).sshkeyId("key").siteId("site").build());
service.updateStatus(correlationId, new SSHKeyOperationResult(SSHKeyOperationStatus.DONE, new SSHKeyOperationError(null, null)));
verify(sshKeyOperationRepository, times(1)).update(eq("id"), eq(SSHKeyOperationStatus.DONE), eq(Optional.empty()), any());
verify(sshKeysRepository).delete("key");
}
use of io.imunity.furms.domain.site_agent.CorrelationId in project furms by unity-idm.
the class SSHKeyOperationServiceTest method shouldUpdateStatusAndAddHistoryWhenUpdateKey.
@Test
void shouldUpdateStatusAndAddHistoryWhenUpdateKey() {
CorrelationId correlationId = CorrelationId.randomID();
SSHKey key = SSHKey.builder().id("key").value("ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDvFdnmjLkBdvUqojB/fWMGol4PyhUHgRCn6/Hiaz/pnedck" + "Spgh+RvDor7UsU8bkOQBYc0Yr1ETL1wUR1vIFxqTm23JmmJsyO5EJgUw92nVIc0gj1u5q6xRKg3ONnxEXhJD/78OSp/Z" + "Y8dJw4fnEYl22LfvGXIuCZbvtKNv1Az19y9LU57kDBi3B2ZBDn6rjI6sTeO2jDzb0m0HR1jbLzBO43sxqnVHC7yf9DM7Tp" + "bbgd1Q2km5eySfit/5E3EJBYY4PvankHzGts1NCblK8rX6w+MlV5L1pVZkstVF6hn9gMSM0fInvpJobhQ5KzcL8sJTKO5AL" + "mb9xUkdFjZk9bL demo@demo.pl").ownerId(new PersistentId("id")).sites(Sets.newHashSet("site")).build();
when(sshKeyOperationRepository.findByCorrelationId(correlationId)).thenReturn(SSHKeyOperationJob.builder().id("id").correlationId(correlationId).operation(SSHKeyOperation.UPDATE).status(SSHKeyOperationStatus.ACK).sshkeyId("key").siteId("site").build());
when(sshKeysRepository.findById("key")).thenReturn(Optional.of(key));
when(sshKeyHistoryRepository.findBySiteIdAndOwnerIdLimitTo("site", "id", 1)).thenReturn(Collections.singletonList(SSHKeyHistory.builder().sshkeyFingerprint("xxx").build()));
service.updateStatus(correlationId, new SSHKeyOperationResult(SSHKeyOperationStatus.DONE, new SSHKeyOperationError(null, null)));
verify(sshKeyOperationRepository, times(1)).update(eq("id"), eq(SSHKeyOperationStatus.DONE), eq(Optional.empty()), any());
ArgumentCaptor<SSHKeyHistory> history = ArgumentCaptor.forClass(SSHKeyHistory.class);
verify(sshKeyHistoryRepository, times(1)).create(history.capture());
assertThat(history.getValue().sshkeyFingerprint).isEqualTo(key.getFingerprint());
assertThat(history.getValue().siteId).isEqualTo("site");
}
use of io.imunity.furms.domain.site_agent.CorrelationId in project furms by unity-idm.
the class ProjectAllocationInstallationStatusUpdaterTest method shouldUpdateProjectDeallocation.
@Test
void shouldUpdateProjectDeallocation() {
// given
CorrelationId id = new CorrelationId("id");
// when
when(repository.findDeallocationByCorrelationId(id.id)).thenReturn(Optional.of(ProjectDeallocation.builder().status(ProjectDeallocationStatus.PENDING).build()));
service.updateStatus(id, ProjectDeallocationStatus.PENDING, Optional.empty());
// then
orderVerifier.verify(repository).update(id.id, ProjectDeallocationStatus.PENDING, Optional.empty());
}
Aggregations