use of com.sequenceiq.cloudbreak.domain.InstanceGroup 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);
}
use of com.sequenceiq.cloudbreak.domain.InstanceGroup in project cloudbreak by hortonworks.
the class UsageService method openUsagesForStack.
public void openUsagesForStack(Stack stack) {
LocalDateTime ldt = LocalDateTime.now();
List<CloudbreakUsage> usages = Lists.newArrayList();
for (InstanceGroup ig : stack.getInstanceGroups()) {
Template template = ig.getTemplate();
String instanceType = template == null ? "undefined" : template.getInstanceType();
String groupName = ig.getGroupName();
Integer instanceNum = ig.getNodeCount();
usages.add(usageGeneratorService.openNewUsage(stack, instanceType, instanceNum, groupName, ldt));
}
usageRepository.save(usages);
}
use of com.sequenceiq.cloudbreak.domain.InstanceGroup in project cloudbreak by hortonworks.
the class InstanceGroupRequestToInstanceGroupConverterTest method testConvert.
@Test
public void testConvert() {
// GIVEN
given(templateService.get(anyLong())).willReturn(TestUtil.gcpTemplate(51L));
given(securityGroupService.get(anyLong())).willReturn(TestUtil.securityGroup(1L));
// WHEN
InstanceGroup instanceGroup = underTest.convert(getRequest("stack/instance-group.json"));
// THEN
assertAllFieldsNotNull(instanceGroup, Collections.singletonList("stack"));
}
use of com.sequenceiq.cloudbreak.domain.InstanceGroup in project cloudbreak by hortonworks.
the class InstanceGroupToInstanceGroupResponseConverterTest method createSource.
@Override
public InstanceGroup createSource() {
InstanceGroup instanceGroup = TestUtil.instanceGroup(1L, InstanceGroupType.CORE, TestUtil.gcpTemplate(1L));
instanceGroup.setInstanceMetaData(getInstanceMetaData(instanceGroup));
return instanceGroup;
}
Aggregations