Package org.multibit.mbm.client.domain.model.model

Examples of org.multibit.mbm.client.domain.model.model.Role


   */
  @Test
  public void testPersistAndFind() {

    // Create a new Role
    Role expected = RoleBuilder.newInstance()
      .withName("ROLE_TEST")
      .withDescription("A test role")
      .withAuthority(Authority.CHANGE_OWN_PASSWORD)
      .build();

    // Persist with insert
    int originalRoleRows = countRowsInTable("roles");
    int originalAuthorityRows = countRowsInTable("authorities");
    testObject.saveOrUpdate(expected);
    testObject.flush();

    // Session flush: Expect an insert in roles and authorities
    int updatedRoleRows = countRowsInTable("roles");
    int updatedAuthorityRows = countRowsInTable("authorities");
    assertThat("Expected session flush for first insert", updatedRoleRows, equalTo(originalRoleRows + 1));
    assertThat("Unexpected data in authorities", updatedAuthorityRows, equalTo(originalAuthorityRows + 1));

    // Perform an update to the Role that should not update authorities
    expected.setDescription("An updated test role");
    expected=testObject.saveOrUpdate(expected);
    testObject.flush();

    // Session flush: Expect no change to roles, authorities
    updatedRoleRows = countRowsInTable("roles");
View Full Code Here


    // Create the User for authenticated access
    User adminUser = setUpTrentHmacAuthenticator();
    adminUser.setId(1L);

    // Create the supporting Role
    Role customerRole = DatabaseLoader.buildCustomerRole();

    // Create some Customers
    User aliceUser = DatabaseLoader.buildAliceCustomer(customerRole);
    aliceUser.setId(1L);
    aliceUser.getCustomer().setId(1L);
View Full Code Here

  CustomerReadService testObject;

  @Test
  public void testPersistAndFind() {

    Role customerRole = DatabaseLoader.buildCustomerRole();
    User aliceUser = DatabaseLoader.buildAliceCustomer(customerRole);

    Customer expected = aliceUser.getCustomer();

    // Persist with insert
View Full Code Here

    @RestrictedTo({Authority.ROLE_ADMIN})
    User adminUser,
    AdminCreateRoleDto createRoleRequest) {

    // Build a role from the given request information
    Role role = RoleBuilder.newInstance()
      .withName(createRoleRequest.getName())
      .withDescription(createRoleRequest.getDescription())
      .build();

    // Perform basic verification
    Optional<Role> verificationRole = roleReadService.getByName(role.getName());
    ResourceAsserts.assertNotConflicted(verificationRole,"role");

    // Persist the role
    Role persistentRole = roleReadService.saveOrUpdate(role);

    // Provide a representation to the client
    Representation representation = new AdminRoleRepresentation().get(persistentRole);
    URI location = uriInfo.getAbsolutePathBuilder().path(persistentRole.getId().toString()).build();

    return created(representation, location);

  }
View Full Code Here

    // Retrieve the role
    Optional<Role> role = roleReadService.getById(roleId);
    ResourceAsserts.assertPresent(role, "role");

    // Verify and apply any changes to the Role
    Role persistentRole = role.get();
    persistentRole.setName(updateRoleRequest.getName());
    persistentRole.setDescription(updateRoleRequest.getDescription());
    // TODO Re-instate this (needs an update to the request)
//    for (String authorityName : updateRoleRequest.getAuthorities()) {
//      try {
//        Authority authority = Authority.valueOf(authorityName.toUpperCase());
//        persistentRole.getAuthorities().add(authority);
View Full Code Here

    // Retrieve the role
    Optional<Role> role = roleReadService.getById(roleId);
    ResourceAsserts.assertPresent(role,"role");

    // Verify and apply any changes to the Role
    Role persistentRole = role.get();
    persistentRole.setDeleted(true);
    persistentRole.setReasonForDelete(deleteEntityRequest.getReason());

    // Persist the updated role
    persistentRole = roleReadService.saveOrUpdate(role.get());

    // Provide a representation to the client
View Full Code Here

TOP

Related Classes of org.multibit.mbm.client.domain.model.model.Role

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.