Package org.adoptopenjdk.lambda.tutorial.exercise4

Examples of org.adoptopenjdk.lambda.tutorial.exercise4.Document$Page


     *
     */
    @Test
    public void getListOfDocumentTitlesUsingReferenceOfInstanceMethodBelongingToAClass() {
        Document expenses = new Document("My Expenses",
                Arrays.asList(new Page("LJC Open Conference ticket: £25"), new Page("Beer stipend: £100")));
        Document toDoList = new Document("My ToDo List",
                Arrays.asList(new Page("Build a todo app"), new Page("Pick up dry cleaning")));
        Document certificates = new Document("My Certificates",
                Arrays.asList(new Page("Oracle Certified Professional"), new Page("Swimming 10m")));

        assertThat(Documents.titlesOf(expenses, toDoList, certificates),
                contains("My Expenses", "My ToDo List", "My Certificates"));
        assertThat(Documents.class, usesMethodReferences("getTitle"));

View Full Code Here


     * @see Documents#characterCount(Page)
     */
    @Test
    public void getListOfPageCharacterCountsFromDocumentUsingReferenceOfStaticMethodBelongingToAClass() {
        Document diary = new Document("My Diary", Arrays.asList(
                new Page("Today I went shopping"),
                new Page("Today I did maths"),
                new Page("Today I wrote in my diary")));

        assertThat(Documents.pageCharacterCounts(diary), contains(21, 17, 25));
        assertThat(Documents.class, usesMethodReferences("characterCount"));
    }
View Full Code Here

     *
     */
    @Test
    public void printContentsOfDocumentUsingReferenceOfInstanceMethodBeloningToAnObject() {
        Document diary = new Document("My Diary", Arrays.asList(
                new Page("Today I went shopping"),
                new Page("Today I did maths"),
                new Page("Today I wrote in my diary")));

        assertThat(Documents.print(diary, new PagePrinter("----")),
                isString(format("My Diary%n" +
                                "----%n" +
                                "Today I went shopping%n" +
View Full Code Here

     * instance.
     */
    @Test
    public void transformPagesToHaveFooterUsingReferenceOfInstanceMethodBelonginToThisObject() {
        Document diary = new Document("My Diary", Arrays.asList(
                new Page("Today I went shopping"),
                new Page("Today I did maths"),
                new Page("Today I wrote in my diary")));

        Document diaryWithFooters = diary.copyWithFooter();

        assertThat(diaryWithFooters.getPages(), everyItem(pageEndingWith("Document: My Diary")));
        assertThat(Document.class, allOf(usesMethodReferences("appendFooter"), usesMethodReferences("copyWithPages")));
View Full Code Here

     * @see Page
     */
    @Test
    public void createNewDocumentWithTranslatedPagesUsingReferenceOfConstructorMethod() {
        Document diary = new Document("My Diary", Arrays.asList(
                new Page("Today I went shopping"),
                new Page("Today I did maths"),
                new Page("Today I wrote in my diary")));

        Document translated = Documents.translate(diary, Languages.REVERSISH);

        assertThat(translated.getPages(),
                contains(pageContaining("gnippohs tnew I yadoT"),
View Full Code Here

    public static Document translate(Document document, Translator translator) {
        return document.getPages().stream()
                .map(page -> page.getContent())
                .map(content -> translator.translate(content))
                .map(translated -> new Page(translated))
                .collect(collectingAndThen(toList(),
                                           pages -> new Document(translator.translate(document.getTitle()), pages)));
    }
View Full Code Here

        Document diary = new Document("My Diary", Arrays.asList(
                new Page("Today I went shopping"),
                new Page("Today I did maths"),
                new Page("Today I wrote in my diary")));

        assertThat(Documents.print(diary, new PagePrinter("----")),
                isString(format("My Diary%n" +
                                "----%n" +
                                "Today I went shopping%n" +
                                "----%n" +
                                "Today I did maths%n" +
View Full Code Here

    @Test
    public void testDocument() throws Exception {
        if (!shouldRunTest("Document")) {
            return;
        }
        Document x = new Document();
        x.setValue("content-x");
        x.setID("Hello There");
        Document yOrig = new Document();
        yOrig.setID("Cheerio");
        yOrig.setValue("content-y");

        Holder<Document> y = new Holder<Document>(yOrig);
        Holder<Document> z = new Holder<Document>();

        Document ret;
        if (testDocLiteral) {
            ret = docClient.testDocument(x, y, z);
        } else if (testXMLBinding) {
            ret = xmlClient.testDocument(x, y, z);
        } else {
            ret = rpcClient.testDocument(x, y, z);
        }
        if (!perfTestOnly) {
            equals("testDocument(): Incorrect value for inout param", x, y.value);
            equals("testDocument(): Incorrect value for out param", yOrig, z.value);
            equals("testDocument(): Incorrect return value", x, ret);
        }

        x = new Document();
        yOrig = new Document();
        x.setValue("content-x");
        yOrig.setValue("content-y");
        x.setID(null);
        yOrig.setID(null);
        y = new Holder<Document>(yOrig);
        z = new Holder<Document>();

        if (testDocLiteral) {
            ret = docClient.testDocument(x, y, z);
        } else if (testXMLBinding) {
            ret = xmlClient.testDocument(x, y, z);
        } else {
            ret = rpcClient.testDocument(x, y, z);
        }
        if (!perfTestOnly) {
            equals("testDocument(): Incorrect value for inout param", x, y.value);
            equals("testDocument(): Incorrect value for out param", yOrig, z.value);
            equals("testDocument(): Incorrect return value", x, ret);
            assertNull(y.value.getID());
            assertNull(ret.getID());
        }
    }
View Full Code Here

        assertEquals(msg, x.getValue(), y.getValue());
        assertEquals(msg, x.getID(), y.getID());
    }
    @Test
    public void testDocument() throws Exception {
        Document x = new Document();
        x.setValue("content-x");
        x.setID("Hello There");
        Document yOrig = new Document();
        yOrig.setID("Cheerio");
        yOrig.setValue("content-y");

        Holder<Document> y = new Holder<Document>(yOrig);
        Holder<Document> z = new Holder<Document>();

        Document ret;
        if (testDocLiteral) {
            ret = docClient.testDocument(x, y, z);
        } else if (testXMLBinding) {
            ret = xmlClient.testDocument(x, y, z);
        } else {
            ret = rpcClient.testDocument(x, y, z);
        }
        if (!perfTestOnly) {
            equals("testDocument(): Incorrect value for inout param", x, y.value);
            equals("testDocument(): Incorrect value for out param", yOrig, z.value);
            equals("testDocument(): Incorrect return value", x, ret);
        }

        x = new Document();
        yOrig = new Document();
        x.setValue("content-x");
        yOrig.setValue("content-y");
        x.setID(null);
        yOrig.setID(null);
        y = new Holder<Document>(yOrig);
        z = new Holder<Document>();

        if (testDocLiteral) {
            ret = docClient.testDocument(x, y, z);
        } else if (testXMLBinding) {
            ret = xmlClient.testDocument(x, y, z);
        } else {
            ret = rpcClient.testDocument(x, y, z);
        }
        if (!perfTestOnly) {
            equals("testDocument(): Incorrect value for inout param", x, y.value);
            equals("testDocument(): Incorrect value for out param", yOrig, z.value);
            equals("testDocument(): Incorrect return value", x, ret);
            assertNull(y.value.getID());
            assertNull(ret.getID());
        }
    }
View Full Code Here

        assertEquals(msg, x.getValue(), y.getValue());
        assertEquals(msg, x.getID(), y.getID());
    }
   
    public void testDocument() throws Exception {
        Document x = new Document();
        x.setValue("content-x");
        x.setID("Hello There");
        Document yOrig = new Document();
        yOrig.setID("Cheerio");
        yOrig.setValue("content-y");

        Holder<Document> y = new Holder<Document>(yOrig);
        Holder<Document> z = new Holder<Document>();

        Document ret;
        if (testDocLiteral) {
            ret = docClient.testDocument(x, y, z);
        } else if (testXMLBinding) {
            ret = xmlClient.testDocument(x, y, z);
        } else {
            ret = rpcClient.testDocument(x, y, z);
        }
        if (!perfTestOnly) {
            equals("testDocument(): Incorrect value for inout param", x, y.value);
            equals("testDocument(): Incorrect value for out param", yOrig, z.value);
            equals("testDocument(): Incorrect return value", x, ret);
        }

        x = new Document();
        yOrig = new Document();
        x.setValue("content-x");
        yOrig.setValue("content-y");
        x.setID(null);
        yOrig.setID(null);
        y = new Holder<Document>(yOrig);
        z = new Holder<Document>();

        if (testDocLiteral) {
            ret = docClient.testDocument(x, y, z);
        } else if (testXMLBinding) {
            ret = xmlClient.testDocument(x, y, z);
        } else {
            ret = rpcClient.testDocument(x, y, z);
        }
        if (!perfTestOnly) {
            equals("testDocument(): Incorrect value for inout param", x, y.value);
            equals("testDocument(): Incorrect value for out param", yOrig, z.value);
            equals("testDocument(): Incorrect return value", x, ret);
            assertNull(y.value.getID());
            assertNull(ret.getID());
        }
    }
View Full Code Here

TOP

Related Classes of org.adoptopenjdk.lambda.tutorial.exercise4.Document$Page

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.