use of mbg.test.mb3.generated.conditional.immutable.model.Pkblobs in project generator by mybatis.
the class DynamicSqlTest method testPKBlobsInsert.
@Test
public void testPKBlobsInsert() {
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
PkblobsMapper mapper = sqlSession.getMapper(PkblobsMapper.class);
Pkblobs record = new Pkblobs();
record.setId(3);
record.setBlob1(generateRandomBlob());
record.setBlob2(generateRandomBlob());
mapper.insert(record);
List<Pkblobs> answer = mapper.select(SelectDSLCompleter.allRows());
assertEquals(1, answer.size());
Pkblobs returnedRecord = answer.get(0);
assertEquals(record.getId(), returnedRecord.getId());
assertTrue(blobsAreEqual(record.getBlob1(), returnedRecord.getBlob1()));
assertTrue(blobsAreEqual(record.getBlob2(), returnedRecord.getBlob2()));
}
}
use of mbg.test.mb3.generated.conditional.immutable.model.Pkblobs in project generator by mybatis.
the class DynamicSqlTest method testPKBlobsUpdateByPrimaryKeySelective.
@Test
public void testPKBlobsUpdateByPrimaryKeySelective() {
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
PkblobsMapper mapper = sqlSession.getMapper(PkblobsMapper.class);
Pkblobs record = new Pkblobs();
record.setId(3);
record.setBlob1(generateRandomBlob());
record.setBlob2(generateRandomBlob());
mapper.insert(record);
Pkblobs newRecord = new Pkblobs();
newRecord.setId(3);
newRecord.setBlob2(generateRandomBlob());
mapper.updateByPrimaryKeySelective(newRecord);
Optional<Pkblobs> returnedRecord = mapper.selectByPrimaryKey(3);
assertThat(returnedRecord).hasValueSatisfying(rr -> {
assertEquals(record.getId(), rr.getId());
assertTrue(blobsAreEqual(record.getBlob1(), rr.getBlob1()));
assertTrue(blobsAreEqual(newRecord.getBlob2(), rr.getBlob2()));
});
}
}
use of mbg.test.mb3.generated.conditional.immutable.model.Pkblobs in project generator by mybatis.
the class DynamicSqlTest method testPKBlobsDeleteByPrimaryKey.
@Test
public void testPKBlobsDeleteByPrimaryKey() {
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
PkblobsMapper mapper = sqlSession.getMapper(PkblobsMapper.class);
Pkblobs record = new Pkblobs();
record.setId(3);
record.setBlob1(generateRandomBlob());
record.setBlob2(generateRandomBlob());
mapper.insert(record);
List<Pkblobs> answer = mapper.select(SelectDSLCompleter.allRows());
assertEquals(1, answer.size());
int rows = mapper.deleteByPrimaryKey(3);
assertEquals(1, rows);
answer = mapper.select(SelectDSLCompleter.allRows());
assertEquals(0, answer.size());
}
}
use of mbg.test.mb3.generated.conditional.immutable.model.Pkblobs in project generator by mybatis.
the class DynamicSqlTest method testPKBlobsSelectByExampleWithBlobs.
@Test
public void testPKBlobsSelectByExampleWithBlobs() {
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
PkblobsMapper mapper = sqlSession.getMapper(PkblobsMapper.class);
Pkblobs record = new Pkblobs();
record.setId(3);
record.setBlob1(generateRandomBlob());
record.setBlob2(generateRandomBlob());
mapper.insert(record);
record = new Pkblobs();
record.setId(6);
record.setBlob1(generateRandomBlob());
record.setBlob2(generateRandomBlob());
mapper.insert(record);
List<Pkblobs> answer = mapper.select(DSL -> DSL.where(pkblobs.id, isGreaterThan(4)));
assertEquals(1, answer.size());
Pkblobs newRecord = answer.get(0);
assertEquals(record.getId(), newRecord.getId());
assertTrue(blobsAreEqual(record.getBlob1(), newRecord.getBlob1()));
assertTrue(blobsAreEqual(record.getBlob2(), newRecord.getBlob2()));
}
}
use of mbg.test.mb3.generated.conditional.immutable.model.Pkblobs in project generator by mybatis.
the class DynamicSqlTest method testPKBlobsdelete.
@Test
public void testPKBlobsdelete() {
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
PkblobsMapper mapper = sqlSession.getMapper(PkblobsMapper.class);
Pkblobs record = new Pkblobs();
record.setId(3);
record.setBlob1(generateRandomBlob());
record.setBlob2(generateRandomBlob());
mapper.insert(record);
record = new Pkblobs();
record.setId(6);
record.setBlob1(generateRandomBlob());
record.setBlob2(generateRandomBlob());
mapper.insert(record);
List<Pkblobs> answer = mapper.select(SelectDSLCompleter.allRows());
assertEquals(2, answer.size());
int rows = mapper.delete(dsl -> dsl.where(pkblobs.id, isLessThan(4)));
assertEquals(1, rows);
answer = mapper.select(SelectDSLCompleter.allRows());
assertEquals(1, answer.size());
}
}
Aggregations