use of com.sequenceiq.cloudbreak.cloud.event.resource.migration.aws.CreateResourcesRequest in project cloudbreak by hortonworks.
the class SecurityGroupRecreatorServiceTest method testAcceptWhenPersistNotSuccess.
@Test
public void testAcceptWhenPersistNotSuccess() throws Exception {
String hostGroupName = "hostGroupName";
CreateResourcesRequest request = new CreateResourcesRequest(cloudContext, cloudCredential, cloudStack, hostGroupName);
CloudResource cloudResource = CloudResource.builder().type(ResourceType.AWS_SECURITY_GROUP).status(CommonStatus.CREATED).name("name").params(Collections.emptyMap()).build();
when(group.getName()).thenReturn(hostGroupName);
when(cloudStack.getGroups()).thenReturn(List.of(group));
when(cloudStack.getNetwork()).thenReturn(network);
Exception value = new Exception();
when(resourcePersisted.getException()).thenReturn(value);
when(persistenceNotifier.notifyAllocation(any(), any())).thenReturn(resourcePersisted);
when(awsSecurityGroupResourceBuilder.create(awsContext, ac, group, network)).thenReturn(cloudResource);
Exception actual = Assertions.assertThrows(Exception.class, () -> underTest.recreate(request, awsContext, ac));
Assertions.assertEquals(value, actual);
verify(awsSecurityGroupResourceBuilder, never()).build(any(), any(), any(), any(), any(), any());
verify(awsSecurityGroupResourceBuilder).create(awsContext, ac, group, network);
}
Aggregations