本文整理匯總了Java中org.eclipse.che.api.workspace.shared.dto.WorkspaceConfigDto類的典型用法代碼示例。如果您正苦於以下問題:Java WorkspaceConfigDto類的具體用法?Java WorkspaceConfigDto怎麽用?Java WorkspaceConfigDto使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
WorkspaceConfigDto類屬於org.eclipse.che.api.workspace.shared.dto包,在下文中一共展示了WorkspaceConfigDto類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: deserializeWorkspaceTemplate
import org.eclipse.che.api.workspace.shared.dto.WorkspaceConfigDto; //導入依賴的package包/類
public WorkspaceConfigDto deserializeWorkspaceTemplate(String templateName) {
requireNonNull(templateName);
try {
URL url =
Resources.getResource(
WorkspaceDtoDeserializer.class,
format("/templates/workspace/%s/%s", infrastructure, templateName));
return DtoFactory.getInstance()
.createDtoFromJson(Resources.toString(url, Charsets.UTF_8), WorkspaceConfigDto.class);
} catch (IOException | IllegalArgumentException | JsonSyntaxException e) {
LOG.error(
"Fail to read workspace template {} for infrastructure {} because {} ",
templateName,
infrastructure,
e.getMessage());
throw new RuntimeException(e.getLocalizedMessage(), e);
}
}
示例2: shouldThrowFactoryUrlExceptionIfProjectNameInvalid
import org.eclipse.che.api.workspace.shared.dto.WorkspaceConfigDto; //導入依賴的package包/類
@Test(
dataProvider = "invalidProjectNamesProvider",
expectedExceptions = ApiException.class,
expectedExceptionsMessageRegExp =
"Project name must contain only Latin letters, "
+ "digits or these following special characters -._."
)
public void shouldThrowFactoryUrlExceptionIfProjectNameInvalid(String projectName)
throws Exception {
// given
factory.withWorkspace(
newDto(WorkspaceConfigDto.class)
.withProjects(
singletonList(
newDto(ProjectConfigDto.class).withType("type").withName(projectName))));
// when, then
validator.validateProjects(factory);
}
示例3: shouldBeAbleToValidateValidProjectName
import org.eclipse.che.api.workspace.shared.dto.WorkspaceConfigDto; //導入依賴的package包/類
@Test(dataProvider = "validProjectNamesProvider")
public void shouldBeAbleToValidateValidProjectName(String projectName) throws Exception {
// given
prepareFactoryWithGivenStorage("git", VALID_REPOSITORY_URL, VALID_PROJECT_PATH);
factory.withWorkspace(
newDto(WorkspaceConfigDto.class)
.withProjects(
singletonList(
newDto(ProjectConfigDto.class)
.withType("type")
.withName(projectName)
.withSource(
newDto(SourceStorageDto.class)
.withType("git")
.withLocation(VALID_REPOSITORY_URL))
.withPath(VALID_PROJECT_PATH))));
// when, then
validator.validateProjects(factory);
}
示例4: asDto
import org.eclipse.che.api.workspace.shared.dto.WorkspaceConfigDto; //導入依賴的package包/類
/** Converts {@link WorkspaceConfig} to {@link WorkspaceConfigDto}. */
public static WorkspaceConfigDto asDto(WorkspaceConfig workspace) {
List<CommandDto> commands =
workspace.getCommands().stream().map(DtoConverter::asDto).collect(toList());
List<ProjectConfigDto> projects =
workspace.getProjects().stream().map(DtoConverter::asDto).collect(toList());
Map<String, EnvironmentDto> environments =
workspace
.getEnvironments()
.entrySet()
.stream()
.collect(toMap(Map.Entry::getKey, entry -> asDto(entry.getValue())));
return newDto(WorkspaceConfigDto.class)
.withName(workspace.getName())
.withDefaultEnv(workspace.getDefaultEnv())
.withCommands(commands)
.withProjects(projects)
.withEnvironments(environments)
.withDescription(workspace.getDescription());
}
示例5: createStack
import org.eclipse.che.api.workspace.shared.dto.WorkspaceConfigDto; //導入依賴的package包/類
private static StackDto createStack() {
return newDto(StackDto.class)
.withId("stack123")
.withName("Name")
.withDescription("Description")
.withScope("general")
.withCreator("user123")
.withTags(new ArrayList<>(Collections.singletonList("latest")))
.withWorkspaceConfig(newDto(WorkspaceConfigDto.class))
.withSource(
newDto(StackSourceDto.class).withType("recipe").withOrigin("FROM codenvy/ubuntu_jdk8"))
.withComponents(
new ArrayList<>(
Collections.singletonList(
newDto(StackComponentDto.class).withName("maven").withVersion("3.3.1"))));
}
示例6: checkWithCustomFactoryJsonFile
import org.eclipse.che.api.workspace.shared.dto.WorkspaceConfigDto; //導入依賴的package包/類
/** Check that with a custom factory.json we've this factory being built */
@Test
public void checkWithCustomFactoryJsonFile() throws Exception {
WorkspaceConfigDto workspaceConfigDto = newDto(WorkspaceConfigDto.class);
FactoryDto templateFactory =
newDto(FactoryDto.class).withV("4.0").withName("florent").withWorkspace(workspaceConfigDto);
String jsonFactory = DtoFactory.getInstance().toJson(templateFactory);
String myLocation = "http://foo-location";
when(urlChecker.exists(myLocation)).thenReturn(FALSE);
when(urlFetcher.fetch(myLocation)).thenReturn(jsonFactory);
FactoryDto factory = urlFactoryBuilder.createFactory(myLocation);
assertEquals(templateFactory, factory);
}
示例7: setup
import org.eclipse.che.api.workspace.shared.dto.WorkspaceConfigDto; //導入依賴的package包/類
@BeforeMethod
public void setup() throws Exception {
FactoryConnection factoryConnection = mock(FactoryConnection.class);
FactoryDto factory = mock(FactoryDto.class);
WorkspaceConfigDto workspace = mock(WorkspaceConfigDto.class);
ProjectConfigDto project = mock(ProjectConfigDto.class);
SourceStorageDto source = mock(SourceStorageDto.class);
ConfigurationProperties configurationProperties = mock(ConfigurationProperties.class);
Map<String, String> properties = new HashMap<>();
properties.put(
"env.CODENVY_BITBUCKET_SERVER_WEBHOOK_WEBHOOK1_REPOSITORY_URL",
"http://[email protected]/scm/projectkey/repository.git");
properties.put("env.CODENVY_BITBUCKET_SERVER_WEBHOOK_WEBHOOK1_FACTORY1_ID", "factoryId");
when(configurationProperties.getProperties(eq("env.CODENVY_BITBUCKET_SERVER_WEBHOOK_.+")))
.thenReturn(properties);
when(factory.getWorkspace()).thenReturn(workspace);
when(factory.getLink(anyString())).thenReturn(mock(Link.class));
when(factory.getId()).thenReturn("factoryId");
when(factoryConnection.getFactory("factoryId")).thenReturn(factory);
when(factoryConnection.updateFactory(factory)).thenReturn(factory);
when(workspace.getProjects()).thenReturn(singletonList(project));
when(project.getSource()).thenReturn(source);
when(source.getType()).thenReturn("type");
when(source.getLocation())
.thenReturn("http://[email protected]/scm/projectkey/repository.git");
parameters.put("branch", "testBranch");
when(source.getParameters()).thenReturn(parameters);
service =
spy(
new BitbucketServerWebhookService(
mock(AuthConnection.class),
factoryConnection,
configurationProperties,
"username",
"password",
"http://bitbucketserver.host"));
}
示例8: createWorkspace
import org.eclipse.che.api.workspace.shared.dto.WorkspaceConfigDto; //導入依賴的package包/類
/** Creates a new workspace. */
public Workspace createWorkspace(
String workspaceName, int memory, MemoryMeasure memoryUnit, WorkspaceConfigDto workspace)
throws Exception {
EnvironmentDto environment = workspace.getEnvironments().get("replaced_name");
environment
.getMachines()
.values()
.stream()
.filter(WsAgentMachineFinderUtil::containsWsAgentServerOrInstaller)
.forEach(
m ->
m.getAttributes()
.put(MEMORY_LIMIT_ATTRIBUTE, Long.toString(convertToByte(memory, memoryUnit))));
workspace.getEnvironments().remove("replaced_name");
workspace.getEnvironments().put(workspaceName, environment);
workspace.setName(workspaceName);
workspace.setDefaultEnv(workspaceName);
WorkspaceDto workspaceDto =
requestFactory
.fromUrl(getBaseUrl())
.usePostMethod()
.setBody(workspace)
.request()
.asDto(WorkspaceDto.class);
LOG.info("Workspace name='{}' and id='{}' created", workspaceName, workspaceDto.getId());
return workspaceDto;
}
示例9: prepareFactoryWithGivenStorage
import org.eclipse.che.api.workspace.shared.dto.WorkspaceConfigDto; //導入依賴的package包/類
private FactoryDto prepareFactoryWithGivenStorage(String type, String location, String path) {
return factory.withWorkspace(
newDto(WorkspaceConfigDto.class)
.withProjects(
singletonList(
newDto(ProjectConfigDto.class)
.withSource(
newDto(SourceStorageDto.class).withType(type).withLocation(location))
.withPath(path))));
}
示例10: relativizeRecipeLinks
import org.eclipse.che.api.workspace.shared.dto.WorkspaceConfigDto; //導入依賴的package包/類
private void relativizeRecipeLinks(WorkspaceConfigDto config) {
if (config != null) {
Map<String, EnvironmentDto> environments = config.getEnvironments();
if (environments != null && !environments.isEmpty()) {
for (EnvironmentDto environment : environments.values()) {
relativizeRecipeLinks(environment);
}
}
}
}
示例11: shouldCreateWorkspace
import org.eclipse.che.api.workspace.shared.dto.WorkspaceConfigDto; //導入依賴的package包/類
@Test
public void shouldCreateWorkspace() throws Exception {
final WorkspaceConfigDto configDto = createConfigDto();
final WorkspaceImpl workspace = createWorkspace(configDto);
when(wsManager.createWorkspace(any(), anyString(), any())).thenReturn(workspace);
final Response response =
given()
.auth()
.basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD)
.contentType("application/json")
.body(configDto)
.when()
.post(
SECURE_PATH
+ "/workspace"
+ "?namespace=test"
+ "&attribute=stackId:stack123"
+ "&attribute=factoryId:factory123"
+ "&attribute=custom:custom:value");
assertEquals(response.getStatusCode(), 201);
assertEquals(
new WorkspaceImpl(unwrapDto(response, WorkspaceDto.class), TEST_ACCOUNT), workspace);
verify(wsManager)
.createWorkspace(
any(),
eq("test"),
eq(
ImmutableMap.of(
"stackId", "stack123",
"factoryId", "factory123",
"custom", "custom:value")));
}
示例12: shouldUseUsernameAsNamespaceWhenCreatingWorkspaceWithoutSpecifiedNamespace
import org.eclipse.che.api.workspace.shared.dto.WorkspaceConfigDto; //導入依賴的package包/類
@Test
public void shouldUseUsernameAsNamespaceWhenCreatingWorkspaceWithoutSpecifiedNamespace()
throws Exception {
final WorkspaceConfigDto configDto = createConfigDto();
final WorkspaceImpl workspace = createWorkspace(configDto);
when(wsManager.createWorkspace(any(WorkspaceConfig.class), anyString(), any()))
.thenReturn(workspace);
final Response response =
given()
.auth()
.basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD)
.contentType("application/json")
.body(configDto)
.when()
.post(
SECURE_PATH
+ "/workspace"
+ "?attribute=stackId:stack123"
+ "&attribute=factoryId:factory123"
+ "&attribute=custom:custom:value");
assertEquals(response.getStatusCode(), 201);
assertEquals(
new WorkspaceImpl(unwrapDto(response, WorkspaceDto.class), TEST_ACCOUNT), workspace);
verify(wsManager)
.createWorkspace(
any(),
eq(NAMESPACE),
eq(
ImmutableMap.of(
"stackId", "stack123",
"factoryId", "factory123",
"custom", "custom:value")));
}
示例13: shouldStartTheWorkspaceAfterItIsCreatedWhenStartAfterCreateParamIsTrue
import org.eclipse.che.api.workspace.shared.dto.WorkspaceConfigDto; //導入依賴的package包/類
@Test
public void shouldStartTheWorkspaceAfterItIsCreatedWhenStartAfterCreateParamIsTrue()
throws Exception {
final WorkspaceConfigDto configDto = createConfigDto();
final WorkspaceImpl workspace = createWorkspace(configDto);
when(wsManager.createWorkspace(any(), any(), any())).thenReturn(workspace);
given()
.auth()
.basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD)
.contentType("application/json")
.body(configDto)
.when()
.post(
SECURE_PATH
+ "/workspace"
+ "?attribute=stackId:stack123"
+ "&attribute=factoryId:factory123"
+ "&attribute=custom:custom:value"
+ "&start-after-create=true");
verify(wsManager).startWorkspace(workspace.getId(), null, emptyMap());
verify(wsManager)
.createWorkspace(
any(),
anyString(),
eq(
ImmutableMap.of(
"stackId", "stack123",
"factoryId", "factory123",
"custom", "custom:value")));
}
示例14: shouldRelativizeLinksOnCreateWorkspace
import org.eclipse.che.api.workspace.shared.dto.WorkspaceConfigDto; //導入依賴的package包/類
@Test
public void shouldRelativizeLinksOnCreateWorkspace() throws Exception {
final String initialLocation = "http://localhost:8080/api/recipe/idrecipe123456789/script";
final WorkspaceConfigDto configDto = createConfigDto();
configDto
.getEnvironments()
.get(configDto.getDefaultEnv())
.getRecipe()
.withLocation(initialLocation)
.withType("dockerfile");
ArgumentCaptor<WorkspaceConfigDto> captor = ArgumentCaptor.forClass(WorkspaceConfigDto.class);
when(wsManager.createWorkspace(captor.capture(), any(), any()))
.thenAnswer(invocation -> createWorkspace(captor.getValue()));
final Response response =
given()
.auth()
.basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD)
.contentType("application/json")
.body(configDto)
.when()
.post(
SECURE_PATH
+ "/workspace"
+ "?namespace=test"
+ "&attribute=stackId:stack123"
+ "&attribute=custom:custom:value");
assertEquals(response.getStatusCode(), 201);
String savedLocation =
unwrapDto(response, WorkspaceDto.class)
.getConfig()
.getEnvironments()
.get(configDto.getDefaultEnv())
.getRecipe()
.getLocation();
assertEquals(savedLocation, initialLocation.substring(API_ENDPOINT.length()));
}
示例15: createConfigDto
import org.eclipse.che.api.workspace.shared.dto.WorkspaceConfigDto; //導入依賴的package包/類
private static WorkspaceConfigDto createConfigDto() {
final WorkspaceConfigImpl config =
WorkspaceConfigImpl.builder()
.setName("dev-workspace")
.setDefaultEnv("dev-env")
.setEnvironments(singletonMap("dev-env", new EnvironmentImpl(createEnvDto())))
.setCommands(singletonList(createCommandDto()))
.setProjects(singletonList(createProjectDto()))
.build();
return DtoConverter.asDto(config);
}