Package org.adoptopenjdk.lambda.tutorial.exercise4

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


     * @see Document#getTitle()
     *
     */
    @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#pageCharacterCounts(Document)
     * @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));
View Full Code Here

     * @see PagePrinter#printPage(Page)
     *
     */
    @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("----")),
View Full Code Here

     * Change {@link Document#copyWithFooter()} to use method references to invoke instance methods on <code>this</code>
     * 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 Translator.Languages
     * @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"),
                        pageContaining("shtam did I yadoT"),
                        pageContaining("yraid ym ni etorw I yadoT")));
        assertThat(Documents.class, usesMethodReferences("new"));
    }
View Full Code Here

     *
     */
    @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

TOP

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

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.