@Test public void test_stringProperty() { Property<String> stringProperty = PropertyFactory.from("MyGirl"); assertEquals("'MyGirl'", stringProperty.getQuery()); QueryBuilder queryBuilder = new QueryBuilder(); stringProperty.concatenate("Talkin' About").appendConditionToQuery(queryBuilder); assertEquals("'MyGirl'='MyGirl' || 'Talkin'' About'", queryBuilder.getQuery().trim()); }
@Test public void test_queryProperty() { Property<TestModel1> model1Property = PropertyFactory.from( SQLite.select().from(TestModel1.class).where(TestModel1_Table.name.eq("Test"))) .as("Cool"); assertEquals( "(SELECT * FROM `TestModel1` WHERE `name`='Test') AS `Cool`", model1Property.getDefinition()); QueryBuilder queryBuilder = new QueryBuilder(); model1Property .minus(ConditionModel_Table.fraction) .plus(TestModel1_Table.name.withTable()) .like("%somethingnotvalid%") .appendConditionToQuery(queryBuilder); assertEquals( "(SELECT * FROM `TestModel1` WHERE `name`='Test') - `fraction` + `TestModel1`.`name` LIKE '%somethingnotvalid%'", queryBuilder.getQuery().trim()); }