Package org.apache.cayenne

Examples of org.apache.cayenne.TranslationCase


        q.addOrdering("artistName", SortOrder.ASCENDING);

        TstQueryAssembler qa = new TstQueryAssembler(getNode(), q);

        try {
            TranslationCase tstCase = new TranslationCase(
                    "Artist",
                    null,
                    "ta.ARTIST_NAME");

            StringBuilder out = new StringBuilder();
            new OrderingTranslator(qa).appendPart(out);

            assertTrue(out.length() > 0);
            tstCase.assertTranslatedWell(out.toString());
        }
        finally {
            qa.dispose();
        }
    }
View Full Code Here


        q.addOrdering("artistName", SortOrder.DESCENDING);

        TstQueryAssembler qa = new TstQueryAssembler(getNode(), q);

        try {
            TranslationCase tstCase = new TranslationCase(
                    "Artist",
                    null,
                    "ta.ARTIST_NAME DESC");

            StringBuilder out = new StringBuilder();
            new OrderingTranslator(qa).appendPart(out);

            assertTrue(out.length() > 0);
            tstCase.assertTranslatedWell(out.toString());
        }
        finally {
            qa.dispose();
        }
    }
View Full Code Here

        q.addOrdering("artistName", SortOrder.ASCENDING_INSENSITIVE);

        TstQueryAssembler qa = new TstQueryAssembler(getNode(), q);

        try {
            TranslationCase tstCase = new TranslationCase(
                    "Artist",
                    null,
                    "UPPER(ta.ARTIST_NAME)");

            StringBuilder out = new StringBuilder();
            new OrderingTranslator(qa).appendPart(out);

            assertTrue(out.length() > 0);
            String orderBySql = out.toString();
            assertTrue(orderBySql.contains("UPPER("));
            tstCase.assertTranslatedWell(orderBySql);
        }
        finally {
            qa.dispose();
        }
    }
View Full Code Here

        q.addOrdering("paintingArray.estimatedPrice", SortOrder.ASCENDING);

        TstQueryAssembler qa = new TstQueryAssembler(getNode(), q);

        try {
            TranslationCase tstCase = new TranslationCase(
                    "Artist",
                    null,
                    "UPPER(ta.ARTIST_NAME) DESC, ta.ESTIMATED_PRICE");

            StringBuilder out = new StringBuilder();
            new OrderingTranslator(qa).appendPart(out);

            assertTrue(out.length() > 0);
            String orderBySql = out.toString();

            // Check there is an UPPER modifier
            int indexOfUpper = orderBySql.indexOf("UPPER(");
            assertTrue(indexOfUpper != -1);

            // and ensure there is only ONE upper modifier
            assertTrue(orderBySql.indexOf("UPPER(", indexOfUpper + 1) == -1);
            tstCase.assertTranslatedWell(orderBySql);
        }
        finally {
            qa.dispose();
        }
    }
View Full Code Here

        q.addOrdering("paintingArray.estimatedPrice", SortOrder.ASCENDING_INSENSITIVE);

        TstQueryAssembler qa = new TstQueryAssembler(getNode(), q);

        try {
            TranslationCase tstCase = new TranslationCase(
                    "Artist",
                    null,
                    "UPPER(ta.ARTIST_NAME), UPPER(ta.ESTIMATED_PRICE)");

            StringBuilder out = new StringBuilder();
            new OrderingTranslator(qa).appendPart(out);

            assertTrue(out.length() > 0);
            String orderBySql = out.toString();

            // Check there is at least one UPPER modifier
            int indexOfUpper = orderBySql.indexOf("UPPER(");
            assertTrue(indexOfUpper != -1);

            // and ensure there is another after it
            assertTrue(orderBySql.indexOf("UPPER(", indexOfUpper + 1) != -1);

            tstCase.assertTranslatedWell(orderBySql);
        }
        finally {
            qa.dispose();
        }
    }
View Full Code Here

        q.addOrdering("paintingArray.estimatedPrice", SortOrder.ASCENDING);

        TstQueryAssembler qa = new TstQueryAssembler(getNode(), q);

        try {
            TranslationCase tstCase = new TranslationCase(
                    "Artist",
                    null,
                    "ta.ARTIST_NAME DESC, ta.ESTIMATED_PRICE");

            StringBuilder out = new StringBuilder();
            new OrderingTranslator(qa).appendPart(out);

            assertTrue(out.length() > 0);
            String orderBySql = out.toString();
            tstCase.assertTranslatedWell(orderBySql);
        }
        finally {
            qa.dispose();
        }
    }
View Full Code Here

        q.addOrdering("artistName", Ordering.ASC);

        TstQueryAssembler qa = new TstQueryAssembler(getNode(), q);

        try {
            TranslationCase tstCase = new TranslationCase(
                    "Artist",
                    null,
                    "ta.ARTIST_NAME");

            StringBuilder out = new StringBuilder();
            new OrderingTranslator(qa).appendPart(out);

            assertTrue(out.length() > 0);
            tstCase.assertTranslatedWell(out.toString());
        }
        finally {
            qa.dispose();
        }
    }
View Full Code Here

        q.addOrdering("artistName", Ordering.DESC);

        TstQueryAssembler qa = new TstQueryAssembler(getNode(), q);

        try {
            TranslationCase tstCase = new TranslationCase(
                    "Artist",
                    null,
                    "ta.ARTIST_NAME DESC");

            StringBuilder out = new StringBuilder();
            new OrderingTranslator(qa).appendPart(out);

            assertTrue(out.length() > 0);
            tstCase.assertTranslatedWell(out.toString());
        }
        finally {
            qa.dispose();
        }
    }
View Full Code Here

        q.addOrdering("artistName", Ordering.ASC, true);

        TstQueryAssembler qa = new TstQueryAssembler(getNode(), q);

        try {
            TranslationCase tstCase = new TranslationCase(
                    "Artist",
                    null,
                    "UPPER(ta.ARTIST_NAME)");

            StringBuilder out = new StringBuilder();
            new OrderingTranslator(qa).appendPart(out);

            assertTrue(out.length() > 0);
            String orderBySql = out.toString();
            assertTrue(orderBySql.contains("UPPER("));
            tstCase.assertTranslatedWell(orderBySql);
        }
        finally {
            qa.dispose();
        }
    }
View Full Code Here

        q.addOrdering("paintingArray.estimatedPrice", Ordering.ASC);

        TstQueryAssembler qa = new TstQueryAssembler(getNode(), q);

        try {
            TranslationCase tstCase = new TranslationCase(
                    "Artist",
                    null,
                    "UPPER(ta.ARTIST_NAME) DESC, ta.ESTIMATED_PRICE");

            StringBuilder out = new StringBuilder();
            new OrderingTranslator(qa).appendPart(out);

            assertTrue(out.length() > 0);
            String orderBySql = out.toString();

            // Check there is an UPPER modifier
            int indexOfUpper = orderBySql.indexOf("UPPER(");
            assertTrue(indexOfUpper != -1);

            // and ensure there is only ONE upper modifier
            assertTrue(orderBySql.indexOf("UPPER(", indexOfUpper + 1) == -1);
            tstCase.assertTranslatedWell(orderBySql);
        }
        finally {
            qa.dispose();
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.cayenne.TranslationCase

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.