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);
}
}
Aggregations