Search in sources :

Example 21 with Role

use of fi.otavanopisto.pyramus.domainmodel.users.Role in project pyramus by otavanopisto.

the class MuikkuRestServiceTestsIT method testUpdateStaffMember.

@Test
public void testUpdateStaffMember() {
    Role testStaffMemberRole = Role.TEACHER;
    StaffMemberPayload payload = new StaffMemberPayload();
    payload.setIdentifier(null);
    payload.setRole(testStaffMemberRole.toString());
    payload.setFirstName("Muikku");
    payload.setLastName("Manager");
    payload.setEmail("muikkumanager@example.com");
    Response response = given().headers(getAuthHeaders()).contentType("application/json").body(payload).post("/muikku/users");
    response.then().statusCode(200).body("identifier", not(is((Long) null))).body("firstName", is(payload.getFirstName())).body("lastName", is(payload.getLastName())).body("email", is(payload.getEmail())).body("role", is(testStaffMemberRole.toString()));
    long staffMemberId = response.body().jsonPath().getLong("identifier");
    long personId = getStaffMemberPersonId(staffMemberId);
    try {
        Role testUpdatedStaffMemberRole = Role.MANAGER;
        payload = new StaffMemberPayload();
        payload.setIdentifier(String.valueOf(staffMemberId));
        payload.setRole(testUpdatedStaffMemberRole.toString());
        payload.setFirstName("Muikku");
        payload.setLastName("Manager");
        payload.setEmail("muikkumanager@example.com");
        given().headers(getAuthHeaders()).contentType("application/json").body(payload).put("/muikku/users/{ID}", staffMemberId).then().statusCode(200).body("identifier", is(payload.getIdentifier())).body("firstName", is(payload.getFirstName())).body("lastName", is(payload.getLastName())).body("email", is(payload.getEmail())).body("role", is(testUpdatedStaffMemberRole.toString()));
    } finally {
        given().headers(getAuthHeaders()).delete("/staff/members/{ID}?permanent=true", staffMemberId).then().statusCode(204);
        given().headers(getAuthHeaders()).delete("/persons/persons/{ID}", personId).then().statusCode(204);
    }
}
Also used : Role(fi.otavanopisto.pyramus.domainmodel.users.Role) Response(io.restassured.response.Response) StaffMemberPayload(fi.otavanopisto.pyramus.rest.model.muikku.StaffMemberPayload) Test(org.junit.Test)

Aggregations

Role (fi.otavanopisto.pyramus.domainmodel.users.Role)21 StaffMember (fi.otavanopisto.pyramus.domainmodel.users.StaffMember)9 UserRole (fi.otavanopisto.pyramus.framework.UserRole)7 StaffMemberDAO (fi.otavanopisto.pyramus.dao.users.StaffMemberDAO)5 User (fi.otavanopisto.pyramus.domainmodel.users.User)5 Organization (fi.otavanopisto.pyramus.domainmodel.base.Organization)4 EnvironmentRolePermission (fi.otavanopisto.pyramus.domainmodel.security.EnvironmentRolePermission)4 Permission (fi.otavanopisto.pyramus.domainmodel.security.Permission)4 Response (io.restassured.response.Response)4 SmvcRuntimeException (fi.internetix.smvc.SmvcRuntimeException)3 EmailDAO (fi.otavanopisto.pyramus.dao.base.EmailDAO)3 PersonDAO (fi.otavanopisto.pyramus.dao.base.PersonDAO)3 UserIdentificationDAO (fi.otavanopisto.pyramus.dao.users.UserIdentificationDAO)3 Person (fi.otavanopisto.pyramus.domainmodel.base.Person)3 StaffMemberPayload (fi.otavanopisto.pyramus.rest.model.muikku.StaffMemberPayload)3 ArrayList (java.util.ArrayList)3 Test (org.junit.Test)3 AddressDAO (fi.otavanopisto.pyramus.dao.base.AddressDAO)2 ContactTypeDAO (fi.otavanopisto.pyramus.dao.base.ContactTypeDAO)2 OrganizationDAO (fi.otavanopisto.pyramus.dao.base.OrganizationDAO)2