congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
DatastoreQueryTest
Code IndexAdd Tabnine to your IDE (free)

How to use
DatastoreQueryTest
in
io.yawp.repository.query

Best Java code snippets using io.yawp.repository.query.DatastoreQueryTest (Showing top 20 results out of 315)

origin: feroult/yawp

@Test
public void testWhereWithoutIndexWithId() {
  yawp.save(setId(new BasicObject("a", 1l), 1l));
  yawp.save(setId(new BasicObject("b", 2l), 2l));
  yawp.save(setId(new BasicObject("c", 3l), 3l));
  IdRef<BasicObject> id = IdRef.create(yawp, BasicObject.class, 1l);
  List<BasicObject> objects = yawp(BasicObject.class).where(c("id", "=", id).or(c("longValue", "=", 3l))).list();
  assertObjects(objects, "a", "c");
  objects = yawp(BasicObject.class).where(c("id", "=", id).and(c("longValue", "=", 1l))).list();
  assertObjects(objects, "a");
  objects = yawp(BasicObject.class).where(c("id", "=", id).and(c("longValue", "=", 3l))).list();
  assertObjects(objects);
}
origin: feroult/yawp

@Test
public void testListOfIdsProperty() {
  BasicObject object = new BasicObject("xpto");
  object.setIdList(Arrays.asList(id(BasicObject.class, 10l), id(BasicObject.class, 20l)));
  yawp.save(object);
  BasicObject retrievedObject;
  retrievedObject = yawp(BasicObject.class).where("idList", "=", id(BasicObject.class, 10l)).first();
  assertEquals("xpto", retrievedObject.getStringValue());
  retrievedObject = yawp(BasicObject.class).where("idList", "<", id(BasicObject.class, 999l)).first();
  assertEquals("xpto", retrievedObject.getStringValue());
}
origin: feroult/yawp

@Test
public void testWhereWithOr() {
  saveManyBasicObjects(2);
  List<BasicObject> objects = yawp(BasicObject.class).where(or(c("intValue", "=", 1), c("intValue", "=", 2))).list();
  assertEquals(2, objects.size());
  sort(objects);
  assertEquals(2, objects.size());
  assertEquals("xpto", objects.get(0).getStringValue());
  assertEquals(1, objects.get(0).getIntValue());
  assertEquals("xpto", objects.get(1).getStringValue());
  assertEquals(2, objects.get(1).getIntValue());
}
origin: feroult/yawp

@Test
public void testWhereWithoutIndex() {
  yawp.save(new BasicObject("a", 1l));
  yawp.save(new BasicObject("b", 2l));
  List<BasicObject> objects = yawp(BasicObject.class).where("longValue", "=", 1l).list();
  assertObjects(objects, "a");
}
origin: feroult/yawp

@SuppressWarnings("unchecked")
@Test
public void testToMap() {
  Map<String, Object> map = yawp(BasicObject.class).where("field", "=", "value").toMap();
  assertEquals("io.yawp.repository.models.basic.BasicObject", map.get("clazz"));
  assertEquals(Collections.emptyList(), map.get("preOrders"));
  assertEquals(Collections.emptyList(), map.get("postOrders"));
  Map<String, String> condition = (Map<String, String>) map.get("condition");
  assertEquals("field", condition.get("field"));
  assertEquals("EQUAL", condition.get("whereOperator"));
  assertEquals("value", condition.get("whereValue"));
}
origin: feroult/yawp

@Test
public void testWhereInWithEmptyList() {
  saveManyBasicObjects(1);
  List<BasicObject> objects = yawp(BasicObject.class).where("intValue", "in", Collections.emptyList()).list();
  assertEquals(0, objects.size());
}
origin: feroult/yawp

@Test
public void testWhereWithoutIndexAndCondition() {
  yawp.save(new BasicObject("a", 1l));
  yawp.save(new BasicObject("a", 2l));
  yawp.save(new BasicObject("b", 1l));
  List<BasicObject> objects = yawp(BasicObject.class).where(c("stringValue", "=", "a").and(c("longValue", "=", 1l))).list();
  assertObjects(objects, "a");
}
origin: feroult/yawp

@Test(expected = RuntimeException.class)
public void testIdsWithPostFilter() {
  assertEquals(0, yawp(BasicObject.class).where("longValue", "=", 2l).ids().size());
}
origin: feroult/yawp

@Test
public void testWhereWithoutIndexOrCondition() {
  yawp.save(new BasicObject("a", 1l));
  yawp.save(new BasicObject("b", 2l));
  yawp.save(new BasicObject("c", 1l));
  List<BasicObject> objects = yawp(BasicObject.class).where(c("stringValue", "=", "a").or(c("longValue", "=", 1l))).list();
  assertObjects(objects, "a", "c");
}
origin: feroult/yawp

@Test
public void testWhereWithAndNot() {
  saveManyBasicObjects(5);
  List<BasicObject> objects = yawp(BasicObject.class).where(and(c("intValue", ">", 1), c("intValue", "<", 5)).not()).list();
  assertEquals(2, objects.size());
  sort(objects);
  assertEquals(1, objects.get(0).getIntValue());
  assertEquals(5, objects.get(1).getIntValue());
}
origin: feroult/yawp

@Test(expected = RuntimeException.class)
public void testIdsWithPostOrder() {
  assertEquals(0, yawp(BasicObject.class).sort("longValue").ids().size());
}
origin: feroult/yawp

@Test
public void testWhereWithoutIndexComplexConditions() {
  yawp.save(new BasicObject("a", 1l));
  yawp.save(new BasicObject("a", 2l));
  yawp.save(new BasicObject("c", 3l));
  yawp.save(new BasicObject("c", 4l));
  yawp.save(new BasicObject("d", 5l));
  yawp.save(new BasicObject("e", 6l));
  BaseCondition c2 = c("stringValue", "=", "c").and(c("longValue", "=", 3l));
  List<BasicObject> objects = yawp(BasicObject.class).where(c("stringValue", "=", "a").or(c2)).list();
  assertObjects(objects, "a", "a", "c");
}
origin: feroult/yawp

@Test
public void testWhereInWithNullList() {
  saveManyBasicObjects(1);
  List<BasicObject> objects = yawp(BasicObject.class).where("intValue", "in", null).list();
  assertEquals(0, objects.size());
}
origin: feroult/yawp

@Test
public void testWithEmptyIn() {
  BasicObject myObj1 = new BasicObject("xpto1");
  yawp.save(myObj1);
  List<BasicObject> objects = yawp(BasicObject.class).where("id", "in", Collections.emptyList()).list();
  assertEquals(0, objects.size());
}
origin: feroult/yawp

@Test
public void testOnlyIdNoResult() {
  try {
    yawp(BasicObject.class).where("stringValue", "=", "xpto").onlyId();
  } catch (NoResultException ex) {
    return;
  }
  assertTrue(false);
}
origin: feroult/yawp

@Test
public void testLimit() {
  saveManyBasicObjects(3);
  List<BasicObject> objects = yawp(BasicObject.class).order("intValue", "desc").limit(1).list();
  assertEquals(1, objects.size());
  assertEquals(3, objects.get(0).getIntValue());
}
origin: feroult/yawp

@Test
public void testWhereInWithEmptyListOrTrueExpression() {
  saveManyBasicObjects(3);
  BaseCondition emptyListCondition = c("intValue", "in", Collections.emptyList());
  BaseCondition condition = or(emptyListCondition, c("stringValue", "=", "xpto"));
  List<BasicObject> objects = yawp(BasicObject.class).where(condition).list();
  assertEquals(3, objects.size());
}
origin: feroult/yawp

@Test
public void testWhereInWithEmptyListAndFalseExpression() {
  saveManyBasicObjects(1);
  BaseCondition emptyListCondition = c("intValue", "in", Collections.emptyList());
  BaseCondition condition = and(emptyListCondition, c("stringValue", "=", "otpx"));
  List<BasicObject> objects = yawp(BasicObject.class).where(condition).list();
  assertEquals(0, objects.size());
}
origin: feroult/yawp

@Test
public void testWhereWithUnicode() {
  yawp.save(new BasicObject("\u00c1"));
  List<BasicObject> objects = yawp(BasicObject.class).where("stringValue", "=", "\u00c1").list();
  assertEquals(1, objects.size());
  assertEquals("\u00c1", objects.get(0).getStringValue());
}
origin: feroult/yawp

@Test
public void testQueryFromOptions() {
  saveManyBasicObjects(3);
  QueryOptions options = QueryOptions
      .parse("{where: ['stringValue', '=', 'xpto'], order: [{p: 'intValue', d: 'desc'}], limit: 2}");
  List<BasicObject> objects = yawp(BasicObject.class).options(options).list();
  assertEquals(2, objects.size());
  assertEquals(3, objects.get(0).getIntValue());
  assertEquals(2, objects.get(1).getIntValue());
}
io.yawp.repository.queryDatastoreQueryTest

Most used methods

  • assertObjects
  • id
  • setId
  • sort
  • yawp

Popular in Java

  • Parsing JSON documents to java classes using gson
  • scheduleAtFixedRate (ScheduledExecutorService)
  • onRequestPermissionsResult (Fragment)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • FileNotFoundException (java.io)
    Thrown when a file specified by a program cannot be found.
  • Path (java.nio.file)
  • NoSuchElementException (java.util)
    Thrown when trying to retrieve an element past the end of an Enumeration or Iterator.
  • JTextField (javax.swing)
  • Loader (org.hibernate.loader)
    Abstract superclass of object loading (and querying) strategies. This class implements useful common
  • DateTimeFormat (org.joda.time.format)
    Factory that creates instances of DateTimeFormatter from patterns and styles. Datetime formatting i
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now