コード例 #1
0
 protected Template createTemplate(
     String namespaceCode, String name, String description, String kimTypeId) {
   // TODO: refactor if RICE adds Create/update methods for templates
   RoleAndPermissionServiceMockImpl impl = (RoleAndPermissionServiceMockImpl) this.roleService;
   Template.Builder bldr = Template.Builder.create(namespaceCode, name, kimTypeId);
   bldr.setDescription(description);
   bldr.setActive(true);
   Template template = impl.createTemplate(bldr.build());
   return template;
 }
コード例 #2
0
  private Permission createPermission(
      Template template, String namespaceCode, String name, Map<String, String> details) {
    Permission.Builder bldr = Permission.Builder.create(namespaceCode, name);
    bldr.setTemplate(Template.Builder.create(template));
    bldr.setActive(true);
    bldr.setAttributes(details);

    Permission fromCreate = this.permissionService.createPermission(bldr.build());
    assertEquals(namespaceCode, fromCreate.getNamespaceCode());
    assertEquals(name, fromCreate.getName());
    assertNotNull(fromCreate.getId());
    assertTrue(fromCreate.isActive());
    assertEquals(details, fromCreate.getAttributes());
    assertNull(fromCreate.getDescription());

    bldr = Permission.Builder.create(fromCreate);
    bldr.setDescription(namespaceCode + " " + name);
    Permission fromUpdate = this.permissionService.updatePermission(bldr.build());
    assertEquals(fromCreate.getNamespaceCode(), fromUpdate.getNamespaceCode());
    assertEquals(fromCreate.getName(), fromUpdate.getName());
    assertEquals(fromCreate.getId(), fromUpdate.getId());
    assertEquals(fromCreate.isActive(), fromUpdate.isActive());
    assertEquals(fromCreate.getAttributes(), fromUpdate.getAttributes());
    assertEquals(bldr.getDescription(), fromUpdate.getDescription());

    Permission fromGet = this.permissionService.getPermission(fromUpdate.getId());
    assertEquals(fromUpdate.getNamespaceCode(), fromGet.getNamespaceCode());
    assertEquals(fromUpdate.getName(), fromGet.getName());
    assertEquals(fromUpdate.getId(), fromGet.getId());
    assertEquals(fromUpdate.getVersionNumber(), fromGet.getVersionNumber());
    assertEquals(fromUpdate.isActive(), fromGet.isActive());
    assertEquals(fromUpdate.getAttributes(), fromGet.getAttributes());
    assertEquals(fromUpdate.getDescription(), fromGet.getDescription());

    Permission fromFind =
        this.permissionService.findPermByNamespaceCodeAndName(namespaceCode, name);
    assertEquals(fromUpdate.getNamespaceCode(), fromFind.getNamespaceCode());
    assertEquals(fromUpdate.getName(), fromFind.getName());
    assertEquals(fromUpdate.getId(), fromFind.getId());
    assertEquals(fromUpdate.getVersionNumber(), fromFind.getVersionNumber());
    assertEquals(fromUpdate.isActive(), fromFind.isActive());
    assertEquals(fromUpdate.getAttributes(), fromFind.getAttributes());
    assertEquals(fromUpdate.getDescription(), fromFind.getDescription());

    return fromFind;
  }