Example usage for org.springframework.data.mongodb.core.query Criteria getCriteriaObject

List of usage examples for org.springframework.data.mongodb.core.query Criteria getCriteriaObject

Introduction

In this page you can find the example usage for org.springframework.data.mongodb.core.query Criteria getCriteriaObject.

Prototype

public Document getCriteriaObject() 

Source Link

Usage

From source file:com.github.rutledgepaulv.testsupport.CriteriaSerializer.java

@Override
public String apply(Criteria criteria) {
    return applyInternal(criteria.getCriteriaObject()).toString();
}

From source file:com.ewcms.common.query.mongo.CriteriaWapper.java

private BasicBSONList createCriteriaList(Criteria[] criteria) {
    BasicBSONList bsonList = new BasicBSONList();
    for (Criteria c : criteria) {
        bsonList.add(c.getCriteriaObject());
    }/*w  w  w.  j  av  a 2 s. c o m*/
    return bsonList;
}

From source file:com.trenako.repositories.mongo.MongoSearchCriteriaTests.java

@Test
public void shouldBuildEraCriteriaCommand() {
    SearchCriteria sc = new SearchCriteria.Builder().era(eraIII()).build();

    Criteria criteria = MongoSearchCriteria.buildCriteria(sc);

    assertEquals("{ \"era\" : \"iii\"}", criteria.getCriteriaObject().toString());
}

From source file:com.trenako.repositories.mongo.MongoSearchCriteriaTests.java

@Test
public void shouldBuildScaleCriteriaCommand() {
    SearchCriteria sc = new SearchCriteria.Builder().scale(scaleH0()).build();

    Criteria criteria = MongoSearchCriteria.buildCriteria(sc);

    assertEquals("{ \"scale.slug\" : \"h0\"}", criteria.getCriteriaObject().toString());
}

From source file:com.trenako.repositories.mongo.MongoSearchCriteriaTests.java

@Test
public void shouldBuildPowerMethodCriteriaCommand() {
    SearchCriteria sc = new SearchCriteria.Builder().powerMethod(ac()).build();

    Criteria criteria = MongoSearchCriteria.buildCriteria(sc);

    assertEquals("{ \"powerMethod\" : \"ac\"}", criteria.getCriteriaObject().toString());
}

From source file:com.trenako.repositories.mongo.MongoSearchCriteriaTests.java

@Test
public void shouldBuildBrandCriteriaCommand() {
    SearchCriteria sc = new SearchCriteria.Builder().brand(acme()).build();

    Criteria criteria = MongoSearchCriteria.buildCriteria(sc);

    assertEquals("{ \"brand.slug\" : \"acme\"}", criteria.getCriteriaObject().toString());
}

From source file:com.trenako.repositories.mongo.MongoSearchCriteriaTests.java

@Test
public void shouldBuildRailwayCriteriaCommand() {
    SearchCriteria sc = new SearchCriteria.Builder().railway(db()).build();

    Criteria criteria = MongoSearchCriteria.buildCriteria(sc);

    assertEquals("{ \"railway.slug\" : \"db\"}", criteria.getCriteriaObject().toString());
}

From source file:com.trenako.repositories.mongo.MongoSearchCriteriaTests.java

@Test
public void shouldBuildCategoryCriteriaCommand() {
    SearchCriteria sc = new SearchCriteria.Builder().category(electricLocomotives()).build();

    Criteria criteria = MongoSearchCriteria.buildCriteria(sc);

    assertEquals("{ \"category\" : \"electric-locomotives\"}", criteria.getCriteriaObject().toString());
}

From source file:com.trenako.repositories.mongo.MongoSearchCriteriaTests.java

@Test
public void shouldBuildCatCriteriaCommand() {
    SearchCriteria sc = new SearchCriteria.Builder().cat(dcElectricLocomotives()).build();

    Criteria criteria = MongoSearchCriteria.buildCriteria(sc);

    assertEquals("{ \"category\" : \"electric-locomotives\" , \"powerMethod\" : \"dc\"}",
            criteria.getCriteriaObject().toString());
}

From source file:com.trenako.repositories.mongo.MongoSearchCriteriaTests.java

@Test
public void shouldBuildCriteriaWithOnlyOneCategoryAndPowerMethod() {
    SearchCriteria sc = new SearchCriteria.Builder().cat(dcElectricLocomotives()).category(steamLocomotives())
            .powerMethod(ac()).build();//from w w  w .j  a  v a 2 s . co  m

    Criteria criteria = MongoSearchCriteria.buildCriteria(sc);

    assertEquals("{ \"category\" : \"electric-locomotives\" , \"powerMethod\" : \"dc\"}",
            criteria.getCriteriaObject().toString());
}