more integration tests
This commit is contained in:
parent
76c08bb5c6
commit
f69176cc23
4 changed files with 336 additions and 6 deletions
|
@ -75,6 +75,7 @@ public class LmsSetupController extends ActivatableEntityController<LmsSetup, Lm
|
||||||
@RequestMapping(
|
@RequestMapping(
|
||||||
path = API.LMS_SETUP_TEST_PATH_SEGMENT + API.MODEL_ID_VAR_PATH_SEGMENT,
|
path = API.LMS_SETUP_TEST_PATH_SEGMENT + API.MODEL_ID_VAR_PATH_SEGMENT,
|
||||||
method = RequestMethod.GET,
|
method = RequestMethod.GET,
|
||||||
|
consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE,
|
||||||
produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
||||||
public LmsSetupTestResult connectionReport(
|
public LmsSetupTestResult connectionReport(
|
||||||
@RequestParam(
|
@RequestParam(
|
||||||
|
|
|
@ -112,6 +112,10 @@ public abstract class AdministrationAPIIntegrationTester {
|
||||||
return obtainAccessToken("examAdmin1", "admin");
|
return obtainAccessToken("examAdmin1", "admin");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected RestAPITestHelper restAPITestHelper() {
|
||||||
|
return new RestAPITestHelper();
|
||||||
|
}
|
||||||
|
|
||||||
protected class RestAPITestHelper {
|
protected class RestAPITestHelper {
|
||||||
|
|
||||||
private String path = "";
|
private String path = "";
|
||||||
|
|
|
@ -25,8 +25,10 @@ import ch.ethz.seb.sebserver.gbl.api.APIMessage;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.Domain;
|
import ch.ethz.seb.sebserver.gbl.model.Domain;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.EntityName;
|
import ch.ethz.seb.sebserver.gbl.model.EntityName;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.EntityProcessingReport;
|
import ch.ethz.seb.sebserver.gbl.model.EntityProcessingReport;
|
||||||
|
import ch.ethz.seb.sebserver.gbl.model.Page;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup;
|
import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup.LmsType;
|
import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup.LmsType;
|
||||||
|
import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetupTestResult;
|
||||||
|
|
||||||
@Sql(scripts = { "classpath:schema-test.sql", "classpath:data-test.sql" })
|
@Sql(scripts = { "classpath:schema-test.sql", "classpath:data-test.sql" })
|
||||||
public class LmsSetupAPITest extends AdministrationAPIIntegrationTester {
|
public class LmsSetupAPITest extends AdministrationAPIIntegrationTester {
|
||||||
|
@ -87,7 +89,7 @@ public class LmsSetupAPITest extends AdministrationAPIIntegrationTester {
|
||||||
EntityProcessingReport report = new RestAPITestHelper()
|
EntityProcessingReport report = new RestAPITestHelper()
|
||||||
.withAccessToken(getAdminInstitution1Access())
|
.withAccessToken(getAdminInstitution1Access())
|
||||||
.withPath(API.LMS_SETUP_ENDPOINT)
|
.withPath(API.LMS_SETUP_ENDPOINT)
|
||||||
.withPath("/").withPath(String.valueOf(lmsSetup.id)).withPath("/active")
|
.withPath(String.valueOf(lmsSetup.id)).withPath("/active")
|
||||||
.withMethod(HttpMethod.POST)
|
.withMethod(HttpMethod.POST)
|
||||||
.withExpectedStatus(HttpStatus.OK)
|
.withExpectedStatus(HttpStatus.OK)
|
||||||
.getAsObject(new TypeReference<EntityProcessingReport>() {
|
.getAsObject(new TypeReference<EntityProcessingReport>() {
|
||||||
|
@ -103,7 +105,7 @@ public class LmsSetupAPITest extends AdministrationAPIIntegrationTester {
|
||||||
// get
|
// get
|
||||||
lmsSetup = new RestAPITestHelper()
|
lmsSetup = new RestAPITestHelper()
|
||||||
.withAccessToken(getAdminInstitution1Access())
|
.withAccessToken(getAdminInstitution1Access())
|
||||||
.withPath(API.LMS_SETUP_ENDPOINT).withPath("/")
|
.withPath(API.LMS_SETUP_ENDPOINT)
|
||||||
.withPath(String.valueOf(lmsSetup.id))
|
.withPath(String.valueOf(lmsSetup.id))
|
||||||
.withMethod(HttpMethod.GET)
|
.withMethod(HttpMethod.GET)
|
||||||
.withExpectedStatus(HttpStatus.OK)
|
.withExpectedStatus(HttpStatus.OK)
|
||||||
|
@ -117,7 +119,7 @@ public class LmsSetupAPITest extends AdministrationAPIIntegrationTester {
|
||||||
report = new RestAPITestHelper()
|
report = new RestAPITestHelper()
|
||||||
.withAccessToken(getAdminInstitution1Access())
|
.withAccessToken(getAdminInstitution1Access())
|
||||||
.withPath(API.LMS_SETUP_ENDPOINT)
|
.withPath(API.LMS_SETUP_ENDPOINT)
|
||||||
.withPath("/").withPath(String.valueOf(lmsSetup.id)).withPath("/inactive")
|
.withPath(String.valueOf(lmsSetup.id)).withPath("/inactive")
|
||||||
.withMethod(HttpMethod.POST)
|
.withMethod(HttpMethod.POST)
|
||||||
.withExpectedStatus(HttpStatus.OK)
|
.withExpectedStatus(HttpStatus.OK)
|
||||||
.getAsObject(new TypeReference<EntityProcessingReport>() {
|
.getAsObject(new TypeReference<EntityProcessingReport>() {
|
||||||
|
@ -132,7 +134,7 @@ public class LmsSetupAPITest extends AdministrationAPIIntegrationTester {
|
||||||
|
|
||||||
lmsSetup = new RestAPITestHelper()
|
lmsSetup = new RestAPITestHelper()
|
||||||
.withAccessToken(getAdminInstitution1Access())
|
.withAccessToken(getAdminInstitution1Access())
|
||||||
.withPath(API.LMS_SETUP_ENDPOINT).withPath("/")
|
.withPath(API.LMS_SETUP_ENDPOINT)
|
||||||
.withPath(String.valueOf(lmsSetup.id))
|
.withPath(String.valueOf(lmsSetup.id))
|
||||||
.withMethod(HttpMethod.GET)
|
.withMethod(HttpMethod.GET)
|
||||||
.withExpectedStatus(HttpStatus.OK)
|
.withExpectedStatus(HttpStatus.OK)
|
||||||
|
@ -146,7 +148,7 @@ public class LmsSetupAPITest extends AdministrationAPIIntegrationTester {
|
||||||
report = new RestAPITestHelper()
|
report = new RestAPITestHelper()
|
||||||
.withAccessToken(getAdminInstitution1Access())
|
.withAccessToken(getAdminInstitution1Access())
|
||||||
.withPath(API.LMS_SETUP_ENDPOINT)
|
.withPath(API.LMS_SETUP_ENDPOINT)
|
||||||
.withPath("/").withPath(String.valueOf(lmsSetup.id))
|
.withPath(String.valueOf(lmsSetup.id))
|
||||||
.withMethod(HttpMethod.DELETE)
|
.withMethod(HttpMethod.DELETE)
|
||||||
.withExpectedStatus(HttpStatus.OK)
|
.withExpectedStatus(HttpStatus.OK)
|
||||||
.getAsObject(new TypeReference<EntityProcessingReport>() {
|
.getAsObject(new TypeReference<EntityProcessingReport>() {
|
||||||
|
@ -162,7 +164,7 @@ public class LmsSetupAPITest extends AdministrationAPIIntegrationTester {
|
||||||
// get
|
// get
|
||||||
final List<APIMessage> error = new RestAPITestHelper()
|
final List<APIMessage> error = new RestAPITestHelper()
|
||||||
.withAccessToken(getAdminInstitution1Access())
|
.withAccessToken(getAdminInstitution1Access())
|
||||||
.withPath(API.LMS_SETUP_ENDPOINT).withPath("/")
|
.withPath(API.LMS_SETUP_ENDPOINT)
|
||||||
.withPath(String.valueOf(lmsSetup.id))
|
.withPath(String.valueOf(lmsSetup.id))
|
||||||
.withMethod(HttpMethod.GET)
|
.withMethod(HttpMethod.GET)
|
||||||
.withExpectedStatus(HttpStatus.NOT_FOUND)
|
.withExpectedStatus(HttpStatus.NOT_FOUND)
|
||||||
|
@ -316,4 +318,153 @@ public class LmsSetupAPITest extends AdministrationAPIIntegrationTester {
|
||||||
.getAsString();
|
.getAsString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testInstituionalView() throws Exception {
|
||||||
|
// create new LmsSetup Mock with seb-admin
|
||||||
|
final LmsSetup lmsSetup1 = new RestAPITestHelper()
|
||||||
|
.withAccessToken(getSebAdminAccess())
|
||||||
|
.withPath(API.LMS_SETUP_ENDPOINT)
|
||||||
|
.withMethod(HttpMethod.POST)
|
||||||
|
.withAttribute(Domain.LMS_SETUP.ATTR_NAME, "new LmsSetup 1")
|
||||||
|
.withAttribute(Domain.LMS_SETUP.ATTR_LMS_TYPE, LmsType.MOCKUP.name())
|
||||||
|
.withExpectedStatus(HttpStatus.OK)
|
||||||
|
.getAsObject(new TypeReference<LmsSetup>() {
|
||||||
|
});
|
||||||
|
|
||||||
|
// create new LmsSetup Mock with institutional 2 admin
|
||||||
|
final LmsSetup lmsSetup2 = new RestAPITestHelper()
|
||||||
|
.withAccessToken(getAdminInstitution2Access())
|
||||||
|
.withPath(API.LMS_SETUP_ENDPOINT)
|
||||||
|
.withMethod(HttpMethod.POST)
|
||||||
|
.withAttribute(Domain.LMS_SETUP.ATTR_NAME, "new LmsSetup 1")
|
||||||
|
.withAttribute(Domain.LMS_SETUP.ATTR_LMS_TYPE, LmsType.MOCKUP.name())
|
||||||
|
.withExpectedStatus(HttpStatus.OK)
|
||||||
|
.getAsObject(new TypeReference<LmsSetup>() {
|
||||||
|
});
|
||||||
|
|
||||||
|
// get with institutional 1 admin, expected to see only the one created by seb-admin
|
||||||
|
Page<LmsSetup> lmsSetups = new RestAPITestHelper()
|
||||||
|
.withAccessToken(getAdminInstitution1Access())
|
||||||
|
.withPath(API.LMS_SETUP_ENDPOINT)
|
||||||
|
.withExpectedStatus(HttpStatus.OK)
|
||||||
|
.getAsObject(new TypeReference<Page<LmsSetup>>() {
|
||||||
|
});
|
||||||
|
|
||||||
|
assertNotNull(lmsSetups);
|
||||||
|
assertNotNull(lmsSetups.content);
|
||||||
|
assertTrue(lmsSetups.content.size() == 1);
|
||||||
|
LmsSetup lmsSetup = lmsSetups.content.get(0);
|
||||||
|
assertEquals(lmsSetup1.id, lmsSetup.id);
|
||||||
|
|
||||||
|
// get with institutional 2 admin, expected to see only the one self created
|
||||||
|
lmsSetups = new RestAPITestHelper()
|
||||||
|
.withAccessToken(getAdminInstitution2Access())
|
||||||
|
.withPath(API.LMS_SETUP_ENDPOINT)
|
||||||
|
.withExpectedStatus(HttpStatus.OK)
|
||||||
|
.getAsObject(new TypeReference<Page<LmsSetup>>() {
|
||||||
|
});
|
||||||
|
|
||||||
|
assertNotNull(lmsSetups);
|
||||||
|
assertNotNull(lmsSetups.content);
|
||||||
|
assertTrue(lmsSetups.content.size() == 1);
|
||||||
|
lmsSetup = lmsSetups.content.get(0);
|
||||||
|
assertEquals(lmsSetup2.id, lmsSetup.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testLmsSetupConnectionTest() throws Exception {
|
||||||
|
// create new LmsSetup Mock with seb-admin
|
||||||
|
LmsSetup lmsSetup = new RestAPITestHelper()
|
||||||
|
.withAccessToken(getSebAdminAccess())
|
||||||
|
.withPath(API.LMS_SETUP_ENDPOINT)
|
||||||
|
.withMethod(HttpMethod.POST)
|
||||||
|
.withAttribute(Domain.LMS_SETUP.ATTR_NAME, "new LmsSetup 1")
|
||||||
|
.withAttribute(Domain.LMS_SETUP.ATTR_LMS_TYPE, LmsType.MOCKUP.name())
|
||||||
|
.withExpectedStatus(HttpStatus.OK)
|
||||||
|
.getAsObject(new TypeReference<LmsSetup>() {
|
||||||
|
});
|
||||||
|
|
||||||
|
// test LMS connection should fail because there is no server set yet
|
||||||
|
List<APIMessage> errors = new RestAPITestHelper()
|
||||||
|
.withAccessToken(getSebAdminAccess())
|
||||||
|
.withPath(API.LMS_SETUP_ENDPOINT)
|
||||||
|
.withPath(API.LMS_SETUP_TEST_PATH_SEGMENT)
|
||||||
|
.withPath(lmsSetup.getModelId())
|
||||||
|
.withMethod(HttpMethod.GET)
|
||||||
|
.withExpectedStatus(HttpStatus.BAD_REQUEST)
|
||||||
|
.getAsObject(new TypeReference<List<APIMessage>>() {
|
||||||
|
});
|
||||||
|
|
||||||
|
assertNotNull(errors);
|
||||||
|
assertTrue(errors.size() == 3);
|
||||||
|
|
||||||
|
// save (wrong) LMS server and credentials
|
||||||
|
lmsSetup = new LmsSetup(
|
||||||
|
lmsSetup.id,
|
||||||
|
lmsSetup.institutionId,
|
||||||
|
lmsSetup.name,
|
||||||
|
lmsSetup.lmsType,
|
||||||
|
"lms1Name",
|
||||||
|
null, // no secret
|
||||||
|
"https://www.lms1.com",
|
||||||
|
null,
|
||||||
|
null);
|
||||||
|
lmsSetup = new RestAPITestHelper()
|
||||||
|
.withAccessToken(getAdminInstitution1Access())
|
||||||
|
.withPath(API.LMS_SETUP_ENDPOINT)
|
||||||
|
.withMethod(HttpMethod.PUT)
|
||||||
|
.withBodyJson(lmsSetup)
|
||||||
|
.withExpectedStatus(HttpStatus.OK)
|
||||||
|
.getAsObject(new TypeReference<LmsSetup>() {
|
||||||
|
});
|
||||||
|
|
||||||
|
// test LMS connection again should fail because there is no secret set
|
||||||
|
errors = new RestAPITestHelper()
|
||||||
|
.withAccessToken(getSebAdminAccess())
|
||||||
|
.withPath(API.LMS_SETUP_ENDPOINT)
|
||||||
|
.withPath(API.LMS_SETUP_TEST_PATH_SEGMENT)
|
||||||
|
.withPath(lmsSetup.getModelId())
|
||||||
|
.withMethod(HttpMethod.GET)
|
||||||
|
.withExpectedStatus(HttpStatus.BAD_REQUEST)
|
||||||
|
.getAsObject(new TypeReference<List<APIMessage>>() {
|
||||||
|
});
|
||||||
|
|
||||||
|
assertNotNull(errors);
|
||||||
|
assertTrue(errors.size() == 1);
|
||||||
|
assertEquals("[lmsSetup, lmsClientsecret, notNull]", String.valueOf(errors.get(0).attributes));
|
||||||
|
|
||||||
|
// save correct LMS server and credentials
|
||||||
|
lmsSetup = new LmsSetup(
|
||||||
|
lmsSetup.id,
|
||||||
|
lmsSetup.institutionId,
|
||||||
|
lmsSetup.name,
|
||||||
|
lmsSetup.lmsType,
|
||||||
|
"lms1Name",
|
||||||
|
"someSecret",
|
||||||
|
"https://www.lms1.com",
|
||||||
|
null,
|
||||||
|
null);
|
||||||
|
lmsSetup = new RestAPITestHelper()
|
||||||
|
.withAccessToken(getAdminInstitution1Access())
|
||||||
|
.withPath(API.LMS_SETUP_ENDPOINT)
|
||||||
|
.withMethod(HttpMethod.PUT)
|
||||||
|
.withBodyJson(lmsSetup)
|
||||||
|
.withExpectedStatus(HttpStatus.OK)
|
||||||
|
.getAsObject(new TypeReference<LmsSetup>() {
|
||||||
|
});
|
||||||
|
|
||||||
|
final LmsSetupTestResult testResult = new RestAPITestHelper()
|
||||||
|
.withAccessToken(getSebAdminAccess())
|
||||||
|
.withPath(API.LMS_SETUP_ENDPOINT)
|
||||||
|
.withPath(API.LMS_SETUP_TEST_PATH_SEGMENT)
|
||||||
|
.withPath(lmsSetup.getModelId())
|
||||||
|
.withMethod(HttpMethod.GET)
|
||||||
|
.withExpectedStatus(HttpStatus.OK)
|
||||||
|
.getAsObject(new TypeReference<LmsSetupTestResult>() {
|
||||||
|
});
|
||||||
|
|
||||||
|
assertNotNull(testResult);
|
||||||
|
assertTrue(testResult.getOkStatus());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,174 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 ETH Zürich, Educational Development and Technology (LET)
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package ch.ethz.seb.sebserver.webservice.integration.api.admin;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.springframework.http.HttpMethod;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.test.context.jdbc.Sql;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
|
|
||||||
|
import ch.ethz.seb.sebserver.gbl.api.API;
|
||||||
|
import ch.ethz.seb.sebserver.gbl.model.Domain;
|
||||||
|
import ch.ethz.seb.sebserver.gbl.model.EntityProcessingReport;
|
||||||
|
import ch.ethz.seb.sebserver.gbl.model.Page;
|
||||||
|
import ch.ethz.seb.sebserver.gbl.model.exam.QuizData;
|
||||||
|
import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup;
|
||||||
|
import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup.LmsType;
|
||||||
|
|
||||||
|
@Sql(scripts = { "classpath:schema-test.sql", "classpath:data-test.sql" })
|
||||||
|
public class QuizDataTest extends AdministrationAPIIntegrationTester {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetInstitutionalQuizPage() throws Exception {
|
||||||
|
// create new active LmsSetup Mock with seb-admin
|
||||||
|
final LmsSetup lmsSetup1 = createLmsSetupMockWith(
|
||||||
|
this,
|
||||||
|
getSebAdminAccess(),
|
||||||
|
"new LmsSetup 1",
|
||||||
|
true);
|
||||||
|
|
||||||
|
assertNotNull(lmsSetup1);
|
||||||
|
assertTrue(lmsSetup1.isActive());
|
||||||
|
|
||||||
|
// create new inactive LmsSetup Mock with institution 2 admin
|
||||||
|
final LmsSetup lmsSetup2 = createLmsSetupMockWith(
|
||||||
|
this,
|
||||||
|
getAdminInstitution2Access(),
|
||||||
|
"new LmsSetup 2",
|
||||||
|
false);
|
||||||
|
|
||||||
|
assertNotNull(lmsSetup2);
|
||||||
|
assertFalse(lmsSetup2.isActive());
|
||||||
|
|
||||||
|
// for the active LmsSetup we should get the quizzes page but only the quizzes from LmsSetup of seb-admin
|
||||||
|
Page<QuizData> quizzes = new RestAPITestHelper()
|
||||||
|
.withAccessToken(getSebAdminAccess())
|
||||||
|
.withPath(API.QUIZ_DISCOVERY_ENDPOINT)
|
||||||
|
.withExpectedStatus(HttpStatus.OK)
|
||||||
|
.getAsObject(new TypeReference<Page<QuizData>>() {
|
||||||
|
});
|
||||||
|
|
||||||
|
assertNotNull(quizzes);
|
||||||
|
assertTrue(quizzes.content.size() == 5);
|
||||||
|
|
||||||
|
// for the inactive LmsSetup we should'nt get any quizzes
|
||||||
|
quizzes = new RestAPITestHelper()
|
||||||
|
.withAccessToken(getAdminInstitution2Access())
|
||||||
|
.withPath(API.QUIZ_DISCOVERY_ENDPOINT)
|
||||||
|
.withExpectedStatus(HttpStatus.OK)
|
||||||
|
.getAsObject(new TypeReference<Page<QuizData>>() {
|
||||||
|
});
|
||||||
|
|
||||||
|
assertNotNull(quizzes);
|
||||||
|
assertTrue(quizzes.content.size() == 0);
|
||||||
|
|
||||||
|
// activate / deactivate
|
||||||
|
new RestAPITestHelper()
|
||||||
|
.withAccessToken(getSebAdminAccess())
|
||||||
|
.withPath(API.LMS_SETUP_ENDPOINT)
|
||||||
|
.withPath(String.valueOf(lmsSetup1.id)).withPath("/inactive")
|
||||||
|
.withMethod(HttpMethod.POST)
|
||||||
|
.withExpectedStatus(HttpStatus.OK)
|
||||||
|
.getAsObject(new TypeReference<EntityProcessingReport>() {
|
||||||
|
});
|
||||||
|
new RestAPITestHelper()
|
||||||
|
.withAccessToken(getAdminInstitution2Access())
|
||||||
|
.withPath(API.LMS_SETUP_ENDPOINT)
|
||||||
|
.withPath(String.valueOf(lmsSetup2.id)).withPath("/active")
|
||||||
|
.withMethod(HttpMethod.POST)
|
||||||
|
.withExpectedStatus(HttpStatus.OK)
|
||||||
|
.getAsObject(new TypeReference<EntityProcessingReport>() {
|
||||||
|
});
|
||||||
|
|
||||||
|
// now we should not get any quizzes for the seb-admin
|
||||||
|
quizzes = new RestAPITestHelper()
|
||||||
|
.withAccessToken(getSebAdminAccess())
|
||||||
|
.withPath(API.QUIZ_DISCOVERY_ENDPOINT)
|
||||||
|
.withExpectedStatus(HttpStatus.OK)
|
||||||
|
.getAsObject(new TypeReference<Page<QuizData>>() {
|
||||||
|
});
|
||||||
|
|
||||||
|
assertNotNull(quizzes);
|
||||||
|
assertTrue(quizzes.content.size() == 0);
|
||||||
|
|
||||||
|
// but for the now active lmsSetup2 we should get the quizzes
|
||||||
|
quizzes = new RestAPITestHelper()
|
||||||
|
.withAccessToken(getAdminInstitution2Access())
|
||||||
|
.withPath(API.QUIZ_DISCOVERY_ENDPOINT)
|
||||||
|
.withExpectedStatus(HttpStatus.OK)
|
||||||
|
.getAsObject(new TypeReference<Page<QuizData>>() {
|
||||||
|
});
|
||||||
|
|
||||||
|
assertNotNull(quizzes);
|
||||||
|
assertTrue(quizzes.content.size() == 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final LmsSetup createLmsSetupMockWith(
|
||||||
|
final AdministrationAPIIntegrationTester tester,
|
||||||
|
final String token,
|
||||||
|
final String name,
|
||||||
|
final boolean active) throws Exception {
|
||||||
|
|
||||||
|
LmsSetup lmsSetup = tester.restAPITestHelper()
|
||||||
|
.withAccessToken(token)
|
||||||
|
.withPath(API.LMS_SETUP_ENDPOINT)
|
||||||
|
.withMethod(HttpMethod.POST)
|
||||||
|
.withAttribute(Domain.LMS_SETUP.ATTR_NAME, name)
|
||||||
|
.withAttribute(Domain.LMS_SETUP.ATTR_LMS_TYPE, LmsType.MOCKUP.name())
|
||||||
|
.withExpectedStatus(HttpStatus.OK)
|
||||||
|
.getAsObject(new TypeReference<LmsSetup>() {
|
||||||
|
});
|
||||||
|
|
||||||
|
lmsSetup = new LmsSetup(
|
||||||
|
lmsSetup.id,
|
||||||
|
lmsSetup.institutionId,
|
||||||
|
lmsSetup.name,
|
||||||
|
lmsSetup.lmsType,
|
||||||
|
"lms1Name",
|
||||||
|
"somePW",
|
||||||
|
"https://www.lms1.com",
|
||||||
|
null,
|
||||||
|
null);
|
||||||
|
|
||||||
|
lmsSetup = tester.restAPITestHelper()
|
||||||
|
.withAccessToken(token)
|
||||||
|
.withPath(API.LMS_SETUP_ENDPOINT)
|
||||||
|
.withMethod(HttpMethod.PUT)
|
||||||
|
.withBodyJson(lmsSetup)
|
||||||
|
.withExpectedStatus(HttpStatus.OK)
|
||||||
|
.getAsObject(new TypeReference<LmsSetup>() {
|
||||||
|
});
|
||||||
|
|
||||||
|
if (active) {
|
||||||
|
final EntityProcessingReport report = tester.restAPITestHelper()
|
||||||
|
.withAccessToken(token)
|
||||||
|
.withPath(API.LMS_SETUP_ENDPOINT)
|
||||||
|
.withPath(String.valueOf(lmsSetup.id)).withPath("/active")
|
||||||
|
.withMethod(HttpMethod.POST)
|
||||||
|
.withExpectedStatus(HttpStatus.OK)
|
||||||
|
.getAsObject(new TypeReference<EntityProcessingReport>() {
|
||||||
|
});
|
||||||
|
assertTrue(report.errors.isEmpty());
|
||||||
|
return tester.restAPITestHelper()
|
||||||
|
.withAccessToken(token)
|
||||||
|
.withPath(API.LMS_SETUP_ENDPOINT)
|
||||||
|
.withPath(String.valueOf(lmsSetup.id))
|
||||||
|
.withMethod(HttpMethod.GET)
|
||||||
|
.withExpectedStatus(HttpStatus.OK)
|
||||||
|
.getAsObject(new TypeReference<LmsSetup>() {
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return lmsSetup;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue