Search in sources :

Example 1 with Permission

use of indi.mybatis.flying.pojo.Permission in project mybatis.flying by limeng32.

the class PermissionTest method testSecret.

@Test
@DatabaseSetup(connection = "dataSource1", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/permissionTest/testSecret.datasource.xml")
@ExpectedDatabase(connection = "dataSource1", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/permissionTest/testSecret.datasource.result.xml")
@DatabaseTearDown(connection = "dataSource1", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/permissionTest/testSecret.datasource.result.xml")
public void testSecret() {
    Permission permission = new Permission();
    permission.setId(1);
    permission.setSalt("sa");
    permission.setSecret2("asd".getBytes());
    permissionService.insert(permission);
    Permission permission2 = permissionService.select(1);
    System.out.println(new String(permission2.getSecret2()));
    Permission p3 = new Permission();
    p3.setId(3);
    p3.setSalt("sa2");
    permissionService.insertAes(p3);
    Permission p4 = new Permission();
    p4.setSalt("sa2");
    Permission permission3 = permissionService.selectAes(p4);
    System.out.println(new String(permission3.getSecret2()));
}
Also used : Permission(indi.mybatis.flying.pojo.Permission) ExpectedDatabase(com.github.springtestdbunit.annotation.ExpectedDatabase) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) DatabaseSetup(com.github.springtestdbunit.annotation.DatabaseSetup) DatabaseTearDown(com.github.springtestdbunit.annotation.DatabaseTearDown)

Example 2 with Permission

use of indi.mybatis.flying.pojo.Permission in project mybatis.flying by limeng32.

the class PermissionTest method testSelect.

@Test
@DatabaseSetup(connection = "dataSource1", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/permissionTest/testSelect.datasource.xml")
@ExpectedDatabase(connection = "dataSource1", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/permissionTest/testSelect.datasource.result.xml")
@DatabaseTearDown(connection = "dataSource1", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/permissionTest/testSelect.datasource.result.xml")
public void testSelect() {
    Permission permission = permissionService.select(2);
    Assert.assertEquals("ann", permission.getName());
    // 当account.permission为null时,外键不发生作用
    Collection<Account_> accounts = accountService.selectAll(new Account_());
    Assert.assertEquals(2, accounts.size());
    // 当account.permission不为null时,外键发生作用
    Permission p = new Permission();
    Account_Condition a = new Account_Condition();
    a.setEmailHeadLike("an");
    a.setPermission(p);
    Collection<Account_> accounts2 = accountService.selectAll(a);
    Assert.assertEquals(2, accounts2.size());
    // for (Account_ e : accounts2) {
    // Assert.assertEquals(1, e.getId().intValue());
    // Assert.assertEquals(20, e.getPermission().getFakeId().intValue());
    // }
    int c = accountService.count(a);
    Assert.assertEquals(2, c);
}
Also used : Permission(indi.mybatis.flying.pojo.Permission) Account_(indi.mybatis.flying.pojo.Account_) Account_Condition(indi.mybatis.flying.pojo.condition.Account_Condition) ExpectedDatabase(com.github.springtestdbunit.annotation.ExpectedDatabase) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) DatabaseSetup(com.github.springtestdbunit.annotation.DatabaseSetup) DatabaseTearDown(com.github.springtestdbunit.annotation.DatabaseTearDown)

Example 3 with Permission

use of indi.mybatis.flying.pojo.Permission in project mybatis.flying by limeng32.

the class PrefixTest method testSelect.

@Test
@DatabaseSetup(connection = "dataSource1", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/prefixTest/testSelect.xml")
@ExpectedDatabase(connection = "dataSource1", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/prefixTest/testSelect.result.xml")
@DatabaseTearDown(connection = "dataSource1", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/prefixTest/testSelect.result.xml")
public void testSelect() {
    Map<String, String> map = new HashMap<>();
    map.put("id", "1");
    Account_ account = accountService.selectAsd(1);
    Assert.assertTrue(account.getActivated());
    Assert.assertEquals("bob", account.getName());
    Assert.assertEquals("bob@live.cn_", account.getEmail());
    Assert.assertNull(account.getPassword());
    Assert.assertEquals("a111", account.getActivateValue());
    Assert.assertEquals(11, account.getOpLock().intValue());
    Account_ ac = new Account_();
    ac.setName("carl");
    Permission pc = new Permission();
    pc.setName("carl");
    ac.setPermission(pc);
    Collection<Account_> accountC = accountService.selectAllPrefix(ac);
    System.out.println(JSONObject.toJSONString(accountC));
    Account_[] accounts = accountC.toArray(new Account_[accountC.size()]);
    Assert.assertEquals(3, accounts[0].getId().intValue());
    Assert.assertEquals(23, accounts[0].getPermission().getFakeId().intValue());
    Assert.assertEquals(3, accounts[0].getPermission().getId().intValue());
    Assert.assertEquals("carl", accounts[0].getPermission().getName());
    Assert.assertEquals(13, accounts[0].getRole().getId().intValue());
    Assert.assertEquals("role3", accounts[0].getRole().getName());
    Assert.assertEquals(113, accounts[0].getRoleDeputy().getId().intValue());
    Assert.assertEquals("roleDeputy3", accounts[0].getRoleDeputy().getName());
    Assert.assertEquals(4, accounts[1].getId().intValue());
    Assert.assertEquals(24, accounts[1].getPermission().getFakeId().intValue());
    Assert.assertEquals(4, accounts[1].getPermission().getId().intValue());
    Assert.assertEquals("carl", accounts[1].getPermission().getName());
    Assert.assertEquals(14, accounts[1].getRole().getId().intValue());
    Assert.assertEquals("role4", accounts[1].getRole().getName());
    Assert.assertEquals(114, accounts[1].getRoleDeputy().getId().intValue());
    Assert.assertEquals("roleDeputy4", accounts[1].getRoleDeputy().getName());
    accountMapper.selectGroupBy(new Account_());
    int c = accountService.countAsd(ac);
    Assert.assertEquals(2, c);
    FlyingModel fm = FlyingManager.getFlyingModelFromCache("indi.mybatis.flying.mapper.AccountMapper.selectAllPrefix");
    System.out.println("fm::" + JSONObject.toJSONString(fm));
    Assert.assertEquals("noPassword", fm.getIgnoreTag());
    Assert.assertEquals("use index(index1)", fm.getIndex());
    Assert.assertNull(fm.getPrefix());
    FlyingModel fm1 = fm.getProperties().get("permission");
    Assert.assertNull(fm1.getIgnoreTag());
    Assert.assertNull(fm1.getIndex());
    Assert.assertEquals("permission__", fm1.getPrefix());
    Assert.assertEquals("indi.mybatis.flying.mapper.PermissionMapper.select", fm1.getId());
    FlyingModel fm2 = fm.getProperties().get("role");
    Assert.assertNull(fm2.getIndex());
    Assert.assertEquals("indi.mybatis.flying.mapper.RoleMapper.select", fm2.getId());
    Assert.assertEquals("role__", fm2.getPrefix());
    FlyingModel fm3 = fm.getProperties().get("roleDeputy");
    Assert.assertNull(fm3.getIndex());
    Assert.assertEquals("roleDeputy__", fm3.getPrefix());
    FlyingModel fm10 = FlyingManager.getFlyingModelFromCache("indi.mybatis.flying.mapper.AccountMapper.selectGroupBy");
    Assert.assertNotNull(fm10);
    System.out.println("fm10::" + JSONObject.toJSONString(fm10));
    Assert.assertEquals(2, fm10.getGroupBy().size());
    Assert.assertEquals(2, fm10.getAggregate().size());
    Set<AggregateModel> am = fm10.getAggregate().get("opLock");
    Assert.assertEquals(2, am.size());
}
Also used : FlyingModel(indi.mybatis.flying.models.FlyingModel) AggregateModel(indi.mybatis.flying.models.AggregateModel) HashMap(java.util.HashMap) Permission(indi.mybatis.flying.pojo.Permission) Account_(indi.mybatis.flying.pojo.Account_) ExpectedDatabase(com.github.springtestdbunit.annotation.ExpectedDatabase) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) DatabaseSetup(com.github.springtestdbunit.annotation.DatabaseSetup) DatabaseTearDown(com.github.springtestdbunit.annotation.DatabaseTearDown)

Example 4 with Permission

use of indi.mybatis.flying.pojo.Permission in project mybatis.flying by limeng32.

the class WhiteListTest method testWhiteListUpdate.

@Test
@DatabaseSetup(connection = "dataSource1", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/whiteListTest/testWhiteListUpdate.xml")
@ExpectedDatabase(connection = "dataSource1", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/whiteListTest/testWhiteListUpdate.result.xml")
@DatabaseTearDown(connection = "dataSource1", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/whiteListTest/testWhiteListUpdate.result.xml")
public void testWhiteListUpdate() {
    Account_ account = accountService.select(1);
    account.setName("bob");
    account.setEmail("bob@live.cn");
    account.setPassword("bbb");
    account.setStatus(StoryStatus_.PUBLISH);
    account.setActivateValue("bv");
    Role_ role = new Role_();
    role.setId(2);
    account.setRole(role);
    Permission permission = new Permission();
    permission.setId(22);
    account.setPermission(permission);
    accountService.updateSimpleNoName(account);
}
Also used : Permission(indi.mybatis.flying.pojo.Permission) Account_(indi.mybatis.flying.pojo.Account_) Role_(indi.mybatis.flying.pojo.Role_) ExpectedDatabase(com.github.springtestdbunit.annotation.ExpectedDatabase) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) DatabaseSetup(com.github.springtestdbunit.annotation.DatabaseSetup) DatabaseTearDown(com.github.springtestdbunit.annotation.DatabaseTearDown)

Example 5 with Permission

use of indi.mybatis.flying.pojo.Permission in project mybatis.flying by limeng32.

the class WhiteListTest method testWhiteListInsert.

@Test
@DatabaseSetup(connection = "dataSource1", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/whiteListTest/testWhiteListInsert.xml")
@ExpectedDatabase(connection = "dataSource1", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/whiteListTest/testWhiteListInsert.result.xml")
@DatabaseTearDown(connection = "dataSource1", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/whiteListTest/testWhiteListInsert.result.xml")
public void testWhiteListInsert() {
    Account_ account = new Account_();
    account.setName("name");
    account.setEmail("email");
    account.setPassword("aaa");
    Role_ role = new Role_();
    role.setId(11);
    account.setRole(role);
    Permission permission = new Permission();
    permission.setId(22);
    account.setPermission(permission);
    accountService.insertSimpleNoName(account);
}
Also used : Permission(indi.mybatis.flying.pojo.Permission) Account_(indi.mybatis.flying.pojo.Account_) Role_(indi.mybatis.flying.pojo.Role_) ExpectedDatabase(com.github.springtestdbunit.annotation.ExpectedDatabase) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) DatabaseSetup(com.github.springtestdbunit.annotation.DatabaseSetup) DatabaseTearDown(com.github.springtestdbunit.annotation.DatabaseTearDown)

Aggregations

Permission (indi.mybatis.flying.pojo.Permission)7 DatabaseSetup (com.github.springtestdbunit.annotation.DatabaseSetup)6 DatabaseTearDown (com.github.springtestdbunit.annotation.DatabaseTearDown)6 ExpectedDatabase (com.github.springtestdbunit.annotation.ExpectedDatabase)6 Account_ (indi.mybatis.flying.pojo.Account_)6 Test (org.junit.Test)6 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)6 Role_ (indi.mybatis.flying.pojo.Role_)3 AggregateModel (indi.mybatis.flying.models.AggregateModel)1 FlyingModel (indi.mybatis.flying.models.FlyingModel)1 Account_Condition (indi.mybatis.flying.pojo.condition.Account_Condition)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Benchmark (org.openjdk.jmh.annotations.Benchmark)1