use of com.sequenceiq.cloudbreak.workspace.model.Workspace in project cloudbreak by hortonworks.
the class CloudResourceAdvisorTest method createBlueprint.
private Blueprint createBlueprint() {
Blueprint blueprint = new Blueprint();
Workspace workspace = new Workspace();
Tenant tenant = new Tenant();
tenant.setName("tenant");
workspace.setTenant(tenant);
blueprint.setWorkspace(workspace);
blueprint.setBlueprintText("{\"Blueprints\":{123:2}}");
return blueprint;
}
use of com.sequenceiq.cloudbreak.workspace.model.Workspace in project cloudbreak by hortonworks.
the class LoggingAgentAutoRestartPatchServiceTest method createStack.
private Stack createStack() {
Stack stack = new Stack();
stack.setId(1L);
stack.setType(StackType.WORKLOAD);
Cluster cluster = new Cluster();
cluster.setId(1L);
Workspace workspace = new Workspace();
workspace.setId(1L);
stack.setWorkspace(workspace);
stack.setCluster(cluster);
stack.setResourceCrn("crn:cdp:datahub:us-west-1:accountId:cluster:name");
InstanceGroup instanceGroup = createInstanceGroup();
instanceGroup.setInstanceMetaData(Set.of(createInstanceMetaData()));
stack.setInstanceGroups(Set.of(instanceGroup));
return stack;
}
use of com.sequenceiq.cloudbreak.workspace.model.Workspace in project cloudbreak by hortonworks.
the class ClusterTemplateServiceCreationValidationTest method testWhenClusterTemplateDoesNotContainBlueprintBadRequestExceptionComes.
@Test
void testWhenClusterTemplateDoesNotContainBlueprintBadRequestExceptionComes() {
Workspace workspace = new Workspace();
Blueprint blueprint = new Blueprint();
Cluster cluster = new Cluster();
cluster.setBlueprint(blueprint);
Stack stack = new Stack();
stack.setEnvironmentCrn("someCrn");
stack.setCluster(cluster);
ClusterTemplate clusterTemplate = new ClusterTemplate();
clusterTemplate.setStackTemplate(stack);
clusterTemplate.setStatus(ResourceStatus.USER_MANAGED);
clusterTemplate.setWorkspace(workspace);
when(clusterTemplateRepository.findByNameAndWorkspace(any(), any())).thenReturn(Optional.empty());
when(blueprintService.getAllAvailableInWorkspace(workspace)).thenReturn(Collections.emptySet());
when(entitlementService.internalTenant(anyString())).thenReturn(true);
when(internalClusterTemplateValidator.isInternalTemplateInNotInternalTenant(anyBoolean(), any(FeatureState.class))).thenReturn(true);
Exception e = Assertions.assertThrows(BadRequestException.class, () -> underTest.createForLoggedInUser(clusterTemplate, WORKSPACE_ID, ACCOUNT_ID, CREATOR_ID));
Assert.assertEquals("Cluster definition should contain a Datahub template!", e.getMessage());
}
use of com.sequenceiq.cloudbreak.workspace.model.Workspace in project cloudbreak by hortonworks.
the class SharedServiceValidatorTest method getWorkspace.
private Workspace getWorkspace() {
Workspace workspace = new Workspace();
workspace.setId(1L);
return workspace;
}
use of com.sequenceiq.cloudbreak.workspace.model.Workspace in project cloudbreak by hortonworks.
the class StackService method getByCrnInWorkspaceWithEntries.
public StackV4Response getByCrnInWorkspaceWithEntries(String crn, Long workspaceId, Set<String> entries, User user, StackType stackType) {
try {
return transactionService.required(() -> {
Workspace workspace = workspaceService.get(workspaceId, user);
ShowTerminatedClustersAfterConfig showTerminatedClustersAfterConfig = showTerminatedClusterConfigService.get();
Optional<Stack> stack = findByCrnAndWorkspaceIdWithLists(crn, workspace.getId(), stackType, showTerminatedClustersAfterConfig);
if (stack.isEmpty()) {
throw new NotFoundException(format("Stack not found by crn '%s'", crn));
}
StackV4Response stackResponse = stackToStackV4ResponseConverter.convert(stack.get());
stackResponse = stackResponseDecorator.decorate(stackResponse, stack.get(), entries);
return stackResponse;
});
} catch (TransactionExecutionException e) {
throw new TransactionRuntimeExecutionException(e);
}
}
Aggregations