@Test(expected = DbException.class) public void testFindLong_uniqueFails() { putTestEntity(null, 1); putTestEntity(null, 1); box.query().build().property(simpleLong).unique().findLong(); }
@Test(expected = DbException.class) public void testFindString_uniqueFails() { putTestEntity("foo", 1); putTestEntity("foo", 2); box.query().build().property(simpleString).unique().findString(); }
@Test(expected = DbException.class) public void testFindByte_uniqueFails() { putTestEntity(null, 1); putTestEntity(null, 1); box.query().build().property(simpleByte).unique().findByte(); }
@Test(expected = DbException.class) public void testFindInt_uniqueFails() { putTestEntity(null, 1); putTestEntity(null, 1); box.query().build().property(simpleInt).unique().findInt(); }
@Test(expected = DbException.class) public void testFindShort_uniqueFails() { putTestEntity(null, 1); putTestEntity(null, 1); box.query().build().property(simpleShort).unique().findShort(); }
@Test(expected = DbException.class) public void testFindBoolean_uniqueFails() { putTestEntity(null, 1); putTestEntity(null, 1); box.query().build().property(simpleBoolean).unique().findBoolean(); }
@Test(expected = DbException.class) public void testFindFloat_uniqueFails() { putTestEntity(null, 1); putTestEntity(null, 1); box.query().build().property(simpleFloat).unique().findFloat(); }
@Test(expected = DbException.class) public void testFindDouble_uniqueFails() { putTestEntity(null, 1); putTestEntity(null, 1); box.query().build().property(simpleDouble).unique().findDouble(); }
@Test public void testFindString() { Query<TestEntity> query = box.query().greater(simpleLong, 1002).build(); PropertyQuery propertyQuery = query.property(simpleString); assertNull(propertyQuery.findString()); assertNull(propertyQuery.reset().unique().findString()); putTestEntities(5); assertEquals("foo3", propertyQuery.reset().findString()); query = box.query().greater(simpleLong, 1004).build(); propertyQuery = query.property(simpleString); assertEquals("foo5", propertyQuery.reset().unique().findString()); putTestEntity(null, 6); putTestEntity(null, 7); query.setParameter(simpleLong, 1005); assertEquals("nope", propertyQuery.reset().distinct().nullValue("nope").unique().findString()); }
@Test public void testFindByte() { Query<TestEntity> query = box.query().greater(simpleLong, 1002).build(); assertNull(query.property(simpleByte).findByte()); assertNull(query.property(simpleByte).unique().findByte()); putTestEntities(5); assertEquals((byte) 13, (byte) query.property(simpleByte).findByte()); query = box.query().greater(simpleLong, 1004).build(); assertEquals((byte) 15, (byte) query.property(simpleByte).distinct().unique().findByte()); }
@Test public void testFindShort() { Query<TestEntity> query = box.query().greater(simpleLong, 1002).build(); assertNull(query.property(simpleShort).findShort()); assertNull(query.property(simpleShort).unique().findShort()); putTestEntities(5); assertEquals(103, (short) query.property(simpleShort).findShort()); query = box.query().greater(simpleLong, 1004).build(); assertEquals(105, (short) query.property(simpleShort).distinct().unique().findShort()); }
@Test public void testFindBoolean() { Query<TestEntity> query = box.query().greater(simpleLong, 1002).build(); assertNull(query.property(simpleBoolean).findBoolean()); assertNull(query.property(simpleBoolean).unique().findBoolean()); putTestEntities(5); assertFalse(query.property(simpleBoolean).findBoolean()); query = box.query().greater(simpleLong, 1004).build(); assertFalse(query.property(simpleBoolean).distinct().unique().findBoolean()); }
@Test public void testFindFloat() { Query<TestEntity> query = box.query().greater(simpleLong, 1002).build(); assertNull(query.property(simpleFloat).findFloat()); assertNull(query.property(simpleFloat).unique().findFloat()); putTestEntities(5); assertEquals(200.3f, query.property(simpleFloat).findFloat(), 0.001f); query = box.query().greater(simpleLong, 1004).build(); assertEquals(200.5f, query.property(simpleFloat).distinct().unique().findFloat(), 0.001f); }
@Test public void testFindDouble() { Query<TestEntity> query = box.query().greater(simpleLong, 1002).build(); assertNull(query.property(simpleDouble).findDouble()); assertNull(query.property(simpleDouble).unique().findDouble()); putTestEntities(5); assertEquals(2000.03, query.property(simpleDouble).findDouble(), 0.001); query = box.query().greater(simpleLong, 1004).build(); assertEquals(2000.05, query.property(simpleDouble).distinct().unique().findDouble(), 0.001); }
@Test public void testFindInt() { Query<TestEntity> query = box.query().greater(simpleLong, 1002).build(); assertNull(query.property(simpleInt).findInt()); assertNull(query.property(simpleInt).unique().findInt()); putTestEntities(5); assertEquals(3, (int) query.property(simpleInt).findInt()); query = box.query().greater(simpleLong, 1004).build(); assertEquals(5, (int) query.property(simpleInt).distinct().unique().findInt()); TestEntityCursor.INT_NULL_HACK = true; try { putTestEntity(null, 6); } finally { TestEntityCursor.INT_NULL_HACK = false; } query.setParameter(simpleLong, 1005); assertEquals(-99, (int) query.property(simpleInt).nullValue(-99).unique().findInt()); }