@Test public void selectOne() { AutoIncrementIdEntity entity = new AutoIncrementIdEntity(); entity.stringField = "stringField#123456"; Optional<Long> id = repository.insert(entity); Assert.assertTrue(id.isPresent()); AutoIncrementIdEntity selectedEntity = repository.selectOne("string_field = ?", entity.stringField).get(); Assert.assertEquals((long) id.get(), (long) selectedEntity.id); Assert.assertEquals(entity.stringField, selectedEntity.stringField); }
@Test public void insert() { AutoIncrementIdEntity entity = new AutoIncrementIdEntity(); entity.stringField = "string"; entity.doubleField = 3.25; entity.dateTimeField = LocalDateTime.now(); Optional<Long> id = repository.insert(entity); Assert.assertTrue(id.isPresent()); AutoIncrementIdEntity selectedEntity = repository.get(id.get()).get(); Assert.assertEquals((long) id.get(), (long) selectedEntity.id); Assert.assertEquals(entity.stringField, selectedEntity.stringField); Assert.assertEquals(entity.doubleField, selectedEntity.doubleField); Assert.assertEquals(entity.dateTimeField, selectedEntity.dateTimeField); }
@Test public void select() { AutoIncrementIdEntity entity1 = new AutoIncrementIdEntity(); entity1.stringField = "string1"; entity1.enumField = TestEnum.V1; repository.insert(entity1); AutoIncrementIdEntity entity2 = new AutoIncrementIdEntity(); entity2.stringField = "string2"; entity2.enumField = TestEnum.V2; repository.insert(entity2); List<AutoIncrementIdEntity> entities = repository.select("enum_field = ?", TestEnum.V1); Assert.assertEquals(1, entities.size()); Assert.assertEquals(entity1.enumField, entities.get(0).enumField); Assert.assertEquals(entity1.stringField, entities.get(0).stringField); }
@Test public void selectAll() { List<AutoIncrementIdEntity> entities = repository.selectAll(); Assert.assertTrue(entities.isEmpty()); }