Search in sources :

Example 6 with StackAuthentication

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

the class StackAuthenticationRequestToStackAuthenticationConverter method convert.

@Override
public StackAuthentication convert(StackAuthenticationRequest source) {
    StackAuthentication stackAuthentication = new StackAuthentication();
    stackAuthentication.setLoginUserName(Strings.isNullOrEmpty(source.getLoginUserName()) ? "cloudbreak" : source.getLoginUserName());
    stackAuthentication.setPublicKey(source.getPublicKey());
    stackAuthentication.setPublicKeyId(source.getPublicKeyId());
    return stackAuthentication;
}
Also used : StackAuthentication(com.sequenceiq.cloudbreak.domain.StackAuthentication)

Example 7 with StackAuthentication

use of com.sequenceiq.cloudbreak.domain.StackAuthentication 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 8 with StackAuthentication

use of com.sequenceiq.cloudbreak.domain.StackAuthentication 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

StackAuthentication (com.sequenceiq.cloudbreak.domain.StackAuthentication)8 FailurePolicy (com.sequenceiq.cloudbreak.domain.FailurePolicy)6 InstanceGroup (com.sequenceiq.cloudbreak.domain.InstanceGroup)6 Orchestrator (com.sequenceiq.cloudbreak.domain.Orchestrator)6 Stack (com.sequenceiq.cloudbreak.domain.Stack)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 Test (org.junit.Test)4 Matchers.anyString (org.mockito.Matchers.anyString)4 TypeDescriptor (org.springframework.core.convert.TypeDescriptor)4 Network (com.sequenceiq.cloudbreak.domain.Network)2 DetailedStackStatus (com.sequenceiq.cloudbreak.api.model.DetailedStackStatus)1 StackRequest (com.sequenceiq.cloudbreak.api.model.StackRequest)1 CloudInstance (com.sequenceiq.cloudbreak.cloud.model.CloudInstance)1 InstanceAuthentication (com.sequenceiq.cloudbreak.cloud.model.InstanceAuthentication)1 InstanceStatus (com.sequenceiq.cloudbreak.cloud.model.InstanceStatus)1 InstanceTemplate (com.sequenceiq.cloudbreak.cloud.model.InstanceTemplate)1 BadRequestException (com.sequenceiq.cloudbreak.controller.BadRequestException)1