Package com.github.variety.test

Source Code of com.github.variety.test.QueryLimitedAnalysisTest

package com.github.variety.test;

import com.github.variety.Variety;
import com.github.variety.VarietyAnalysis;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

public class QueryLimitedAnalysisTest {
    private Variety variety;

    @Before
    public void setUp() throws Exception {
        variety = new Variety("test", "users");
        variety.getSourceCollection().insert(SampleData.getDocuments());
    }

    @After
    public void tearDown() throws Exception {
        variety.getVarietyResultsDatabase().dropDatabase();
        variety.getSourceCollection().drop();
    }

    @Test
    public void testQueryLimitedAnalysis() throws Exception {
        final VarietyAnalysis analysis = variety.withQuery("{someBinData:{$exists: true}}").runAnalysis();
        Assert.assertEquals(3, analysis.getResultsCollection().count());

        // we analyzed only the keys of objects defined by query. But total counts and percents are computed from the complete collection
        analysis.verifyResult("_id", 5, 100, "ObjectId");
        analysis.verifyResult("name", 5, 100, "String");
        analysis.verifyResult("someBinData", 1, 20, "BinData-old");

    }
}
TOP

Related Classes of com.github.variety.test.QueryLimitedAnalysisTest

TOP
Copyright © 2018 www.massapi.com. 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.