use of fi.otavanopisto.pyramus.rest.model.AcademicTerm in project pyramus by otavanopisto.
the class AcademicTermTestsIT method testDeleteAcademicTerm.
@Test
public void testDeleteAcademicTerm() {
AcademicTerm academicTerm = new AcademicTerm(null, "to be deleted", getDate(2010, 02, 03), getDate(2010, 06, 12), Boolean.FALSE);
Response response = given().headers(getAuthHeaders()).contentType("application/json").body(academicTerm).post("/calendar/academicTerms");
Long id = new Long(response.body().jsonPath().getInt("id"));
assertNotNull(id);
given().headers(getAuthHeaders()).get("/calendar/academicTerms/{ID}", id).then().statusCode(200);
given().headers(getAuthHeaders()).delete("/calendar/academicTerms/{ID}", id).then().statusCode(204);
given().headers(getAuthHeaders()).get("/calendar/academicTerms/{ID}", id).then().statusCode(404);
given().headers(getAuthHeaders()).delete("/calendar/academicTerms/{ID}?permanent=true", id).then().statusCode(204);
given().headers(getAuthHeaders()).get("/calendar/academicTerms/{ID}", id).then().statusCode(404);
}
use of fi.otavanopisto.pyramus.rest.model.AcademicTerm in project pyramus by otavanopisto.
the class AcademicTermTestsIT method testCreateAcadmicTerm.
@Test
public void testCreateAcadmicTerm() {
OffsetDateTime start = getDate(2010, 02, 03);
OffsetDateTime end = getDate(2010, 06, 12);
AcademicTerm academicTerm = new AcademicTerm(null, "create test", start, end, Boolean.FALSE);
Response response = given().headers(getAuthHeaders()).contentType("application/json").body(academicTerm).post("/calendar/academicTerms");
response.then().body("id", not(is((Long) null))).body("name", is(academicTerm.getName())).body("startDate", is(academicTerm.getStartDate().toString())).body("endDate", is(academicTerm.getEndDate().toString())).body("archived", is(academicTerm.getArchived()));
int id = response.body().jsonPath().getInt("id");
given().headers(getAuthHeaders()).delete("/calendar/academicTerms/{ID}?permanent=true", id).then().statusCode(204);
}
use of fi.otavanopisto.pyramus.rest.model.AcademicTerm in project pyramus by otavanopisto.
the class CalendarPermissionsTestsIT method testPermissionsUpdateAcademicTerm.
@Test
public void testPermissionsUpdateAcademicTerm() throws NoSuchFieldException {
AcademicTerm academicTerm = new AcademicTerm(null, "not updated", getDate(2010, 02, 03), getDate(2010, 06, 12), Boolean.FALSE);
Response response = given().headers(getAdminAuthHeaders()).contentType("application/json").body(academicTerm).post("/calendar/academicTerms");
Long id = new Long(response.body().jsonPath().getInt("id"));
try {
response.then().body("id", not(is((Long) null))).body("name", is(academicTerm.getName())).body("startDate", is(academicTerm.getStartDate().toString())).body("endDate", is(academicTerm.getEndDate().toString())).body("archived", is(academicTerm.getArchived()));
AcademicTerm updateAcademicTerm = new AcademicTerm(id, "updated", getDate(2010, 03, 04), getDate(2010, 07, 13), Boolean.FALSE);
Response updateResponse = given().headers(getAuthHeaders()).contentType("application/json").body(updateAcademicTerm).put("/calendar/academicTerms/{ID}", id);
assertOk(updateResponse, calendarPermissions, CalendarPermissions.UPDATE_ACADEMICTERM, 200);
} finally {
given().headers(getAdminAuthHeaders()).delete("/calendar/academicTerms/{ID}?permanent=true", id);
}
}
use of fi.otavanopisto.pyramus.rest.model.AcademicTerm in project pyramus by otavanopisto.
the class CalendarPermissionsTestsIT method testPermissionsCoursesByTerm.
@Test
public void testPermissionsCoursesByTerm() throws NoSuchFieldException {
AcademicTerm academicTerm = new AcademicTerm(null, "2010 spring", getDate(2010, 01, 01), getDate(2010, 06, 1), Boolean.FALSE);
Response response = given().headers(getAdminAuthHeaders()).contentType("application/json").body(academicTerm).post("/calendar/academicTerms");
Long id = new Long(response.body().jsonPath().getInt("id"));
Response courseByTermResponse = given().headers(getAuthHeaders()).get("/calendar/academicTerms/{ID}/courses", id);
assertOk(courseByTermResponse, calendarPermissions, CalendarPermissions.FIND_COURSESBYACADEMICTERM, 200);
given().headers(getAdminAuthHeaders()).delete("/calendar/academicTerms/{ID}?permanent=true", id);
}
use of fi.otavanopisto.pyramus.rest.model.AcademicTerm in project pyramus by otavanopisto.
the class CalendarPermissionsTestsIT method testPermissionsDeleteAcademicTerm.
@Test
public void testPermissionsDeleteAcademicTerm() throws NoSuchFieldException {
AcademicTerm academicTerm = new AcademicTerm(null, "to be deleted", getDate(2010, 02, 03), getDate(2010, 06, 12), Boolean.FALSE);
Response response = given().headers(getAdminAuthHeaders()).contentType("application/json").body(academicTerm).post("/calendar/academicTerms");
Long id = new Long(response.body().jsonPath().getInt("id"));
Response deleteResponse = given().headers(getAuthHeaders()).delete("/calendar/academicTerms/{ID}", id);
assertOk(deleteResponse, calendarPermissions, CalendarPermissions.DELETE_ACADEMICTERM, 204);
given().headers(getAdminAuthHeaders()).delete("/calendar/academicTerms/{ID}?permanent=true", id);
}
Aggregations