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;
}
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());
}
}
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);
}
Aggregations