Package com.github.variety

Examples of com.github.variety.VarietyAnalysis


    /**
     * Verify default parameters of variety.
     */
    @Test
    public void verifyDefaultResultsStdout() throws Exception {
        final VarietyAnalysis analysis = variety.runAnalysis();

        final Map<String, String> params = getParamsMap(analysis.getStdOut());

        Assert.assertEquals("99", params.get(Variety.PARAM_MAXDEPTH));
        Assert.assertEquals("{ }", params.get(Variety.PARAM_QUERY));
        Assert.assertEquals("{ \"_id\" : -1 }", params.get(Variety.PARAM_SORT));
        Assert.assertEquals("5", params.get(Variety.PARAM_LIMIT)); // TODO: why is limit configured to current count, not set as 'unlimited'? It could save one count query
View Full Code Here


    /**
     * Verify, that all passed parameters are correctly recognized and printed out in stdout of variety.
     */
    @Test
    public void verifyRestrictedResultsStdout() throws Exception {
        final VarietyAnalysis analysis = variety
                .withQuery("{name:'Harry'}")
                .withSort("{name:1}")
                .withMaxDepth(5)
                .withLimit(2)
                .runAnalysis();

        final Map<String, String> params = getParamsMap(analysis.getStdOut());

        Assert.assertEquals("5", params.get(Variety.PARAM_MAXDEPTH));
        Assert.assertEquals("{ \"name\" : \"Harry\" }", params.get(Variety.PARAM_QUERY));
        Assert.assertEquals("{ \"name\" : 1 }", params.get(Variety.PARAM_SORT));
        Assert.assertEquals("2", params.get(Variety.PARAM_LIMIT));
View Full Code Here

        }
    }

    @Test
    public void testDefaultOutputFormatParam() throws Exception {
        final VarietyAnalysis analysis = variety.runAnalysis(); // format option not provided
        final Map<String, String> params = getParamsMap(analysis.getStdOut());
        Assert.assertEquals("ascii", params.get(Variety.PARAM_OUTPUT_FORMAT));
    }
View Full Code Here

        Assert.assertEquals("ascii", params.get(Variety.PARAM_OUTPUT_FORMAT));
    }

    @Test
    public void testAsciiOutputFormatParam() throws Exception {
        final VarietyAnalysis analysis = variety.withFormat(Variety.FORMAT_ASCII).runAnalysis();
        final Map<String, String> params = getParamsMap(analysis.getStdOut());
        Assert.assertEquals("ascii", params.get(Variety.PARAM_OUTPUT_FORMAT));
    }
View Full Code Here

        Assert.assertEquals("ascii", params.get(Variety.PARAM_OUTPUT_FORMAT));
    }

    @Test
    public void testJsonOutputFormatParam() throws Exception {
        final VarietyAnalysis analysis = variety.withFormat(Variety.FORMAT_JSON).runAnalysis();
        final Map<String, String> params = getParamsMap(analysis.getStdOut());
        Assert.assertEquals("json", params.get(Variety.PARAM_OUTPUT_FORMAT));
    }
View Full Code Here

        variety.getSourceCollection().drop();
    }

    @Test
    public void testUnlimitedAnalysis() throws Exception {
        final VarietyAnalysis analysis = variety.runAnalysis();
        Assert.assertEquals("Variety results have not correct count of entries", 8, analysis.getResultsCollection().count()); // 8 results, including '_id' and 'name'

        analysis.verifyResult("_id", 1, EXPECTED_PERCENTS, "ObjectId");
        analysis.verifyResult("name", 1, EXPECTED_PERCENTS, "String");

        analysis.verifyResult("someNestedObject", 1, EXPECTED_PERCENTS, "Object");
        analysis.verifyResult("someNestedObject.a", 1, EXPECTED_PERCENTS, "Object");
        analysis.verifyResult("someNestedObject.a.b", 1, EXPECTED_PERCENTS, "Object");
        analysis.verifyResult("someNestedObject.a.b.c", 1, EXPECTED_PERCENTS, "Object");
        analysis.verifyResult("someNestedObject.a.b.c.d", 1, EXPECTED_PERCENTS, "Object");
        analysis.verifyResult("someNestedObject.a.b.c.d.e", 1, EXPECTED_PERCENTS, "Number");
    }
View Full Code Here

        analysis.verifyResult("someNestedObject.a.b.c.d.e", 1, EXPECTED_PERCENTS, "Number");
    }

    @Test
    public void testLimitedDepthAnalysis() throws Exception {
        final VarietyAnalysis analysis = variety.withMaxDepth(3).runAnalysis();

        Assert.assertEquals("Variety results have not correct count of entries", 5, analysis.getResultsCollection().count()); // 5 results, including '_id' and 'name'

        analysis.verifyResult("_id", 1, EXPECTED_PERCENTS, "ObjectId");
        analysis.verifyResult("name", 1, EXPECTED_PERCENTS, "String");

        analysis.verifyResult("someNestedObject", 1, EXPECTED_PERCENTS, "Object");
        analysis.verifyResult("someNestedObject.a", 1, EXPECTED_PERCENTS, "Object");
        analysis.verifyResult("someNestedObject.a.b", 1, EXPECTED_PERCENTS, "Object");
    }
View Full Code Here

        variety.getSourceCollection().drop();
    }

    @Test
    public void verifyLimitedResults() throws Exception {
        final VarietyAnalysis analysis = variety.withLimit(1).runAnalysis();
        analysis.verifyResult("_id", 5, 100, "ObjectId");
        analysis.verifyResult("name", 5, 100, "String");

        analysis.verifyResult("someBinData", 1, 20, "BinData-old");
    }
View Full Code Here

    }

    @Test
    public void testSortedAnalysis() throws Exception {
        // Sort without limit or other query should not modify results itself. Analysis is done on the same data, only in another order.
        final VarietyAnalysis analysis = variety.withSort("{name:-1}").runAnalysis();
        analysis.verifyResult("_id", 5, 100, "ObjectId");
        analysis.verifyResult("name", 5, 100, "String");
        analysis.verifyResult("bio", 3, 60, "String");
        analysis.verifyResult("pets", 2, 40, "String", "Array");
        analysis.verifyResult("someBinData", 1, 20, "BinData-old");
        analysis.verifyResult("someWeirdLegacyKey", 1, 20, "String");

    }
View Full Code Here

    @Test
    public void testSortedAnalysisWithLimit() throws Exception {
        // when sorting default SampleData by name desc, first entry becomes Tom. He is only with key 'someWeirdLegacyKey'
        // Together with applying limit 1, Tom is the only result in analysis. That gives us chance to assume keys and verify
        // that ordering is correct.
        final VarietyAnalysis analysis = variety.withSort("{name:-1}").withLimit(1).runAnalysis();

        Assert.assertEquals(5, analysis.getResultsCollection().count());

        analysis.verifyResult("_id", 5, 100, "ObjectId");
        analysis.verifyResult("name", 5, 100, "String");
        analysis.verifyResult("bio", 3, 60, "String");
        analysis.verifyResult("pets", 2, 40, "Array");
        analysis.verifyResult("someWeirdLegacyKey", 1, 20, "String");

    }
View Full Code Here

TOP

Related Classes of com.github.variety.VarietyAnalysis

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.