Search in sources :

Example 1 with AcademicTerm

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);
}
Also used : Response(io.restassured.response.Response) AcademicTerm(fi.otavanopisto.pyramus.rest.model.AcademicTerm) Test(org.junit.Test)

Example 2 with AcademicTerm

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);
}
Also used : Response(io.restassured.response.Response) AcademicTerm(fi.otavanopisto.pyramus.rest.model.AcademicTerm) OffsetDateTime(java.time.OffsetDateTime) Test(org.junit.Test)

Example 3 with AcademicTerm

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);
    }
}
Also used : Response(io.restassured.response.Response) AcademicTerm(fi.otavanopisto.pyramus.rest.model.AcademicTerm) Test(org.junit.Test)

Example 4 with AcademicTerm

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);
}
Also used : Response(io.restassured.response.Response) AcademicTerm(fi.otavanopisto.pyramus.rest.model.AcademicTerm) Test(org.junit.Test)

Example 5 with AcademicTerm

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);
}
Also used : Response(io.restassured.response.Response) AcademicTerm(fi.otavanopisto.pyramus.rest.model.AcademicTerm) Test(org.junit.Test)

Aggregations

AcademicTerm (fi.otavanopisto.pyramus.rest.model.AcademicTerm)9 Response (io.restassured.response.Response)8 Test (org.junit.Test)8 OffsetDateTime (java.time.OffsetDateTime)2 Address (fi.otavanopisto.pyramus.domainmodel.base.Address)1 BillingDetails (fi.otavanopisto.pyramus.domainmodel.base.BillingDetails)1 ContactType (fi.otavanopisto.pyramus.domainmodel.base.ContactType)1 ContactURL (fi.otavanopisto.pyramus.domainmodel.base.ContactURL)1 ContactURLType (fi.otavanopisto.pyramus.domainmodel.base.ContactURLType)1 CourseBaseVariable (fi.otavanopisto.pyramus.domainmodel.base.CourseBaseVariable)1 CourseBaseVariableKey (fi.otavanopisto.pyramus.domainmodel.base.CourseBaseVariableKey)1 CourseEducationSubtype (fi.otavanopisto.pyramus.domainmodel.base.CourseEducationSubtype)1 CourseEducationType (fi.otavanopisto.pyramus.domainmodel.base.CourseEducationType)1 EducationSubtype (fi.otavanopisto.pyramus.domainmodel.base.EducationSubtype)1 EducationType (fi.otavanopisto.pyramus.domainmodel.base.EducationType)1 EducationalTimeUnit (fi.otavanopisto.pyramus.domainmodel.base.EducationalTimeUnit)1 Email (fi.otavanopisto.pyramus.domainmodel.base.Email)1 Language (fi.otavanopisto.pyramus.domainmodel.base.Language)1 Municipality (fi.otavanopisto.pyramus.domainmodel.base.Municipality)1 Nationality (fi.otavanopisto.pyramus.domainmodel.base.Nationality)1