Package org.objectquery.generic.domain

Examples of org.objectquery.generic.domain.Person


  @Test(expected = ObjectQueryException.class)
  public void testWrongValueInsert() {
    MockQueryBuilder builder = new MockQueryBuilder();
    GenericInsertQuery<Person> insert = new GenericInsertQuery<Person>(builder, Person.class);
    Person toUp = insert.target();
    insert.set(toUp.getName(), toUp.getDad().getName());
    builder.build();
  }
View Full Code Here


  @Test(expected = ObjectQueryException.class)
  public void testWrongValueObjInsert() {
    MockQueryBuilder builder = new MockQueryBuilder();
    GenericInsertQuery<Person> insert = new GenericInsertQuery<Person>(builder, Person.class);
    Person toUp = insert.target();
    insert.set(toUp.getDad(), toUp.getMom());
    builder.build();
  }
View Full Code Here

  @Test(expected = ObjectQueryException.class)
  public void testWrongRootInsert() {
    MockQueryBuilder builder = new MockQueryBuilder();
    GenericInsertQuery<Person> insert = new GenericInsertQuery<Person>(builder, Person.class);
    Person toUp = insert.target();
    insert.set(toUp, new Person());
    builder.build();
  }
View Full Code Here

  @Test
  public void addProjectionTest() {
    MockQueryBuilder builder = new MockQueryBuilder();
    SelectQuery<Person> query = new GenericSelectQuery<Person, Object>(builder, Person.class);
    Person toSearch = query.target();
    query.prj(toSearch.getMom().getName());
    query.prj(toSearch.getMom().getName(), ProjectionType.COUNT);
    query.prj(toSearch.getMom().getName(), ProjectionType.AVG);
    query.prj(toSearch.getMom().getName(), ProjectionType.MAX);
    query.prj(toSearch.getMom().getName(), ProjectionType.MIN);
    query.prj(toSearch.getMom().getName(), ProjectionType.SUM);
    builder.build();

    assertEquals(6, builder.getProjectionsString().size());
    assertEquals("mom.name", builder.getProjectionsString().get(0));
    assertEquals("mom.name COUNT", builder.getProjectionsString().get(1));
View Full Code Here

  @Test
  public void testSetSimpleUpdate() {
    MockQueryBuilder builder = new MockQueryBuilder();
    GenericUpdateQuery<Person> update = new GenericUpdateQuery<Person>(builder, Person.class);
    Person toUp = update.target();
    update.set(toUp.getName(), "new-name");
    builder.build();
    assertEquals(1, builder.getSetsString().size());
    assertEquals("name new-name", builder.getSetsString().get(0));
  }
View Full Code Here

  @Test
  public void testSetNestedUpdate() {
    MockQueryBuilder builder = new MockQueryBuilder();
    GenericUpdateQuery<Person> update = new GenericUpdateQuery<Person>(builder, Person.class);
    Person toUp = update.target();
    update.set(toUp.getDad().getName(), "new-name");
    builder.build();
    assertEquals(1, builder.getSetsString().size());
    assertEquals("dad.name new-name", builder.getSetsString().get(0));
  }
View Full Code Here

  @Test
  public void testSetCrossFieldUpdate() {
    MockQueryBuilder builder = new MockQueryBuilder();
    GenericUpdateQuery<Person> update = new GenericUpdateQuery<Person>(builder, Person.class);
    Person toUp = update.target();
    update.set(toUp.getName(), toUp.getDad().getName());
    update.set(toUp.getDad(), toUp.getMom());
    builder.build();
    assertEquals(2, builder.getSetsString().size());
    assertEquals("name dad.name", builder.getSetsString().get(0));
    assertEquals("dad mom", builder.getSetsString().get(1));
  }
View Full Code Here

  @Test(expected = ObjectQueryException.class)
  public void testSetWrongRootTarget() {
    MockQueryBuilder builder = new MockQueryBuilder();
    GenericUpdateQuery<Person> update = new GenericUpdateQuery<Person>(builder, Person.class);
    Person toUp = update.target();
    update.set(toUp, new Person());
  }
View Full Code Here

  @Test
  public void testPathValueQueryBuild() {
    MockQueryBuilder builder = new MockQueryBuilder();
    GenericSelectQuery<Person, Object> query = new GenericSelectQuery<Person, Object>(builder, Person.class);
    Person toSearch = query.target();
    query.eq(toSearch.getHome().getAddress(), toSearch.getDog().getHome().getAddress());
    query.eq(toSearch.getDad().getHome(), toSearch.getDog().getHome());
    query.eq(toSearch.getMom().getName(), toSearch.getDog().getOwner().getName());
    query.order(toSearch.getName());
    builder.build();
    assertEquals("There is more conditions than expected", builder.getConditionsString().size(), 3);
    assertEquals("There is more orders than expected", builder.getOrdersString().size(), 1);

    assertEquals("Not present expected condition", "home.address EQUALS dog.home.address", builder.getConditionsString().get(0));
View Full Code Here

  @Test
  public void testConditionsTypes() {
    MockQueryBuilder builder = new MockQueryBuilder();
    SelectQuery<Person> query = new GenericSelectQuery<Person, Object>(builder, Person.class);
    Person toSearch = query.target();
    query.eq(toSearch.getMom().getName(), toSearch.getDad().getName());
    query.contains(toSearch.getFriends(), toSearch.getDad());
    query.in(toSearch.getMom(), toSearch.getDad().getFriends());
    query.like(toSearch.getMom().getName(), toSearch.getDad().getName());
    query.gt(toSearch.getMom().getName(), toSearch.getDad().getName());
    query.gtEq(toSearch.getMom().getName(), toSearch.getDad().getName());
    query.lt(toSearch.getMom().getName(), toSearch.getDad().getName());
    query.ltEq(toSearch.getMom().getName(), toSearch.getDad().getName());
    query.notEq(toSearch.getMom().getName(), toSearch.getDad().getName());
    query.notIn(toSearch.getMom(), toSearch.getDad().getFriends());
    query.notContains(toSearch.getMom().getFriends(), toSearch.getDad());
    query.notLike(toSearch.getMom().getName(), toSearch.getDad().getName());
    query.likeNc(toSearch.getMom().getName(), toSearch.getDad().getName());
    query.notLikeNc(toSearch.getMom().getName(), toSearch.getDad().getName());
    query.between(query.box(toSearch.getHome().getPrice()), query.box(toSearch.getMom().getHome().getPrice()),
        query.box(toSearch.getDad().getHome().getPrice()));
    builder.build();

    assertEquals(15, builder.getConditionsString().size());
    assertEquals("mom.name EQUALS dad.name", builder.getConditionsString().get(0));
    assertEquals("friends CONTAINS dad", builder.getConditionsString().get(1));
View Full Code Here

TOP

Related Classes of org.objectquery.generic.domain.Person

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.