Ejemplo n.º 1
0
  @Test
  public void shouldReturnCountOfReportingRightOfUser() throws SQLException {
    Long userId = 1L;
    Right right1 = new Right("template1", RightType.REPORTING);
    Right right2 = new Right("template2", RightType.REPORTING);
    Right right3 = new Right("template3", RightType.REPORTING);
    Right right4 = new Right("admin", RightType.REPORTING);
    rightMapper.insertRight(right1);
    rightMapper.insertRight(right2);
    rightMapper.insertRight(right3);
    rightMapper.insertRight(right4);

    Role role = new Role();
    role.setName("New Role");
    roleRightsMapper.insertRole(role);
    queryExecutor.executeUpdate(
        "INSERT INTO role_rights(roleId, rightName) VALUES (?,?)", role.getId(), "template1");
    queryExecutor.executeUpdate(
        "INSERT INTO role_rights(roleId, rightName) VALUES (?,?)", role.getId(), "template2");
    queryExecutor.executeUpdate(
        "INSERT INTO role_rights(roleId, rightName) VALUES (?,?)", role.getId(), "template3");
    queryExecutor.executeUpdate(
        "INSERT INTO role_rights(roleId, rightName) VALUES (?,?)", role.getId(), "admin");

    queryExecutor.executeUpdate(
        "INSERT INTO role_assignments(userId, roleId) VALUES (?,?)", userId, role.getId());

    Integer count = rightMapper.totalReportingRightsFor(userId);

    assertThat(count, is(4));
  }
Ejemplo n.º 2
0
  @Test
  public void shouldInsertRight() throws SQLException {

    Right right = new Right();
    right.setName("Requisition Group Program");
    right.setType(RightType.REPORTING);

    rightMapper.insertRight(right);

    ResultSet resultSet =
        queryExecutor.execute("SELECT * FROM rights WHERE name = ?", right.getName());
    resultSet.next();
    assertThat(resultSet.getString("name"), is(right.getName()));
    assertThat(resultSet.getString("rightType"), is(right.getType().toString()));
    assertNotNull(resultSet.getTimestamp("createdDate"));
  }
  @Test
  public void insertTest() throws SQLException {
    OrderQuantityAdjustmentType adjustmentType = new OrderQuantityAdjustmentType();

    adjustmentType.setName("Test Adjustment 1");
    adjustmentType.setDisplayOrder(2);
    adjustmentType.setDescription("Test Adjustment Description1");
    adjustmentType.setCreatedDate(new Date());

    //        adjustmentType.setCreatedBy(Long.valueOf(2));
    this.adjustmentTypeMapper.insert(adjustmentType);

    ResultSet resultSet =
        queryExecutor.execute(
            "SELECT * FROM order_quantity_adjustment_types WHERE name = ?",
            adjustmentType.getName());
    resultSet.next();
    assertThat(resultSet.getString("name"), is(adjustmentType.getName()));
    assertThat(resultSet.getString("description"), is(adjustmentType.getDescription()));
  }