Package org.zanata.model

Examples of org.zanata.model.HDocument


    }

    @Test
    public void mergeNoTextFlows() {
        List<TextFlow> from = new ArrayList<TextFlow>();
        HDocument to = new HDocument();
        boolean changed =
                resourceUtils.transferFromTextFlows(from, to,
                        new HashSet<String>(), 1);

        assertThat(changed, is(false));
View Full Code Here


        List<TextFlow> from = new ArrayList<TextFlow>();

        TextFlow tf1 = new TextFlow("id", LocaleId.EN, "text1");
        from.add(tf1);

        HDocument to = new HDocument();

        boolean changed =
                resourceUtils.transferFromTextFlows(from, to,
                        new HashSet<String>(), 1);
View Full Code Here

    }

    @Test
    public void mergeChangedTextFlow() {
        // set up HDocument with a text flow
        HDocument to = new HDocument();
        int originalTFRevision = 1;
        to.setRevision(originalTFRevision);
        HTextFlow originalTF = new HTextFlow(to, "id", "original text");
        originalTF.setRevision(originalTFRevision);

        // target locales that will have new, fuzzy and approved targets
        HLocale newLoc, fuzzyLoc, apprLoc;
        newLoc = new HLocale(LocaleId.DE);
        fuzzyLoc = new HLocale(LocaleId.FR);
        apprLoc = new HLocale(LocaleId.ES);
        // Target Locale ids
        Long newLocId = 1L, fuzzyLocId = 2L, apprLocId = 3L;

        HTextFlowTarget newTarg, fuzzyTarg, apprTarg;
        newTarg = new HTextFlowTarget(originalTF, newLoc);
        fuzzyTarg = new HTextFlowTarget(originalTF, fuzzyLoc);
        apprTarg = new HTextFlowTarget(originalTF, apprLoc);

        int newTargVersionBefore = 1;
        int fuzzyTargVersionBefore = 1;
        int apprTargVersionBefore = 1;

        newTarg.setVersionNum(newTargVersionBefore);
        fuzzyTarg.setVersionNum(fuzzyTargVersionBefore);
        apprTarg.setVersionNum(apprTargVersionBefore);

        newTarg.setState(ContentState.New);
        fuzzyTarg.setState(ContentState.NeedReview);
        apprTarg.setState(ContentState.Approved);

        originalTF.getTargets().put(newLocId, newTarg);
        originalTF.getTargets().put(fuzzyLocId, fuzzyTarg);
        originalTF.getTargets().put(apprLocId, apprTarg);

        to.getAllTextFlows().put("id", originalTF);

        // set up a textflow with the same id and different content
        TextFlow changedTF =
                new TextFlow(originalTF.getResId(), LocaleId.EN, "changed text");
        List<TextFlow> from = new ArrayList<TextFlow>();
        from.add(changedTF);

        int newTFRevision = 2;

        boolean changed =
                resourceUtils.transferFromTextFlows(from, to,
                        new HashSet<String>(), newTFRevision);

        Map<Long, HTextFlowTarget> targets =
                to.getAllTextFlows().get("id").getTargets();
        newTarg = targets.get(newLocId);
        assertThat(newTarg.getState(), is(ContentState.New));
        assertThat(newTarg.getVersionNum(), is(newTargVersionBefore));
        assertThat(newTarg.getTextFlowRevision(), is(originalTFRevision));
View Full Code Here

                        hLocale);

        admin = makePerson("admin123");
        translator = makePerson("translator123");

        HDocument hDocument =
                EntityMakerBuilder
                        .builder()
                        .addFieldOrPropertyMaker(HProject.class,
                                "sourceViewURL",
                                FixedValueMaker.EMPTY_STRING_MAKER)
                        .reuseEntity(hLocale).build()
                        .makeAndPersist(getEm(), HDocument.class);
        documentId = new DocumentId(hDocument.getId(), hDocument.getDocId());

        HTextFlowBuilder baseBuilder =
                new HTextFlowBuilder().withDocument(hDocument)
                        .withTargetLocale(hLocale);
        HTextFlowBuilder adminModifiedToday =
View Full Code Here

    @BeforeMethod
    public void beforeMethod() {
        resolver = TransMemoryMergeStatusResolver.newInstance();

        HDocument document =
                new HDocument(docId, "message.po", "/po", ContentType.PO,
                        new HLocale(new LocaleId("en")));
        HProjectIteration projectIteration = new HProjectIteration();
        HProject project = new HProject();
        project.setName(projectName);
        projectIteration.setProject(project);
        document.setProjectIteration(projectIteration);
        textFlow = new HTextFlow(document, resId, "this is a string.");

        tmDetail = tmDetail(projectName, docId, resId, msgContext);

    }
View Full Code Here

    @Test
    public void testExecute() throws Exception {
        WorkspaceId workspaceId = TestFixture.workspaceId();
        GetDocumentList action = new GetDocumentList();
        action.setWorkspaceId(workspaceId);
        HDocument hDocument = hDocument(1);
        List<HDocument> documentList = Arrays.asList(hDocument);

        when(documentDAO.getAllByProjectIteration("project", "master"))
                .thenReturn(documentList);
View Full Code Here

    @Test
    public void testExecuteWithFilter() throws Exception {
        WorkspaceId workspaceId = TestFixture.workspaceId();
        GetDocumentList action = new GetDocumentList();
        action.setWorkspaceId(workspaceId);
        HDocument hDocument = hDocument(1);
        List<HDocument> documentList = Arrays.asList(hDocument);
        when(documentDAO.getAllByProjectIteration("project", "master"))
                .thenReturn(documentList);

        GetDocumentListResult result = handler.execute(action, null);
View Full Code Here

    private HDocument hDocument(long id) {
        HProjectIteration iteration = new HProjectIteration();
        iteration.setProjectType(ProjectType.Podir);

        HDocument hDocument =
                new HDocument("/dot/a.po", ContentType.PO, new HLocale(
                        LocaleId.EN_US));
        hDocument.setProjectIteration(iteration);
        TestFixture.setId(id, hDocument);
        return hDocument;
    }
View Full Code Here

                document);
        when(
                documentService.saveDocument(eq(conf.projectSlug),
                        eq(conf.versionSlug), Matchers.<Resource> any(),
                        Matchers.anySetOf(String.class), Matchers.anyBoolean()))
                .thenReturn(new HDocument());
    }
View Full Code Here

        assertThat(responseEntity().isExpectingMore(), is(false));
        assertThat(responseEntity().getErrorMessage(), is(nullValue()));
    }

    public void canUploadExistingDocument() throws IOException {
        conf = defaultUpload().existingDocument(new HDocument()).build();
        mockRequiredServices();
        when(documentUploadUtil.isNewDocument(conf.id)).thenReturn(false);

        response = sourceUpload.tryUploadSourceFile(conf.id, conf.uploadForm);
        assertResponseHasStatus(OK);
View Full Code Here

TOP

Related Classes of org.zanata.model.HDocument

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.