use of mbg.test.mb3.generated.conditional.immutable.mapper.PkblobsMapper in project generator by mybatis.
the class DynamicSqlTest method testPKBlobsSelectByExampleWithMultiInsert.
@Test
public void testPKBlobsSelectByExampleWithMultiInsert() {
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
PkblobsMapper mapper = sqlSession.getMapper(PkblobsMapper.class);
Collection<Pkblobs> records = new ArrayList<>();
Pkblobs record = new Pkblobs();
record.setId(3);
record.setBlob1(generateRandomBlob());
record.setBlob2(generateRandomBlob());
records.add(record);
record = new Pkblobs();
record.setId(6);
record.setBlob1(generateRandomBlob());
record.setBlob2(generateRandomBlob());
records.add(record);
int recordsInserted = mapper.insertMultiple(records);
assertEquals(2, recordsInserted);
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.mapper.PkblobsMapper in project generator by mybatis.
the class DynamicSqlTest method testPKBlobsSelectByPrimaryKey.
@Test
public void testPKBlobsSelectByPrimaryKey() {
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 record1 = new Pkblobs();
record1.setId(6);
record1.setBlob1(generateRandomBlob());
record1.setBlob2(generateRandomBlob());
mapper.insert(record1);
Optional<Pkblobs> newRecord = mapper.selectByPrimaryKey(6);
assertThat(newRecord).hasValueSatisfying(nr -> {
assertEquals(record1.getId(), nr.getId());
assertTrue(blobsAreEqual(record1.getBlob1(), nr.getBlob1()));
assertTrue(blobsAreEqual(record1.getBlob2(), nr.getBlob2()));
});
}
}
use of mbg.test.mb3.generated.conditional.immutable.mapper.PkblobsMapper in project generator by mybatis.
the class DynamicSqlTest method testPKBlobscount.
@Test
public void testPKBlobscount() {
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);
long rows = mapper.count(dsl -> dsl.where(pkblobs.id, isLessThan(4)));
assertEquals(1, rows);
rows = mapper.count(dsl -> dsl);
assertEquals(2, rows);
}
}
use of mbg.test.mb3.generated.conditional.immutable.mapper.PkblobsMapper in project generator by mybatis.
the class ConditionalJava5Test method testPKBlobsDeleteByPrimaryKey.
@Test
public void testPKBlobsDeleteByPrimaryKey() {
SqlSession sqlSession = sqlSessionFactory.openSession();
try {
PkblobsMapper mapper = sqlSession.getMapper(PkblobsMapper.class);
Pkblobs record = new Pkblobs();
record.setId(3);
record.setBlob1(generateRandomBlob());
record.setBlob2(generateRandomBlob());
mapper.insert(record);
PkblobsExample example = new PkblobsExample();
List<Pkblobs> answer = mapper.selectByExample(example);
assertEquals(1, answer.size());
int rows = mapper.deleteByPrimaryKey(3);
assertEquals(1, rows);
example = new PkblobsExample();
answer = mapper.selectByExample(example);
assertEquals(0, answer.size());
} finally {
sqlSession.close();
}
}
use of mbg.test.mb3.generated.conditional.immutable.mapper.PkblobsMapper in project generator by mybatis.
the class ConditionalJava5Test method testPKBlobsInsert.
@Test
public void testPKBlobsInsert() {
SqlSession sqlSession = sqlSessionFactory.openSession();
try {
PkblobsMapper mapper = sqlSession.getMapper(PkblobsMapper.class);
Pkblobs record = new Pkblobs();
record.setId(3);
record.setBlob1(generateRandomBlob());
record.setBlob2(generateRandomBlob());
mapper.insert(record);
PkblobsExample example = new PkblobsExample();
List<Pkblobs> answer = mapper.selectByExampleWithBLOBs(example);
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()));
} finally {
sqlSession.close();
}
}
Aggregations