Package org.zanata.rest.dto

Examples of org.zanata.rest.dto.Project


            if (response != null) {
                return response.build();
            }

            HProject hProject = projectDAO.getBySlug(projectSlug);
            Project project =
                    org.zanata.rest.service.ProjectService.toResource(hProject,
                            MediaType.APPLICATION_JSON_TYPE);
            return Response.ok(project).tag(etag).build();
        } catch (NoSuchEntityException e) {
            return Response.status(Response.Status.NOT_FOUND).build();
View Full Code Here


                if (hProject.getDefaultProjectType() == null) {
                    projectType = "";
                } else {
                    projectType = hProject.getDefaultProjectType().toString();
                }
                Project project =
                        new Project(hProject.getSlug(), hProject.getName(),
                                projectType);
                project.setStatus(hProject.getStatus());
                project.getLinks(true).add(
                        new Link(URI.create("p/" + hProject.getSlug()), "self",
                                MediaTypes.createFormatSpecificType(
                                        MediaTypes.APPLICATION_ZANATA_PROJECT,
                                        accept)));
                projectRefs.add(project);
View Full Code Here

    public void createProjectAndVersion(String projectSlug,
            String iterationSlug, String projectType) {
        IProjectResource projectResource =
                zanataProxyFactory.getProject(projectSlug);
        Project project = new Project();
        project.setDefaultType(projectType);
        project.setId(projectSlug);
        project.setName(projectSlug);

        ClientResponse response = projectResource.put(project);
        checkStatusAndReleaseConnection(response);

        ProjectIteration iteration = new ProjectIteration();
View Full Code Here

            if (response != null) {
                return response.build();
            }

            HProject hProject = projectDAO.getBySlug(getProjectSlug());
            Project project = toResource(hProject, accept);
            return Response.ok(project).tag(etag).build();
        } catch (NoSuchEntityException e) {
            return Response.status(Status.NOT_FOUND).build();
        }
    }
View Full Code Here

        to.setSourceViewURL(from.getSourceViewURL());
        to.setSourceCheckoutURL(from.getSourceCheckoutURL());
    }

    public static Project toResource(HProject hProject, MediaType mediaType) {
        Project project = new Project();
        transfer(hProject, project);
        for (HProjectIteration pIt : hProject.getProjectIterations()) {
            ProjectIteration iteration = new ProjectIteration();
            ProjectIterationService.transfer(pIt, iteration);

            iteration
                    .getLinks(true)
                    .add(new Link(
                            URI.create("iterations/i/" + pIt.getSlug()),
                            "self",
                            MediaTypes
                                    .createFormatSpecificType(
                                            MediaTypes.APPLICATION_ZANATA_PROJECT_ITERATION,
                                            mediaType)));
            project.getIterations(true).add(iteration);
        }
        return project;
    }
View Full Code Here

        Credentials mockCredentials = mock(Credentials.class);
        when(mockIdentity.getCredentials()).thenReturn(mockCredentials);
        when(mockCredentials.getUsername()).thenReturn("admin");

        Project project =
                new Project(PROJECT_SLUG, PROJECT_NAME,
                        ProjectType.Gettext.toString(), PROJECT_DESC);

        IProjectResource projectService =
                getClientRequestFactory().createProxy(IProjectResource.class,
                        createBaseURI(RESOURCE_PATH).resolve(PROJECT_SLUG));

        Response response = projectService.put(project);

        assertThat(response.getStatus(), is(Status.CREATED.getStatusCode()));

        String location = (String) response.getMetadata().getFirst("Location");

        assertThat(location, endsWith("/projects/p/" + PROJECT_SLUG));

        projectService =
                getClientRequestFactory().createProxy(IProjectResource.class,
                        createBaseURI(RESOURCE_PATH).resolve(PROJECT_SLUG));

        ClientResponse<Project> response1 = projectService.get();
        assertThat(response1.getStatus(), is(Status.OK.getStatusCode()));

        Project projectRes = response1.getEntity();

        assertThat(projectRes, notNullValue());
        assertThat(projectRes.getName(), is(PROJECT_NAME));
        assertThat(projectRes.getId(), is(PROJECT_SLUG));
        assertThat(projectRes.getDescription(), is(PROJECT_DESC));
        verify(mockIdentity).checkPermission(any(HProject.class), eq("insert"));
    }
View Full Code Here

                getClientRequestFactory().createProxy(
                        IProjectResource.class,
                        createBaseURI(RESOURCE_PATH).resolve(
                                PROJECT_SLUG_INVALID));

        Project project =
                new Project(PROJECT_SLUG_INVALID, PROJECT_NAME,
                        ProjectType.Gettext.toString(), PROJECT_DESC);
        Response response = projectService.put(project);

        assertThat(response.getStatus(), is(Status.NOT_FOUND.getStatusCode()));
    }
View Full Code Here

    @Test
    public void createProjectWithInvalidData() {
        IProjectResource projectService =
                getClientRequestFactory().createProxy(IProjectResource.class,
                        createBaseURI(RESOURCE_PATH).resolve(PROJECT_SLUG));
        Project project1 =
                new Project(PROJECT_SLUG, PROJECT_NAME_INVALID,
                        ProjectType.Gettext.toString(), PROJECT_DESC);
        Response response1 = projectService.put(project1);

        assertThat(response1.getStatus(),
                is(Status.BAD_REQUEST.getStatusCode()));
View Full Code Here

                is(Status.BAD_REQUEST.getStatusCode()));
    }

    @Test
    public void updateProjectWithInvalidData() {
        Project project =
                new Project(
                        "sample-project",
                        "ProjectUpdateProjectUpdateProjectUpdateProjectUpdateProjectUpdateProjectUpdateProjectUpdate",
                        ProjectType.Gettext.toString(),
                        "Project Name exceeds 80");
View Full Code Here

        assertThat(response.getStatus(), is(Status.BAD_REQUEST.getStatusCode()));
    }

    @Test
    public void updateProject() {
        Project project =
                new Project("sample-project", "My Project Update",
                        ProjectType.Gettext.toString(), "Update project");

        IProjectResource projectService =
                getClientRequestFactory().createProxy(IProjectResource.class,
                        createBaseURI(RESOURCE_PATH).resolve("sample-project"));

        Response response = projectService.put(project);

        assertThat(response.getStatus(), is(Status.OK.getStatusCode()));

        ClientResponse<Project> projectResponse = projectService.get();

        assertThat(projectResponse.getStatus(), is(Status.OK.getStatusCode()));

        Project projectRes = projectResponse.getEntity();

        assertThat(projectRes.getName(), is("My Project Update"));
        assertThat(projectRes.getDescription(), is("Update project"));
        verify(mockIdentity, atLeastOnce()).checkPermission(
                any(HProject.class), eq("update"));
    }
View Full Code Here

TOP

Related Classes of org.zanata.rest.dto.Project

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.