use of io.imunity.furms.domain.project_allocation.ProjectAllocationResolved in project furms by unity-idm.
the class ProjectAllocationAuditLogServiceIntegrationTest method shouldDetectProjectAllocationDeletion.
@Test
void shouldDetectProjectAllocationDeletion() {
// given
String id = "id";
ProjectAllocationResolved projectAllocationResolved = ProjectAllocationResolved.builder().amount(BigDecimal.TEN).consumed(BigDecimal.ZERO).build();
ProjectAllocation projectAllocation = ProjectAllocation.builder().build();
when(projectAllocationRepository.findByIdWithRelatedObjects(id)).thenReturn(Optional.of(projectAllocationResolved));
when(projectAllocationRepository.findById(id)).thenReturn(Optional.of(projectAllocation));
// when
service.delete("projectId", id);
ArgumentCaptor<AuditLog> argument = ArgumentCaptor.forClass(AuditLog.class);
Mockito.verify(auditLogRepository).create(argument.capture());
assertEquals(Operation.PROJECT_ALLOCATION, argument.getValue().operationCategory);
assertEquals(Action.DELETE, argument.getValue().action);
}
use of io.imunity.furms.domain.project_allocation.ProjectAllocationResolved in project furms by unity-idm.
the class ProjectAllocationInstallationServiceTest method shouldDeleteProjectAllocationIfFailed.
@Test
void shouldDeleteProjectAllocationIfFailed() {
// given
ProjectAllocationResolved projectAllocationInstallation = ProjectAllocationResolved.builder().id("id").site(Site.builder().id("id").build()).build();
// when
when(repository.findByProjectAllocationId("id")).thenReturn(ProjectAllocationInstallation.builder().id("id").projectAllocationId("id").status(ProjectAllocationInstallationStatus.PROJECT_INSTALLATION_FAILED).build());
service.createDeallocation(projectAllocationInstallation);
// then
orderVerifier.verify(projectAllocationRepository).deleteById("id");
}
use of io.imunity.furms.domain.project_allocation.ProjectAllocationResolved in project furms by unity-idm.
the class ProjectAllocationInstallationServiceTest method shouldCreateProjectDeallocation.
@Test
void shouldCreateProjectDeallocation() {
// given
ProjectAllocationResolved projectAllocationInstallation = ProjectAllocationResolved.builder().id("id").site(Site.builder().id("id").build()).build();
// when
when(repository.findByProjectAllocationId("id")).thenReturn(ProjectAllocationInstallation.builder().status(ProjectAllocationInstallationStatus.ACKNOWLEDGED).build());
service.createDeallocation(projectAllocationInstallation);
for (TransactionSynchronization transactionSynchronization : TransactionSynchronizationManager.getSynchronizations()) {
transactionSynchronization.afterCommit();
}
// then
orderVerifier.verify(repository).create(any(ProjectDeallocation.class));
orderVerifier.verify(siteAgentProjectAllocationInstallationService).deallocateProject(any(), any());
}
use of io.imunity.furms.domain.project_allocation.ProjectAllocationResolved in project furms by unity-idm.
the class ResourceUsageUpdaterTest method shouldUpdateResourceUsage.
@Test
void shouldUpdateResourceUsage() {
ResourceUsage resourceUsage = ResourceUsage.builder().projectId("id").projectAllocationId("id").cumulativeConsumption(BigDecimal.TEN).probedAt(LocalDateTime.now().minusMinutes(5)).build();
ProjectAllocationResolved build = ProjectAllocationResolved.builder().build();
when(projectAllocationRepository.findByIdWithRelatedObjects("id")).thenReturn(Optional.of(build));
service.updateUsage(resourceUsage);
verify(repository).create(resourceUsage, build);
}
use of io.imunity.furms.domain.project_allocation.ProjectAllocationResolved in project furms by unity-idm.
the class ProjectAllocationDatabaseRepositoryTest method shouldReturnAllocationsWithRelatedObjects.
@Test
void shouldReturnAllocationsWithRelatedObjects() {
entityRepository.save(ProjectAllocationEntity.builder().projectId(projectId).communityAllocationId(communityAllocationId).name("anem").amount(new BigDecimal(10)).build());
Set<ProjectAllocationResolved> entities = entityDatabaseRepository.findAllWithRelatedObjects(projectId.toString());
assertThat(entities.size()).isEqualTo(1);
ProjectAllocationResolved entity = entities.iterator().next();
assertThat(entity.name).isEqualTo("anem");
assertThat(entity.amount).isEqualTo(new BigDecimal(10));
assertThat(entity.site.getName()).isEqualTo("name");
assertThat(entity.resourceType.type).isEqualTo(ResourceMeasureType.FLOATING_POINT);
assertThat(entity.resourceType.unit).isEqualTo(ResourceMeasureUnit.TERA);
assertThat(entity.resourceCredit.name).isEqualTo("name");
assertThat(entity.resourceCredit.splittable).isEqualTo(true);
assertThat(entity.resourceCredit.amount).isEqualTo(new BigDecimal(100));
}
Aggregations