use of com.sequenceiq.cloudbreak.workspace.model.Workspace in project cloudbreak by hortonworks.
the class RecipeService method createWithInternalUser.
public Recipe createWithInternalUser(Recipe recipe, @Nonnull Long workspaceId, String accountId) {
if (recipeViewRepository.findByNameAndWorkspaceId(recipe.getName(), workspaceId).isPresent()) {
String message = String.format("%s already exists with name '%s'", recipe.getResourceName(), recipe.getName());
throw new BadRequestException(message);
}
recipe.setResourceCrn(createCRN(accountId));
try {
return transactionService.required(() -> {
Workspace workspace = getWorkspaceService().getByIdWithoutAuth(workspaceId);
recipe.setWorkspace(workspace);
recipe.setCreationType(CreationType.SERVICE);
return super.pureSave(recipe);
});
} catch (TransactionService.TransactionExecutionException e) {
throw new TransactionService.TransactionRuntimeExecutionException(e);
}
}
use of com.sequenceiq.cloudbreak.workspace.model.Workspace in project cloudbreak by hortonworks.
the class ScheduledLifetimeCheckerTest method testValidateWhenClusterExceededByRunningTimeMoreThanTTL.
@Test
public void testValidateWhenClusterExceededByRunningTimeMoreThanTTL() {
StackTtlViewImpl stack = new StackTtlViewImpl();
stack.setId(STACK_ID);
long startTimeMillis = 0;
stack.setCreationFinished(startTimeMillis);
Workspace workspace = new Workspace();
Tenant tenant = new Tenant();
tenant.setName("tenant");
workspace.setTenant(tenant);
workspace.setName("workspace");
stack.setWorkspace(workspace);
int ttlMillis = 1;
StackStatus stackStatus = new StackStatus();
stackStatus.setStatus(Status.AVAILABLE);
stack.setStatus(stackStatus);
when(stackService.getAllAlive()).thenReturn(Collections.singletonList(stack));
when(stackService.getTtlValueForStack(anyLong())).thenReturn(Optional.of(Duration.ofMillis(ttlMillis)));
when(clock.getCurrentTimeMillis()).thenReturn(startTimeMillis + ttlMillis + 1);
underTest.validate();
verify(flowManager, times(1)).triggerTermination(stack.getId());
}
use of com.sequenceiq.cloudbreak.workspace.model.Workspace in project cloudbreak by hortonworks.
the class ImageCatalogServiceTest method getImageCatalog.
private ImageCatalog getImageCatalog() {
ImageCatalog imageCatalog = new ImageCatalog();
imageCatalog.setImageCatalogUrl(DEFAULT_CATALOG_URL);
imageCatalog.setName("default");
Workspace ws = new Workspace();
ws.setId(ORG_ID);
imageCatalog.setWorkspace(ws);
imageCatalog.setCreator("someone");
imageCatalog.setResourceCrn("someCrn");
return imageCatalog;
}
use of com.sequenceiq.cloudbreak.workspace.model.Workspace in project cloudbreak by hortonworks.
the class CloudbreakRestRequestThreadLocalServiceTest method aWorkspace.
private Workspace aWorkspace() {
Workspace workspace = new Workspace();
workspace.setId(WORKSPACE_ID);
return workspace;
}
use of com.sequenceiq.cloudbreak.workspace.model.Workspace in project cloudbreak by hortonworks.
the class ClusterDecoratorTest method testAutoTlsSetting.
@ParameterizedTest
@ValueSource(strings = { "true", "false" })
void testAutoTlsSetting(String valueString) {
boolean useAutoTls = Boolean.parseBoolean(valueString);
Cluster expectedClusterInstance = new Cluster();
Blueprint blueprint = getBlueprint();
when(sharedServiceConfigProvider.configureCluster(any(Cluster.class), any(User.class), any(Workspace.class))).thenReturn(expectedClusterInstance);
when(platformParameters.isAutoTlsSupported()).thenReturn(useAutoTls);
when(embeddedDatabaseService.isEmbeddedDatabaseOnAttachedDiskEnabled(stack, expectedClusterInstance)).thenReturn(false);
Cluster result = underTest.decorate(expectedClusterInstance, createClusterV4Request(), blueprint, user, new Workspace(), stack, null);
assertEquals(useAutoTls, result.getAutoTlsEnabled());
}
Aggregations