本文整理汇总了Java中org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto类的典型用法代码示例。如果您正苦于以下问题:Java ProjectConfigDto类的具体用法?Java ProjectConfigDto怎么用?Java ProjectConfigDto使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ProjectConfigDto类属于org.eclipse.che.api.workspace.shared.dto包,在下文中一共展示了ProjectConfigDto类的38个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testGradleProject
点赞 3
import org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto; //导入依赖的package包/类
@Test
public void testGradleProject() throws Exception {
UsersWorkspaceDto usersWorkspaceMock = mock(UsersWorkspaceDto.class);
when(httpJsonRequestFactory.fromLink(eq(DtoFactory.newDto(Link.class)
.withMethod("GET")
.withHref(API_ENDPOINT + "/workspace/" + workspace))))
.thenReturn(httpJsonRequest);
when(httpJsonRequestFactory.fromLink(eq(DtoFactory.newDto(Link.class)
.withMethod("PUT")
.withHref(API_ENDPOINT + "/workspace/" + workspace + "/project"))))
.thenReturn(httpJsonRequest);
when(httpJsonRequest.request()).thenReturn(httpJsonResponse);
when(httpJsonResponse.asDto(UsersWorkspaceDto.class)).thenReturn(usersWorkspaceMock);
final ProjectConfigDto projectConfig = DtoFactory.getInstance().createDto(ProjectConfigDto.class)
.withName("project")
.withPath("/myProject")
.withType(Constants.PROJECT_TYPE_ID);
when(usersWorkspaceMock.getProjects()).thenReturn(Collections.singletonList(projectConfig));
Project project = pm.createProject(workspace, "myProject",
DtoFactory.getInstance().createDto(ProjectConfigDto.class)
.withType(Constants.PROJECT_TYPE_ID),
null);
Assert.assertEquals(project.getConfig().getType(), Constants.PROJECT_TYPE_ID);
}
开发者ID:vzhukovskii,
项目名称:che-gradle-plugin,
代码行数:27,
代码来源:GradleProjectTypeIntegrationTest.java
示例2: getProjects
点赞 3
import org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto; //导入依赖的package包/类
@GET
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(
value = "Gets list of projects in root folder",
response = ProjectConfigDto.class,
responseContainer = "List"
)
@ApiResponses({
@ApiResponse(code = 200, message = "OK"),
@ApiResponse(code = 500, message = "Server error")
})
@GenerateLink(rel = LINK_REL_GET_PROJECTS)
public List<ProjectConfigDto> getProjects()
throws IOException, ServerException, ConflictException, ForbiddenException {
return getProjectServiceApi().getProjects();
}
开发者ID:eclipse,
项目名称:che,
代码行数:18,
代码来源:ProjectService.java
示例3: getProject
点赞 3
import org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto; //导入依赖的package包/类
@GET
@Path("/{path:.*}")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(
value = "Gets project by ID of workspace and project's path",
response = ProjectConfigDto.class
)
@ApiResponses({
@ApiResponse(code = 200, message = "OK"),
@ApiResponse(code = 404, message = "Project with specified path doesn't exist in workspace"),
@ApiResponse(code = 403, message = "Access to requested project is forbidden"),
@ApiResponse(code = 500, message = "Server error")
})
public ProjectConfigDto getProject(
@ApiParam(value = "Path to requested project", required = true) @PathParam("path")
String wsPath)
throws NotFoundException, ForbiddenException, ServerException, ConflictException {
return getProjectServiceApi().getProject(wsPath);
}
开发者ID:eclipse,
项目名称:che,
代码行数:21,
代码来源:ProjectService.java
示例4: createProject
点赞 3
import org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto; //导入依赖的package包/类
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Creates new project", response = ProjectConfigDto.class)
@ApiResponses({
@ApiResponse(code = 200, message = "OK"),
@ApiResponse(code = 403, message = "Operation is forbidden"),
@ApiResponse(code = 409, message = "Project with specified name already exist in workspace"),
@ApiResponse(code = 500, message = "Server error")
})
@GenerateLink(rel = LINK_REL_CREATE_PROJECT)
public ProjectConfigDto createProject(
@ApiParam(value = "Add to this project as module") @Context UriInfo uriInfo,
@Description("descriptor of project") ProjectConfigDto projectConfig)
throws ConflictException, ForbiddenException, ServerException, NotFoundException,
BadRequestException {
return getProjectServiceApi().createProject(uriInfo, projectConfig);
}
开发者ID:eclipse,
项目名称:che,
代码行数:20,
代码来源:ProjectService.java
示例5: updateProject
点赞 3
import org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto; //导入依赖的package包/类
@PUT
@Path("/{path:.*}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Updates existing project", response = ProjectConfigDto.class)
@ApiResponses({
@ApiResponse(code = 200, message = "OK"),
@ApiResponse(code = 404, message = "Project with specified path doesn't exist in workspace"),
@ApiResponse(code = 403, message = "Operation is forbidden"),
@ApiResponse(code = 409, message = "Update operation causes conflicts"),
@ApiResponse(code = 500, message = "Server error")
})
public ProjectConfigDto updateProject(
@ApiParam(value = "Path to updated project", required = true) @PathParam("path")
String wsPath,
ProjectConfigDto projectConfigDto)
throws NotFoundException, ConflictException, ForbiddenException, ServerException, IOException,
BadRequestException {
return getProjectServiceApi().updateProject(wsPath, projectConfigDto);
}
开发者ID:eclipse,
项目名称:che,
代码行数:22,
代码来源:ProjectService.java
示例6: createProject
点赞 3
import org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto; //导入依赖的package包/类
/** Create project with specified project configuration */
public ProjectConfigDto createProject(UriInfo uriInfo, ProjectConfigDto projectConfig)
throws ConflictException, ForbiddenException, ServerException, NotFoundException,
BadRequestException {
Map<String, String> options =
uriInfo
.getQueryParameters()
.entrySet()
.stream()
.collect(toMap(Entry::getKey, it -> it.getValue().get(0)));
RegisteredProject project = projectManager.create(projectConfig, options);
ProjectConfigDto asDto = asDto(project);
ProjectConfigDto injectedLinks = injectProjectLinks(asDto);
eventService.publish(new ProjectCreatedEvent(project.getPath()));
return injectedLinks;
}
开发者ID:eclipse,
项目名称:che,
代码行数:21,
代码来源:ProjectServiceApi.java
示例7: asDto
点赞 3
import org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto; //导入依赖的package包/类
/**
* The method tries to provide as much as possible information about project. If get error then
* save information about error with 'problems' field in ProjectConfigDto.
*
* @param project project from which we need get information
* @return an instance of {@link ProjectConfigDto}
*/
public static ProjectConfigDto asDto(RegisteredProject project) {
return newDto(ProjectConfigDto.class)
.withName(project.getName())
.withPath(project.getPath())
.withDescription(project.getDescription())
.withSource(asDto(project.getSource()))
.withAttributes(project.getAttributes())
.withType(project.getProjectType().getId())
.withMixins(new ArrayList<>(project.getMixinTypes().keySet()))
.withProblems(
project
.getProblems()
.stream()
.map(ProjectDtoConverter::asDto)
.collect(Collectors.toList()));
}
开发者ID:eclipse,
项目名称:che,
代码行数:24,
代码来源:ProjectDtoConverter.java
示例8: getInternally
点赞 3
import org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto; //导入依赖的package包/类
private GetResponseDto getInternally(GetRequestDto request)
throws ServerException, ConflictException, ForbiddenException, BadRequestException,
NotFoundException {
String wsPath = request.getWsPath();
RegisteredProject registeredProject =
projectManager
.get(wsPath)
.orElseThrow(() -> new NotFoundException("Can't find project: " + wsPath));
GetResponseDto response = newDto(GetResponseDto.class);
ProjectConfigDto projectConfigDto = asDto(registeredProject);
response.setConfig(projectConfigDto);
return response;
}
开发者ID:eclipse,
项目名称:che,
代码行数:17,
代码来源:ProjectJsonRpcServiceBackEnd.java
示例9: deleteInternally
点赞 3
import org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto; //导入依赖的package包/类
private DeleteResponseDto deleteInternally(DeleteRequestDto request)
throws ServerException, ConflictException, ForbiddenException, BadRequestException,
NotFoundException {
String wsPath = request.getWsPath();
RegisteredProject registeredProject =
projectManager
.delete(wsPath)
.orElseThrow(() -> new NotFoundException("Can't find project: " + wsPath));
ProjectConfigDto projectConfigDto = asDto(registeredProject);
DeleteResponseDto response = newDto(DeleteResponseDto.class);
response.setConfig(projectConfigDto);
return response;
}
开发者ID:eclipse,
项目名称:che,
代码行数:17,
代码来源:ProjectJsonRpcServiceBackEnd.java
示例10: setProjectType
点赞 3
import org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto; //导入依赖的package包/类
/** Set type for existing project on vfs */
public void setProjectType(String workspaceId, String template, String projectName)
throws Exception {
InputStream in = getClass().getResourceAsStream("/templates/project/" + template);
String json = IoUtil.readAndCloseQuietly(in);
ProjectConfigDto project = getInstance().createDtoFromJson(json, ProjectConfigDto.class);
project.setName(projectName);
String url = getWsAgentUrl(workspaceId);
requestFactory
.fromUrl(url + "/" + projectName)
.usePutMethod()
.setAuthorizationHeader(machineServiceClient.getMachineApiToken(workspaceId))
.setBody(project)
.request();
}
开发者ID:eclipse,
项目名称:che,
代码行数:18,
代码来源:TestProjectServiceClient.java
示例11: shouldThrowFactoryUrlExceptionIfProjectNameInvalid
点赞 3
import org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto; //导入依赖的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);
}
开发者ID:eclipse,
项目名称:che,
代码行数:19,
代码来源:FactoryBaseValidatorTest.java
示例12: shouldBeAbleToValidateValidProjectName
点赞 3
import org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto; //导入依赖的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);
}
开发者ID:eclipse,
项目名称:che,
代码行数:20,
代码来源:FactoryBaseValidatorTest.java
示例13: asDto
点赞 3
import org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto; //导入依赖的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());
}
开发者ID:eclipse,
项目名称:che,
代码行数:22,
代码来源:DtoConverter.java
示例14: addProject
点赞 3
import org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto; //导入依赖的package包/类
@POST
@Path("/{id}/project")
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@ApiOperation(
value = "Adds a new project to the workspace",
notes = "This operation can be performed only by the workspace owner"
)
@ApiResponses({
@ApiResponse(code = 200, message = "The project successfully added to the workspace"),
@ApiResponse(code = 400, message = "Missed required parameters, parameters are not valid"),
@ApiResponse(code = 403, message = "The user does not have access to add the project"),
@ApiResponse(code = 404, message = "The workspace not found"),
@ApiResponse(code = 409, message = "Any conflict error occurs"),
@ApiResponse(code = 500, message = "Internal server error occurred")
})
public WorkspaceDto addProject(
@ApiParam("The workspace id") @PathParam("id") String id,
@ApiParam(value = "The new project", required = true) ProjectConfigDto newProject)
throws ServerException, BadRequestException, NotFoundException, ConflictException,
ForbiddenException {
requiredNotNull(newProject, "New project config");
final WorkspaceImpl workspace = workspaceManager.getWorkspace(id);
workspace.getConfig().getProjects().add(new ProjectConfigImpl(newProject));
return asDtoWithLinksAndToken(doUpdate(id, workspace));
}
开发者ID:eclipse,
项目名称:che,
代码行数:27,
代码来源:WorkspaceService.java
示例15: shouldAddProject
点赞 3
import org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto; //导入依赖的package包/类
@Test
public void shouldAddProject() throws Exception {
final WorkspaceImpl workspace = createWorkspace(createConfigDto());
when(wsManager.getWorkspace(workspace.getId())).thenReturn(workspace);
when(wsManager.updateWorkspace(any(), any())).thenReturn(workspace);
final ProjectConfigDto projectDto = createProjectDto();
final int projectsSizeBefore = workspace.getConfig().getProjects().size();
final Response response =
given()
.auth()
.basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD)
.contentType("application/json")
.body(projectDto)
.when()
.post(SECURE_PATH + "/workspace/" + workspace.getId() + "/project");
assertEquals(response.getStatusCode(), 200);
assertEquals(
new WorkspaceImpl(unwrapDto(response, WorkspaceDto.class), TEST_ACCOUNT)
.getConfig()
.getProjects()
.size(),
projectsSizeBefore + 1);
verify(wsManager).updateWorkspace(any(), any());
}
开发者ID:eclipse,
项目名称:che,
代码行数:27,
代码来源:WorkspaceServiceTest.java
示例16: shouldUpdateProject
点赞 3
import org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto; //导入依赖的package包/类
@Test
public void shouldUpdateProject() throws Exception {
final WorkspaceImpl workspace = createWorkspace(createConfigDto());
when(wsManager.getWorkspace(workspace.getId())).thenReturn(workspace);
when(wsManager.updateWorkspace(any(), any())).thenReturn(workspace);
final ProjectConfigDto projectDto = createProjectDto();
final Response response =
given()
.auth()
.basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD)
.contentType("application/json")
.body(projectDto)
.when()
.put(
SECURE_PATH
+ "/workspace/"
+ workspace.getId()
+ "/project"
+ projectDto.getPath());
assertEquals(response.getStatusCode(), 200);
verify(wsManager).updateWorkspace(any(), any());
}
开发者ID:eclipse,
项目名称:che,
代码行数:25,
代码来源:WorkspaceServiceTest.java
示例17: updateProjectConfigs
点赞 3
import org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto; //导入依赖的package包/类
private void updateProjectConfigs(
String newProjectPath, ProjectTemplateDescriptor projectTemplate) {
final List<ProjectConfigDto> configDtoList = projectTemplate.getProjects();
if (newProjectPath.equals("/")) {
return;
}
final String templatePath = projectTemplate.getPath();
final List<NewProjectConfig> updatedConfigs = new ArrayList<>(configDtoList.size());
for (ProjectConfigDto configDto : configDtoList) {
final NewProjectConfig newConfig = new NewProjectConfigImpl(configDto);
final String projectPath = configDto.getPath();
if (projectPath.startsWith(templatePath)) {
final String path = projectPath.replaceFirst(templatePath, newProjectPath);
newConfig.setPath(path);
}
updatedConfigs.add(newConfig);
}
dataObject.setProjects(updatedConfigs);
}
开发者ID:eclipse,
项目名称:che,
代码行数:21,
代码来源:CategoriesPagePresenter.java
示例18: newResourceFrom
点赞 3
import org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto; //导入依赖的package包/类
private Resource newResourceFrom(final ItemReference reference) {
final Path path = Path.valueOf(reference.getPath());
switch (reference.getType()) {
case "file":
final Link link = reference.getLink(GET_CONTENT_REL);
String vcsStatusAttribute = reference.getAttributes().get("vcs.status");
return resourceFactory.newFileImpl(
path,
link.getHref(),
this,
vcsStatusAttribute == null
? VcsStatus.NOT_MODIFIED
: VcsStatus.from(vcsStatusAttribute));
case "folder":
return resourceFactory.newFolderImpl(path, this);
case "project":
ProjectConfigDto config = reference.getProjectConfig();
if (config != null) {
return resourceFactory.newProjectImpl(config, this);
} else {
return resourceFactory.newFolderImpl(path, this);
}
default:
throw new IllegalArgumentException("Failed to recognize resource type to create.");
}
}
开发者ID:eclipse,
项目名称:che,
代码行数:29,
代码来源:ResourceManager.java
示例19: shouldEncodeUrlAndUpdateProject
点赞 3
import org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto; //导入依赖的package包/类
@Test
public void shouldEncodeUrlAndUpdateProject() {
when(requestFactory.createRequest(
any(RequestBuilder.Method.class), anyString(), any(ProjectConfig.class), anyBoolean()))
.thenReturn(asyncRequest);
when(prjConfig1.getPath()).thenReturn(TEXT);
client.updateProject(prjConfig1);
verify(requestFactory).createRequest(eq(PUT), anyString(), eq(prjConfig1), eq(false));
verify(asyncRequest).header(CONTENT_TYPE, APPLICATION_JSON);
verify(asyncRequest).header(ACCEPT, APPLICATION_JSON);
verify(loaderFactory).newLoader("Updating project...");
verify(asyncRequest).loader(messageLoader);
verify(unmarshaller).newUnmarshaller(ProjectConfigDto.class);
verify(asyncRequest).send(unmarshallablePrjConf);
}
开发者ID:eclipse,
项目名称:che,
代码行数:18,
代码来源:ProjectServiceClientTest.java
示例20: mergeWithoutOneProjectWithoutSource
点赞 3
import org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto; //导入依赖的package包/类
/** Check source are added if there is only one project without source */
@Test
public void mergeWithoutOneProjectWithoutSource() {
// add existing project
ProjectConfigDto projectConfigDto = newDto(ProjectConfigDto.class);
factory.getWorkspace().setProjects(Collections.singletonList(projectConfigDto));
// no source storage
Assert.assertNull(projectConfigDto.getSource());
// merge
projectConfigDtoMerger.merge(factory, computedProjectConfig);
// project still 1
assertEquals(factory.getWorkspace().getProjects().size(), 1);
SourceStorageDto sourceStorageDto = factory.getWorkspace().getProjects().get(0).getSource();
assertEquals(sourceStorageDto.getLocation(), DUMMY_LOCATION);
}
开发者ID:eclipse,
项目名称:che,
代码行数:21,
代码来源:ProjectConfigDtoMergerTest.java
示例21: shouldShowLocalBranchesWheBranchesFilterIsSetToLocal
点赞 3
import org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto; //导入依赖的package包/类
@Test
public void shouldShowLocalBranchesWheBranchesFilterIsSetToLocal() throws Exception {
// given
final List<Branch> branches = Collections.singletonList(selectedBranch);
when(service.branchList(anyObject(), eq(BranchListMode.LIST_LOCAL)))
.thenReturn(branchListPromise);
when(branchListPromise.then(any(Operation.class))).thenReturn(branchListPromise);
when(branchListPromise.catchError(any(Operation.class))).thenReturn(branchListPromise);
when(view.getFilterValue()).thenReturn("local");
// when
presenter.showBranches(project);
verify(branchListPromise).then(branchListCaptor.capture());
branchListCaptor.getValue().apply(branches);
// then
verify(view).showDialogIfClosed();
verify(view).setBranches(eq(branches));
verify(console, never()).printError(anyString());
verify(notificationManager, never()).notify(anyString(), any(ProjectConfigDto.class));
verify(constant, never()).branchesListFailed();
}
开发者ID:eclipse,
项目名称:che,
代码行数:23,
代码来源:BranchPresenterTest.java
示例22: shouldShowRemoteBranchesWheBranchesFilterIsSetToRemote
点赞 3
import org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto; //导入依赖的package包/类
@Test
public void shouldShowRemoteBranchesWheBranchesFilterIsSetToRemote() throws Exception {
// given
final List<Branch> branches = Collections.singletonList(selectedBranch);
when(service.branchList(anyObject(), eq(BranchListMode.LIST_LOCAL)))
.thenReturn(branchListPromise);
when(branchListPromise.then(any(Operation.class))).thenReturn(branchListPromise);
when(branchListPromise.catchError(any(Operation.class))).thenReturn(branchListPromise);
when(view.getFilterValue()).thenReturn("remote");
// when
presenter.showBranches(project);
verify(branchListPromise).then(branchListCaptor.capture());
branchListCaptor.getValue().apply(branches);
// then
verify(view).showDialogIfClosed();
verify(view).setBranches(eq(branches));
verify(console, never()).printError(anyString());
verify(notificationManager, never()).notify(anyString(), any(ProjectConfigDto.class));
verify(constant, never()).branchesListFailed();
}
开发者ID:eclipse,
项目名称:che,
代码行数:23,
代码来源:BranchPresenterTest.java
示例23: setup
点赞 2
import org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto; //导入依赖的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"));
}
开发者ID:codenvy,
项目名称:codenvy,
代码行数:39,
代码来源:BitbucketServerWebhookServiceTest.java
示例24: updateProjectInFactory
点赞 2
import org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto; //导入依赖的package包/类
/**
* Update project matching given predicate in given factory
*
* @param factory the factory to search for projects
* @param headRepositoryUrl the URL of the repository that a project into the factory is
* configured with
* @param headBranch the name of the branch that a project into the factory is configured with
* @param baseRepositoryUrl the repository URL to set as source location for matching project in
* factory
* @param headCommitId the commitId to set as 'commitId' parameter for matching project in factory
* @return the project that matches the predicate given in argument
* @throws ServerException
*/
protected FactoryDto updateProjectInFactory(
final FactoryDto factory,
final String headRepositoryUrl,
final String headBranch,
final String baseRepositoryUrl,
final String headCommitId,
final CloneUrlMatcher matcher)
throws ServerException {
// Get projects in factory
final List<ProjectConfigDto> factoryProjects = factory.getWorkspace().getProjects();
factoryProjects
.stream()
.filter(project -> matcher.isCloneUrlMatching(project, headRepositoryUrl, headBranch))
.forEach(
project -> {
// Update repository and commitId
final SourceStorageDto source = project.getSource();
final Map<String, String> projectParams = source.getParameters();
source.setLocation(baseRepositoryUrl);
projectParams.put("commitId", headCommitId);
// Clean branch parameter if exist
projectParams.remove("branch");
source.setParameters(projectParams);
});
return factory;
}
开发者ID:codenvy,
项目名称:codenvy,
代码行数:44,
代码来源:BaseWebhookService.java
示例25: createFactory
点赞 2
import org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto; //导入依赖的package包/类
/**
* Create factory object based on provided parameters
*
* @param factoryParameters map containing factory data parameters provided through URL
* @throws BadRequestException when data are invalid
*/
@Override
public FactoryDto createFactory(@NotNull final Map<String, String> factoryParameters)
throws BadRequestException {
// no need to check null value of url parameter as accept() method has performed the check
final GitlabUrl gitlabUrl = gitlabUrlParser.parse(factoryParameters.get("url"));
// create factory from the following location if location exists, else create default factory
FactoryDto factory = urlFactoryBuilder.createFactory(gitlabUrl.factoryJsonFileLocation());
// add workspace configuration if not defined
if (factory.getWorkspace() == null) {
factory.setWorkspace(
urlFactoryBuilder.buildWorkspaceConfig(
gitlabUrl.getRepository(), gitlabUrl.getUsername(), gitlabUrl.dockerFileLocation()));
}
// Compute project configuration
ProjectConfigDto projectConfigDto =
newDto(ProjectConfigDto.class)
.withSource(gitlabSourceStorageBuilder.build(gitlabUrl))
.withName(gitlabUrl.getRepository())
.withType("blank")
.withPath("/".concat(gitlabUrl.getRepository()));
// apply merging operation from existing and computed settings
return projectConfigDtoMerger.merge(factory, projectConfigDto);
}
开发者ID:codenvy,
项目名称:codenvy,
代码行数:35,
代码来源:GitlabFactoryParametersResolver.java
示例26: shouldReturnGitHubSimpleFactory
点赞 2
import org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto; //导入依赖的package包/类
/** Check that with a simple valid URL github url it works */
@Test
public void shouldReturnGitHubSimpleFactory() throws Exception {
String gitlabUrl = "https://gitlab.com/eclipse/che";
String gitlabUrlRepository = gitlabUrl + ".git";
FactoryDto computedFactory = newDto(FactoryDto.class).withV("4.0");
when(urlFactoryBuilder.createFactory(anyString())).thenReturn(computedFactory);
gitlabFactoryParametersResolver.createFactory(singletonMap(URL_PARAMETER_NAME, gitlabUrl));
// check we called the builder with the following codenvy json file
verify(urlFactoryBuilder).createFactory(createFactoryParamsArgumentCaptor.capture());
assertEquals(
createFactoryParamsArgumentCaptor.getValue(),
"https://gitlab.com/eclipse/che/raw/master/.factory.json");
// check we provide dockerfile and correct env
verify(urlFactoryBuilder)
.buildWorkspaceConfig(
eq("che"),
eq("eclipse"),
eq("https://gitlab.com/eclipse/che/raw/master/.factory.dockerfile"));
// check project config built
verify(projectConfigDtoMerger)
.merge(any(FactoryDto.class), projectConfigDtoArgumentCaptor.capture());
ProjectConfigDto projectConfigDto = projectConfigDtoArgumentCaptor.getValue();
SourceStorageDto sourceStorageDto = projectConfigDto.getSource();
assertNotNull(sourceStorageDto);
assertEquals(sourceStorageDto.getType(), "git");
assertEquals(sourceStorageDto.getLocation(), gitlabUrlRepository);
Map<String, String> sourceParameters = sourceStorageDto.getParameters();
assertEquals(sourceParameters.size(), 1);
assertEquals(sourceParameters.get("branch"), "master");
}
开发者ID:codenvy,
项目名称:codenvy,
代码行数:40,
代码来源:GitlabFactoryParametersResolverTest.java
示例27: shouldReturnGitHubBranchFactory
点赞 2
import org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto; //导入依赖的package包/类
/** Check that we've expected branch when url contains a branch name */
@Test
public void shouldReturnGitHubBranchFactory() throws Exception {
String gitlabUrl = "https://gitlab.com/eclipse/che/tree/4.2.x";
String gitlabCloneUrl = "https://gitlab.com/eclipse/che";
String gitlabBranch = "4.2.x";
String gitlabCloneUrlRespository = gitlabCloneUrl + ".git";
FactoryDto computedFactory = newDto(FactoryDto.class).withV("4.0");
when(urlFactoryBuilder.createFactory(anyString())).thenReturn(computedFactory);
gitlabFactoryParametersResolver.createFactory(singletonMap(URL_PARAMETER_NAME, gitlabUrl));
// check we called the builder with the following codenvy json file
verify(urlFactoryBuilder).createFactory(createFactoryParamsArgumentCaptor.capture());
assertEquals(
createFactoryParamsArgumentCaptor.getValue(),
"https://gitlab.com/eclipse/che/raw/4.2.x/.factory.json");
// check we provide dockerfile and correct env
verify(urlFactoryBuilder)
.buildWorkspaceConfig(
eq("che"),
eq("eclipse"),
eq("https://gitlab.com/eclipse/che/raw/4.2.x/.factory.dockerfile"));
// check project config built
verify(projectConfigDtoMerger)
.merge(any(FactoryDto.class), projectConfigDtoArgumentCaptor.capture());
ProjectConfigDto projectConfigDto = projectConfigDtoArgumentCaptor.getValue();
SourceStorageDto sourceStorageDto = projectConfigDto.getSource();
assertNotNull(sourceStorageDto);
assertEquals(sourceStorageDto.getType(), "git");
assertEquals(sourceStorageDto.getLocation(), gitlabCloneUrlRespository);
Map<String, String> sourceParameters = sourceStorageDto.getParameters();
assertEquals(sourceParameters.size(), 1);
assertEquals(sourceParameters.get("branch"), gitlabBranch);
}
开发者ID:codenvy,
项目名称:codenvy,
代码行数:41,
代码来源:GitlabFactoryParametersResolverTest.java
示例28: createBatchProjects
点赞 2
import org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto; //导入依赖的package包/类
@POST
@Path("/batch")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(
value = "Creates batch of projects according to their configurations",
notes =
"A project will be created by importing when project configuration contains source object. "
+ "For creating a project by generator options should be specified.",
response = ProjectConfigDto.class
)
@ApiResponses({
@ApiResponse(code = 200, message = "OK"),
@ApiResponse(code = 400, message = "Path for new project should be defined"),
@ApiResponse(code = 403, message = "Operation is forbidden"),
@ApiResponse(code = 409, message = "Project with specified name already exist in workspace"),
@ApiResponse(code = 500, message = "Server error")
})
@GenerateLink(rel = LINK_REL_CREATE_BATCH_PROJECTS)
public List<ProjectConfigDto> createBatchProjects(
@Description("list of descriptors for projects") List<NewProjectConfigDto> projectConfigs,
@ApiParam(value = "Force rewrite existing project", allowableValues = "true,false")
@QueryParam("force")
boolean rewrite,
@QueryParam("clientId") String clientId)
throws ConflictException, ForbiddenException, ServerException, NotFoundException, IOException,
UnauthorizedException, BadRequestException {
return getProjectServiceApi().createBatchProjects(projectConfigs, rewrite, clientId);
}
开发者ID:eclipse,
项目名称:che,
代码行数:31,
代码来源:ProjectService.java
示例29: uploadProjectFromZip
点赞 2
import org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto; //导入依赖的package包/类
@POST
@Path("/upload/zipproject/{path:.*}")
@Consumes({MediaType.MULTIPART_FORM_DATA})
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(
value = "Upload zip project",
notes = "Upload project from local zip",
response = ProjectConfigDto.class
)
@ApiResponses({
@ApiResponse(code = 200, message = ""),
@ApiResponse(code = 401, message = "User not authorized to call this operation"),
@ApiResponse(code = 403, message = "Forbidden operation"),
@ApiResponse(code = 409, message = "Resource already exists"),
@ApiResponse(code = 500, message = "Unsupported source type")
})
public List<SourceEstimation> uploadProjectFromZip(
@ApiParam(value = "Path in the project", required = true) @PathParam("path") String wsPath,
@ApiParam(value = "Force rewrite existing project", allowableValues = "true,false")
@QueryParam("force")
boolean force,
Iterator<FileItem> formData)
throws ServerException, ConflictException, ForbiddenException, NotFoundException,
BadRequestException {
return getProjectServiceApi().uploadProjectFromZip(wsPath, force, formData);
}
开发者ID:eclipse,
项目名称:che,
代码行数:28,
代码来源:ProjectService.java
示例30: getProjects
点赞 2
import org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto; //导入依赖的package包/类
/** Get list of projects */
public List<ProjectConfigDto> getProjects()
throws IOException, ServerException, ConflictException, ForbiddenException {
return projectManager
.getAll()
.stream()
.map(ProjectDtoConverter::asDto)
.map(this::injectProjectLinks)
.collect(Collectors.toList());
}
开发者ID:eclipse,
项目名称:che,
代码行数:12,
代码来源:ProjectServiceApi.java
示例31: getProject
点赞 2
import org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto; //导入依赖的package包/类
/** Get project specified by the following workspace path */
public ProjectConfigDto getProject(String wsPath)
throws NotFoundException, ForbiddenException, ServerException, ConflictException {
wsPath = absolutize(wsPath);
return projectManager
.get(wsPath)
.map(ProjectDtoConverter::asDto)
.map(this::injectProjectLinks)
.orElseThrow(() -> new NotFoundException("Project is not found"));
}
开发者ID:eclipse,
项目名称:che,
代码行数:12,
代码来源:ProjectServiceApi.java
示例32: createBatchProjects
点赞 2
import org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto; //导入依赖的package包/类
/** Create projects with specified configurations for a client with specified identifier */
public List<ProjectConfigDto> createBatchProjects(
List<NewProjectConfigDto> projectConfigs, boolean rewrite, String clientId)
throws ConflictException, ForbiddenException, ServerException, NotFoundException, IOException,
UnauthorizedException, BadRequestException {
projectManager.doImport(
new HashSet<>(projectConfigs), rewrite, jsonRpcImportConsumer(clientId));
Set<RegisteredProject> registeredProjects = new HashSet<>(projectConfigs.size());
for (NewProjectConfigDto projectConfig : projectConfigs) {
registeredProjects.add(projectManager.update(projectConfig));
}
Set<ProjectConfigDto> result =
registeredProjects
.stream()
.map(ProjectDtoConverter::asDto)
.map(this::injectProjectLinks)
.collect(toSet());
registeredProjects
.stream()
.map(RegisteredProject::getPath)
.map(ProjectCreatedEvent::new)
.forEach(eventService::publish);
return new ArrayList<>(result);
}
开发者ID:eclipse,
项目名称:che,
代码行数:31,
代码来源:ProjectServiceApi.java
示例33: updateProject
点赞 2
import org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto; //导入依赖的package包/类
/** Update project specified by workspace path with new configuration */
public ProjectConfigDto updateProject(String wsPath, ProjectConfigDto projectConfigDto)
throws NotFoundException, ConflictException, ForbiddenException, ServerException, IOException,
BadRequestException {
if (wsPath != null) {
projectConfigDto.setPath(absolutize(wsPath));
}
RegisteredProject updated = projectManager.update(projectConfigDto);
return asDto(updated);
}
开发者ID:eclipse,
项目名称:che,
代码行数:12,
代码来源:ProjectServiceApi.java
示例34: createInternally
点赞 2
import org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto; //导入依赖的package包/类
private CreateResponseDto createInternally(CreateRequestDto request)
throws ServerException, ConflictException, ForbiddenException, BadRequestException,
NotFoundException {
String wsPath = request.getWsPath();
ProjectConfigDto projectConfig = request.getConfig();
Map<String, String> options = request.getOptions();
ProjectConfig registeredProject = projectManager.create(projectConfig, options);
ProjectConfigDto projectConfigDto = asDto(registeredProject);
CreateResponseDto response = newDto(CreateResponseDto.class);
response.setConfig(projectConfigDto);
return response;
}
开发者ID:eclipse,
项目名称:che,
代码行数:15,
代码来源:ProjectJsonRpcServiceBackEnd.java
示例35: updateInternally
点赞 2
import org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto; //导入依赖的package包/类
private UpdateResponseDto updateInternally(UpdateRequestDto request)
throws ServerException, ConflictException, ForbiddenException, BadRequestException,
NotFoundException {
String wsPath = request.getWsPath();
ProjectConfigDto config = request.getConfig();
Map<String, String> options = request.getOptions();
RegisteredProject registeredProject = projectManager.update(config);
ProjectConfigDto projectConfigDto = asDto(registeredProject);
UpdateResponseDto response = newDto(UpdateResponseDto.class);
response.setConfig(projectConfigDto);
return response;
}
开发者ID:eclipse,
项目名称:che,
代码行数:15,
代码来源:ProjectJsonRpcServiceBackEnd.java
示例36: doImportInternally
点赞 2
import org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto; //导入依赖的package包/类
private ImportResponseDto doImportInternally(String endpointId, ImportRequestDto request)
throws ServerException, ConflictException, ForbiddenException, BadRequestException,
NotFoundException, UnauthorizedException {
String wsPath = request.getWsPath();
SourceStorageDto sourceStorage = request.getSourceStorage();
BiConsumer<String, String> consumer =
(projectName, message) -> {
ImportProgressRecordDto progressRecord =
newDto(ImportProgressRecordDto.class).withProjectName(projectName).withLine(message);
requestTransmitter
.newRequest()
.endpointId(endpointId)
.methodName(EVENT_IMPORT_OUTPUT_PROGRESS)
.paramsAsDto(progressRecord)
.sendAndSkipResult();
};
RegisteredProject registeredProject =
projectManager.doImport(wsPath, sourceStorage, false, consumer);
ProjectConfigDto projectConfigDto = asDto(registeredProject);
ImportResponseDto response = newDto(ImportResponseDto.class);
response.setConfig(projectConfigDto);
return response;
}
开发者ID:eclipse,
项目名称:che,
代码行数:28,
代码来源:ProjectJsonRpcServiceBackEnd.java
示例37: verifyProjectLinks
点赞 2
import org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto; //导入依赖的package包/类
@Test
public void verifyProjectLinks() throws Exception {
ProjectConfigDto projectConfigDto = DtoFactory.newDto(ProjectConfigDto.class);
projectConfigDto.withPath(PROJECT_PATH);
ProjectConfigDto result =
projectServiceLinksInjector.injectProjectLinks(projectConfigDto, serviceContext);
final List<Link> links = result.getLinks();
assertEquals(4, links.size());
final Link updateProjectLink = links.get(0);
assertNotNull(updateProjectLink);
assertEquals("localhost:8080/project/project_path", updateProjectLink.getHref());
assertEquals(HttpMethod.PUT, updateProjectLink.getMethod());
assertEquals(LINK_REL_UPDATE_PROJECT, updateProjectLink.getRel());
assertEquals(APPLICATION_JSON, updateProjectLink.getConsumes());
assertEquals(APPLICATION_JSON, updateProjectLink.getProduces());
final Link childrenProjectLink = links.get(1);
assertNotNull(childrenProjectLink);
assertEquals("localhost:8080/project/children/project_path", childrenProjectLink.getHref());
assertEquals(HttpMethod.GET, childrenProjectLink.getMethod());
assertEquals(LINK_REL_CHILDREN, childrenProjectLink.getRel());
assertEquals(APPLICATION_JSON, childrenProjectLink.getProduces());
final Link treeProjectLink = links.get(2);
assertNotNull(treeProjectLink);
assertEquals("localhost:8080/project/tree/project_path", treeProjectLink.getHref());
assertEquals(HttpMethod.GET, treeProjectLink.getMethod());
assertEquals(LINK_REL_TREE, treeProjectLink.getRel());
assertEquals(APPLICATION_JSON, treeProjectLink.getProduces());
final Link deleteProjectLink = links.get(3);
assertNotNull(deleteProjectLink);
assertEquals("localhost:8080/project/project_path", deleteProjectLink.getHref());
assertEquals(HttpMethod.DELETE, deleteProjectLink.getMethod());
assertEquals(LINK_REL_DELETE, deleteProjectLink.getRel());
}
开发者ID:eclipse,
项目名称:che,
代码行数:40,
代码来源:ProjectServiceLinksInjectorTest.java
示例38: getFirstProject
点赞 2
import org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto; //导入依赖的package包/类
public ProjectConfigDto getFirstProject(String workspaceId) throws Exception {
String apiUrl = getWsAgentUrl(workspaceId);
return requestFactory
.fromUrl(apiUrl)
.setAuthorizationHeader(machineServiceClient.getMachineApiToken(workspaceId))
.request()
.asList(ProjectConfigDto.class)
.get(0);
}
开发者ID:eclipse,
项目名称:che,
代码行数:10,
代码来源:TestProjectServiceClient.java