Search in sources :

Example 6 with CreateResourcesRequest

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);
}
Also used : CreateResourcesRequest(com.sequenceiq.cloudbreak.cloud.event.resource.migration.aws.CreateResourcesRequest) CloudResource(com.sequenceiq.cloudbreak.cloud.model.CloudResource) Test(org.junit.jupiter.api.Test)

Aggregations

CreateResourcesRequest (com.sequenceiq.cloudbreak.cloud.event.resource.migration.aws.CreateResourcesRequest)6 Test (org.junit.jupiter.api.Test)4 CreateResourcesResult (com.sequenceiq.cloudbreak.cloud.event.resource.migration.aws.CreateResourcesResult)3 Event (reactor.bus.Event)3 CloudResource (com.sequenceiq.cloudbreak.cloud.model.CloudResource)2 AwsContext (com.sequenceiq.cloudbreak.cloud.aws.common.context.AwsContext)1 AuthenticatedContext (com.sequenceiq.cloudbreak.cloud.context.AuthenticatedContext)1 CloudContext (com.sequenceiq.cloudbreak.cloud.context.CloudContext)1 CloudCredential (com.sequenceiq.cloudbreak.cloud.model.CloudCredential)1 CloudStack (com.sequenceiq.cloudbreak.cloud.model.CloudStack)1 Network (com.sequenceiq.cloudbreak.cloud.model.Network)1 AwsVariantMigrationTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.event.AwsVariantMigrationTriggerEvent)1 ResourceRecreator (com.sequenceiq.cloudbreak.core.flow2.stack.migration.handler.service.ResourceRecreator)1 Map (java.util.Map)1 Bean (org.springframework.context.annotation.Bean)1