Search in sources :

Example 6 with FailurePolicy

use of com.sequenceiq.cloudbreak.domain.FailurePolicy in project cloudbreak by hortonworks.

the class StackRequestToStackConverterTest method testConvertWithNoGateway.

@SuppressFBWarnings(value = "DLS_DEAD_LOCAL_STORE")
@Test
public void testConvertWithNoGateway() throws CloudbreakException {
    InstanceGroup instanceGroup = mock(InstanceGroup.class);
    when(instanceGroup.getInstanceGroupType()).thenReturn(InstanceGroupType.CORE);
    // GIVEN
    ReflectionTestUtils.setField(underTest, "defaultRegions", "AWS:eu-west-2");
    given(conversionService.convert(any(Object.class), any(TypeDescriptor.class), any(TypeDescriptor.class))).willReturn(new HashSet<>(Collections.singletonList(instanceGroup)));
    given(conversionService.convert(any(Object.class), any(TypeDescriptor.class), any(TypeDescriptor.class))).willReturn(new HashSet<>(Collections.singletonList(instanceGroup)));
    given(conversionService.convert(any(StackAuthenticationRequest.class), eq(StackAuthentication.class))).willReturn(new StackAuthentication());
    given(conversionService.convert(any(FailurePolicyRequest.class), eq(FailurePolicy.class))).willReturn(new FailurePolicy());
    given(conversionService.convert(any(InstanceGroupRequest.class), eq(InstanceGroup.class))).willReturn(instanceGroup);
    given(conversionService.convert(any(OrchestratorRequest.class), eq(Orchestrator.class))).willReturn(new Orchestrator());
    given(orchestratorTypeResolver.resolveType(any(String.class))).willReturn(OrchestratorType.HOST);
    // WHEN
    try {
        Stack stack = underTest.convert(getRequest("stack/stack.json"));
    } catch (BadRequestException e) {
        // THEN
        Assert.assertEquals("Ambari server must be specified", e.getMessage());
    }
}
Also used : StackAuthenticationRequest(com.sequenceiq.cloudbreak.api.model.StackAuthenticationRequest) StackAuthentication(com.sequenceiq.cloudbreak.domain.StackAuthentication) InstanceGroupRequest(com.sequenceiq.cloudbreak.api.model.InstanceGroupRequest) Matchers.anyString(org.mockito.Matchers.anyString) Orchestrator(com.sequenceiq.cloudbreak.domain.Orchestrator) InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup) Stack(com.sequenceiq.cloudbreak.domain.Stack) TypeDescriptor(org.springframework.core.convert.TypeDescriptor) OrchestratorRequest(com.sequenceiq.cloudbreak.api.model.OrchestratorRequest) BadRequestException(com.sequenceiq.cloudbreak.controller.BadRequestException) FailurePolicyRequest(com.sequenceiq.cloudbreak.api.model.FailurePolicyRequest) FailurePolicy(com.sequenceiq.cloudbreak.domain.FailurePolicy) Test(org.junit.Test) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 7 with FailurePolicy

use of com.sequenceiq.cloudbreak.domain.FailurePolicy in project cloudbreak by hortonworks.

the class StackRequestToStackConverterTest method testForNoRegionAndNoDefaultRegion.

@Test
public void testForNoRegionAndNoDefaultRegion() throws CloudbreakException {
    InstanceGroup instanceGroup = mock(InstanceGroup.class);
    when(instanceGroup.getInstanceGroupType()).thenReturn(InstanceGroupType.GATEWAY);
    // GIVEN
    given(conversionService.convert(any(Object.class), any(TypeDescriptor.class), any(TypeDescriptor.class))).willReturn(new HashSet<>(Collections.singletonList(instanceGroup)));
    given(conversionService.convert(any(StackAuthenticationRequest.class), eq(StackAuthentication.class))).willReturn(new StackAuthentication());
    given(conversionService.convert(any(FailurePolicyRequest.class), eq(FailurePolicy.class))).willReturn(new FailurePolicy());
    given(conversionService.convert(any(InstanceGroupRequest.class), eq(InstanceGroup.class))).willReturn(instanceGroup);
    given(conversionService.convert(any(OrchestratorRequest.class), eq(Orchestrator.class))).willReturn(new Orchestrator());
    given(orchestratorTypeResolver.resolveType(any(Orchestrator.class))).willReturn(OrchestratorType.HOST);
    given(orchestratorTypeResolver.resolveType(any(String.class))).willReturn(OrchestratorType.HOST);
    given(defaultCostTaggingService.prepareDefaultTags(any(String.class), any(String.class), anyMap(), anyString())).willReturn(new HashMap<>());
    thrown.expect(BadRequestException.class);
    thrown.expectMessage("No default region is specified. Region cannot be empty.");
    // WHEN
    StackRequest stackRequest = getRequest("stack/stack.json");
    OrchestratorRequest orchestratorRequest = new OrchestratorRequest();
    orchestratorRequest.setType("SALT");
    stackRequest.setOrchestrator(orchestratorRequest);
    stackRequest.setRegion(null);
    underTest.convert(stackRequest);
}
Also used : StackAuthenticationRequest(com.sequenceiq.cloudbreak.api.model.StackAuthenticationRequest) StackAuthentication(com.sequenceiq.cloudbreak.domain.StackAuthentication) InstanceGroupRequest(com.sequenceiq.cloudbreak.api.model.InstanceGroupRequest) Matchers.anyString(org.mockito.Matchers.anyString) Orchestrator(com.sequenceiq.cloudbreak.domain.Orchestrator) StackRequest(com.sequenceiq.cloudbreak.api.model.StackRequest) InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup) TypeDescriptor(org.springframework.core.convert.TypeDescriptor) OrchestratorRequest(com.sequenceiq.cloudbreak.api.model.OrchestratorRequest) FailurePolicyRequest(com.sequenceiq.cloudbreak.api.model.FailurePolicyRequest) FailurePolicy(com.sequenceiq.cloudbreak.domain.FailurePolicy) Test(org.junit.Test)

Aggregations

FailurePolicy (com.sequenceiq.cloudbreak.domain.FailurePolicy)7 Orchestrator (com.sequenceiq.cloudbreak.domain.Orchestrator)5 StackAuthentication (com.sequenceiq.cloudbreak.domain.StackAuthentication)5 FailurePolicyRequest (com.sequenceiq.cloudbreak.api.model.FailurePolicyRequest)4 InstanceGroupRequest (com.sequenceiq.cloudbreak.api.model.InstanceGroupRequest)4 OrchestratorRequest (com.sequenceiq.cloudbreak.api.model.OrchestratorRequest)4 StackAuthenticationRequest (com.sequenceiq.cloudbreak.api.model.StackAuthenticationRequest)4 InstanceGroup (com.sequenceiq.cloudbreak.domain.InstanceGroup)4 Stack (com.sequenceiq.cloudbreak.domain.Stack)4 Test (org.junit.Test)4 Matchers.anyString (org.mockito.Matchers.anyString)4 TypeDescriptor (org.springframework.core.convert.TypeDescriptor)4 StackRequest (com.sequenceiq.cloudbreak.api.model.StackRequest)1 BadRequestException (com.sequenceiq.cloudbreak.controller.BadRequestException)1 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)1 Network (com.sequenceiq.cloudbreak.domain.Network)1 Resource (com.sequenceiq.cloudbreak.domain.Resource)1 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)1