Search in sources :

Example 1 with Regexrename

use of mbg.test.mb3.generated.miscellaneous.model.Regexrename in project generator by mybatis.

the class MiscellaneousTest method testRegexRenameInsertSelective.

@Test
public void testRegexRenameInsertSelective() {
    RegexrenameDAO dao = getRegexrenameDAO();
    try {
        Regexrename record = new Regexrename();
        record.setZipCode("99999");
        dao.insertRegexrenameSelective(record);
        Integer key = 1;
        assertEquals(key, record.getId());
        Regexrename returnedRecord = dao.selectRegexrenameByPrimaryKey(key);
        assertNull(returnedRecord.getAddress());
        assertEquals(record.getId(), returnedRecord.getId());
        assertNull(returnedRecord.getName());
        assertEquals(record.getZipCode(), returnedRecord.getZipCode());
    } catch (SQLException e) {
        fail(e.getMessage());
    }
}
Also used : RegexrenameDAO(mbg.test.ib2j5.generated.miscellaneous.dao.RegexrenameDAO) Regexrename(mbg.test.ib2j5.generated.miscellaneous.model.Regexrename) SQLException(java.sql.SQLException) Test(org.junit.Test)

Example 2 with Regexrename

use of mbg.test.mb3.generated.miscellaneous.model.Regexrename in project generator by mybatis.

the class MiscellaneousTest method testRegexRenameInsert.

@Test
public void testRegexRenameInsert() {
    try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
        RegexrenameMapper mapper = sqlSession.getMapper(RegexrenameMapper.class);
        Regexrename record = new Regexrename();
        record.setAddress("123 Main Street");
        record.setName("Fred");
        record.setZipCode("99999");
        mapper.insert(record);
        // test generated id
        assertEquals(1, record.getId());
        Optional<Regexrename> returnedRecord = mapper.selectByPrimaryKey(1);
        assertThat(returnedRecord).hasValueSatisfying(rr -> {
            assertEquals(record.getAddress(), rr.getAddress());
            assertEquals(1, rr.getId().intValue());
            assertEquals(record.getName(), rr.getName());
            assertEquals(record.getZipCode(), rr.getZipCode());
        });
    }
}
Also used : SqlSession(org.apache.ibatis.session.SqlSession) Regexrename(mbg.test.mb3.generated.dsql.miscellaneous.model.Regexrename) RegexrenameMapper(mbg.test.mb3.generated.dsql.miscellaneous.mapper.RegexrenameMapper) Test(org.junit.jupiter.api.Test)

Example 3 with Regexrename

use of mbg.test.mb3.generated.miscellaneous.model.Regexrename in project generator by mybatis.

the class MiscellaneousTest method testRegexRenameInsertSelective.

@Test
public void testRegexRenameInsertSelective() {
    try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
        RegexrenameMapper mapper = sqlSession.getMapper(RegexrenameMapper.class);
        Regexrename record = new Regexrename();
        record.setZipCode("99999");
        mapper.insertSelective(record);
        assertEquals(1, record.getId());
        Optional<Regexrename> returnedRecord = mapper.selectByPrimaryKey(1);
        assertThat(returnedRecord).hasValueSatisfying(rr -> {
            assertNull(rr.getAddress());
            assertEquals(record.getId(), rr.getId());
            assertNull(rr.getName());
            assertEquals(record.getZipCode(), rr.getZipCode());
        });
    }
}
Also used : SqlSession(org.apache.ibatis.session.SqlSession) Regexrename(mbg.test.mb3.generated.dsql.miscellaneous.model.Regexrename) RegexrenameMapper(mbg.test.mb3.generated.dsql.miscellaneous.mapper.RegexrenameMapper) Test(org.junit.jupiter.api.Test)

Example 4 with Regexrename

use of mbg.test.mb3.generated.miscellaneous.model.Regexrename in project generator by mybatis.

the class MiscellaneousTest method testRegexRenameInsertSelective.

@Test
public void testRegexRenameInsertSelective() {
    SqlSession sqlSession = sqlSessionFactory.openSession();
    try {
        RegexrenameMapper mapper = sqlSession.getMapper(RegexrenameMapper.class);
        Regexrename record = new Regexrename();
        record.setZipCode("99999");
        mapper.insertSelective(record);
        Integer key = 1;
        assertEquals(key, record.getId());
        Regexrename returnedRecord = mapper.selectByPrimaryKey(key);
        assertNull(returnedRecord.getAddress());
        assertEquals(record.getId(), returnedRecord.getId());
        assertNull(record.getName(), returnedRecord.getName());
        assertEquals(record.getZipCode(), returnedRecord.getZipCode());
    } finally {
        sqlSession.close();
    }
}
Also used : SqlSession(org.apache.ibatis.session.SqlSession) Regexrename(mbg.test.mb3.generated.mixed.miscellaneous.model.Regexrename) RegexrenameMapper(mbg.test.mb3.generated.mixed.miscellaneous.mapper.RegexrenameMapper) Test(org.junit.jupiter.api.Test)

Example 5 with Regexrename

use of mbg.test.mb3.generated.miscellaneous.model.Regexrename in project generator by mybatis.

the class MiscellaneousTest method testRegexRenameInsertSelective.

public void testRegexRenameInsertSelective() {
    RegexrenameDAO dao = getRegexrenameDAO();
    try {
        Regexrename record = new Regexrename();
        record.setZipCode("99999");
        dao.insertRegexrenameSelective(record);
        Integer key = new Integer(1);
        assertEquals(key, record.getId());
        Regexrename returnedRecord = dao.selectRegexrenameByPrimaryKey(key);
        assertNull(returnedRecord.getAddress());
        assertEquals(record.getId(), returnedRecord.getId());
        assertNull(returnedRecord.getName());
        assertEquals(record.getZipCode(), returnedRecord.getZipCode());
    } catch (SQLException e) {
        fail(e.getMessage());
    }
}
Also used : RegexrenameDAO(mbg.test.ib2j2.generated.miscellaneous.dao.RegexrenameDAO) Regexrename(mbg.test.ib2j2.generated.miscellaneous.model.Regexrename) SQLException(java.sql.SQLException)

Aggregations

SqlSession (org.apache.ibatis.session.SqlSession)8 Test (org.junit.jupiter.api.Test)8 SQLException (java.sql.SQLException)4 RegexrenameDAO (mbg.test.ib2j2.generated.miscellaneous.dao.RegexrenameDAO)2 Regexrename (mbg.test.ib2j2.generated.miscellaneous.model.Regexrename)2 RegexrenameDAO (mbg.test.ib2j5.generated.miscellaneous.dao.RegexrenameDAO)2 Regexrename (mbg.test.ib2j5.generated.miscellaneous.model.Regexrename)2 RegexrenameMapper (mbg.test.mb3.generated.annotated.miscellaneous.mapper.RegexrenameMapper)2 Regexrename (mbg.test.mb3.generated.annotated.miscellaneous.model.Regexrename)2 RegexrenameMapper (mbg.test.mb3.generated.dsql.miscellaneous.mapper.RegexrenameMapper)2 Regexrename (mbg.test.mb3.generated.dsql.miscellaneous.model.Regexrename)2 RegexrenameMapper (mbg.test.mb3.generated.miscellaneous.mapper.RegexrenameMapper)2 Regexrename (mbg.test.mb3.generated.miscellaneous.model.Regexrename)2 RegexrenameMapper (mbg.test.mb3.generated.mixed.miscellaneous.mapper.RegexrenameMapper)2 Regexrename (mbg.test.mb3.generated.mixed.miscellaneous.model.Regexrename)2 Test (org.junit.Test)2