use of com.github.tomakehurst.wiremock.matching.EqualToJsonPattern in project nfdiv-case-api by hmcts.
the class CaseDataWireMock method stubForCaseAssignmentRoles.
public static void stubForCaseAssignmentRoles() {
CASE_DATA_SERVER.stubFor(delete(urlMatching("/case-users")).withHeader(HttpHeaders.AUTHORIZATION, new EqualToPattern(BEARER + SYSTEM_UPDATE_AUTH_TOKEN)).withHeader(SERVICE_AUTHORIZATION, new EqualToPattern(AUTH_HEADER_VALUE)).withRequestBody(new EqualToJsonPattern("{\"case_users\":[{\"case_id\":\"1616591401473378\",\"case_role\":\"[CREATOR]\",\"organisation_id\":\"ABC123\"," + "\"user_id\":\"1\"}]}", true, true)).willReturn(aResponse().withStatus(200)));
CASE_DATA_SERVER.stubFor(post(urlMatching("/case-users")).withHeader(HttpHeaders.AUTHORIZATION, new EqualToPattern(BEARER + SYSTEM_UPDATE_AUTH_TOKEN)).withHeader(SERVICE_AUTHORIZATION, new EqualToPattern(AUTH_HEADER_VALUE)).withRequestBody(new EqualToJsonPattern("{\"case_users\":[{\"case_id\":\"1616591401473378\",\"case_role\":\"[APPONESOLICITOR]\",\"organisation_id\":\"ABC123\"," + "\"user_id\":\"1\"}]}", true, true)).willReturn(aResponse().withStatus(200)));
}
use of com.github.tomakehurst.wiremock.matching.EqualToJsonPattern in project muikku by otavanopisto.
the class NewEvaluationTestsBase method evaluateStudentWorkspaceTest.
@Test
@TestEnvironments(browsers = { TestEnvironments.Browser.CHROME, TestEnvironments.Browser.CHROME_HEADLESS, TestEnvironments.Browser.FIREFOX, TestEnvironments.Browser.INTERNET_EXPLORER, TestEnvironments.Browser.EDGE, TestEnvironments.Browser.SAFARI })
public void evaluateStudentWorkspaceTest() throws Exception {
MockStaffMember admin = new MockStaffMember(1l, 1l, 1l, "Admin", "User", UserRole.ADMINISTRATOR, "121212-1234", "admin@example.com", Sex.MALE);
MockStudent student = new MockStudent(2l, 2l, "Student", "Tester", "student@example.com", 1l, OffsetDateTime.of(1990, 2, 2, 0, 0, 0, 0, ZoneOffset.UTC), "121212-1212", Sex.FEMALE, TestUtilities.toDate(2012, 1, 1), TestUtilities.getNextYear());
OffsetDateTime dateNow = OffsetDateTime.of(LocalDateTime.now(), ZoneOffset.UTC);
Course course1 = new CourseBuilder().name("testcourse").id((long) 2).description("test course for testing").buildCourse();
Builder mockBuilder = mocker();
try {
mockBuilder.addStudent(student).addStaffMember(admin).mockLogin(admin).addCourse(course1).build();
Double price = new Double(75);
WorklistBasePriceRestModel courseBasePrices = new WorklistBasePriceRestModel();
courseBasePrices.put(course1.getCourseModules().iterator().next().getId(), price);
login();
Workspace workspace = createWorkspace(course1, Boolean.TRUE);
MockCourseStudent courseStudent = new MockCourseStudent(2l, course1.getId(), student.getId(), TestUtilities.createCourseActivity(course1, CourseActivityState.ONGOING));
CourseStaffMember courseStaffMember = new CourseStaffMember(1l, course1.getId(), admin.getId(), 1l);
mockBuilder.addCourseStaffMember(course1.getId(), courseStaffMember).addCourseStudent(course1.getId(), courseStudent).build();
WorkspaceFolder workspaceFolder1 = createWorkspaceFolder(workspace.getId(), null, Boolean.FALSE, 1, "Test Course material folder", "DEFAULT");
WorkspaceHtmlMaterial htmlMaterial = createWorkspaceHtmlMaterial(workspace.getId(), workspaceFolder1.getId(), "Test", "text/html;editor=CKEditor", "<p><object type=\"application/vnd.muikku.field.text\"><param name=\"type\" value=\"application/json\" /><param name=\"content\" value=\"{"name":"muikku-field-nT0yyez23QwFXD3G0I8HzYeK","rightAnswers":[],"columns":"","hint":""}\" /></object></p>", "EVALUATED");
try {
logout();
mockBuilder.mockLogin(student);
login();
navigate(String.format("/workspace/%s/materials", workspace.getUrlName()), false);
selectFinnishLocale();
waitForVisible(".content-panel__container .content-panel__body .content-panel__item .material-page--assignment .material-page__textfield input");
assertValue(".content-panel__container .content-panel__body .content-panel__item .material-page--assignment .material-page__textfield input", "");
waitAndClick(".content-panel__container .content-panel__body .content-panel__item .material-page--assignment .material-page__textfield input");
waitAndSendKeys(".content-panel__container .content-panel__body .content-panel__item .material-page--assignment .material-page__textfield input", "field value");
waitForPresent(".material-page__textfield-wrapper.state-SAVED");
waitAndClick(".button--muikku-submit-assignment");
waitForElementToBeClickable(".button--muikku-withdraw-assignment");
mockBuilder.mockAssessmentRequests(student.getId(), course1.getId(), courseStudent.getId(), "Hello!", false, false, dateNow).mockCompositeGradingScales().addCompositeCourseAssessmentRequest(student.getId(), course1.getId(), courseStudent.getId(), "Hello!", false, false, course1, student, dateNow).mockCompositeCourseAssessmentRequests().addStaffCompositeAssessmentRequest(student.getId(), course1.getId(), courseStudent.getId(), "Hello!", false, false, course1, student, admin.getId(), dateNow, false).mockStaffCompositeCourseAssessmentRequests().mockWorkspaceBasePrice(course1.getId(), courseBasePrices).mockWorkspaceBilledPriceUpdate(String.valueOf(price / 2));
logout();
mockBuilder.removeMockCourseStudent(courseStudent);
courseStudent = new MockCourseStudent(2l, course1.getId(), student.getId(), TestUtilities.createCourseActivity(course1, CourseActivityState.ASSESSMENT_REQUESTED));
mockBuilder.addCourseStudent(course1.getId(), courseStudent).build();
mockBuilder.mockLogin(admin);
login();
navigate(String.format("/evaluation"), false);
waitAndClick(".button-pill--evaluate");
waitAndClickAndConfirm(".dialog--evaluation.dialog--visible a.button--evaluation-add-assessment", ".evaluation-modal__evaluate-drawer .evaluation-modal__evaluate-drawer-content--workspace #workspaceEvaluationGrade", 10, 3000);
waitUntilAnimationIsDone(".evaluation-modal__evaluate-drawer");
if (getBrowser().equals("chrome_headless")) {
sleep(500);
}
waitForPresent(".evaluation-modal__evaluate-drawer .evaluation-modal__evaluate-drawer-content--workspace .cke_contents");
addTextToCKEditor("Test evaluation.");
selectOption("#workspaceEvaluationGrade", "PYRAMUS-1");
selectOption("#workspaceEvaluationBilling", "37.5");
mockBuilder.addStaffCompositeAssessmentRequest(student.getId(), course1.getId(), courseStudent.getId(), "Hello!", false, true, course1, student, admin.getId(), dateNow, true).mockStaffCompositeCourseAssessmentRequests().mockAssessmentRequests(student.getId(), course1.getId(), courseStudent.getId(), "Hello!", false, true, dateNow);
mockBuilder.removeMockCourseStudent(courseStudent);
courseStudent = new MockCourseStudent(2l, course1.getId(), student.getId(), TestUtilities.createCourseActivity(course1, CourseActivityState.GRADED));
mockBuilder.mockCourseAssessments(course1, courseStudent, admin).mockWorkspaceBilledPrice(String.valueOf(price / 2)).addCourseStudent(course1.getId(), courseStudent).mockCourseActivities();
waitAndClick(".evaluation-modal__evaluate-drawer-row--buttons .button--evaluate-workspace");
waitForPresent(".dialog--evaluation-archive-student.dialog--visible .button--standard-ok");
waitAndClickAndConfirmVisibilityGoesAway(".button--standard-ok", ".dialog--evaluation-archive-student.dialog--visible", 3, 2000);
assertText(".evaluation-modal__event .evaluation-modal__event-grade.state-PASSED", "Excellent");
EqualToJsonPattern jsonPattern = new EqualToJsonPattern("{\"price\": 37.5}", true, true);
verify(putRequestedFor(urlEqualTo("/1/worklist/billedPrice")).withRequestBody(jsonPattern).withHeader("Content-Type", equalTo("application/json")));
} finally {
deleteWorkspaceHtmlMaterial(workspace.getId(), htmlMaterial.getId());
deleteWorkspace(workspace.getId());
archiveUserByEmail(student.getEmail());
}
} finally {
mockBuilder.wiremockReset();
}
}
use of com.github.tomakehurst.wiremock.matching.EqualToJsonPattern in project sdc by onap.
the class HttpNotificationTaskTest method retryWithSameItemIdsWhenResponse500AndFailedToParseResponse.
@Test
public void retryWithSameItemIdsWhenResponse500AndFailedToParseResponse() {
final String[] expectedItemIds = { UUID.randomUUID().toString(), UUID.randomUUID().toString() };
stubFor(post(NOTIFICATION_PATH).willReturn(aResponse().withStatus(500).withBody("d[g.0g,y/")).inScenario(MALFORMED_RESPONSE_SCENARIO));
HttpNotificationTask task = new HttpNotificationTask(endpoint, USER_ID, Arrays.asList(expectedItemIds));
assertEquals(RETRY, task.call());
EqualToJsonPattern expectedRequestBody = new EqualToJsonPattern(arrayToJson(expectedItemIds), true, false);
verify(postRequestedFor(urlEqualTo(NOTIFICATION_PATH)).withRequestBody(expectedRequestBody));
stubFor(post(NOTIFICATION_PATH).willReturn(aResponse().withStatus(200).withBody("{}")).inScenario(MALFORMED_RESPONSE_SCENARIO));
assertEquals(DONE, task.call());
verify(postRequestedFor(urlEqualTo(NOTIFICATION_PATH)).withRequestBody(expectedRequestBody));
}
use of com.github.tomakehurst.wiremock.matching.EqualToJsonPattern in project mod-kb-ebsco-java by folio-org.
the class EholdingsPackagesTest method shouldUpdateAllAttributesInCustomPackageAndDeleteAccessTypeMapping.
@Test
public void shouldUpdateAllAttributesInCustomPackageAndDeleteAccessTypeMapping() throws URISyntaxException, IOException {
List<AccessType> accessTypes = insertAccessTypes(testData(configuration.getId()), vertx);
String accessTypeId = accessTypes.get(0).getId();
insertAccessTypeMapping(FULL_PACKAGE_ID, PACKAGE, accessTypeId, vertx);
boolean updatedSelected = true;
boolean updatedHidden = true;
String updatedBeginCoverage = "2003-01-01";
String updatedEndCoverage = "2004-01-01";
String updatedPackageName = "name of the ages forever and ever";
EqualToJsonPattern putBodyPattern = new EqualToJsonPattern(readFile("requests/rmapi/packages/put-package-custom.json"), true, true);
PackageByIdData packageData = mapper.readValue(getFile(CUSTOM_PACKAGE_STUB_FILE), PackageByIdData.class);
packageData = packageData.toByIdBuilder().isSelected(updatedSelected).visibilityData(packageData.getVisibilityData().toBuilder().isHidden(updatedHidden).build()).customCoverage(CoverageDates.builder().beginCoverage(updatedBeginCoverage).endCoverage(updatedEndCoverage).build()).packageName(updatedPackageName).contentType("streamingmedia").build();
String updatedPackageValue = mapper.writeValueAsString(packageData);
mockUpdateScenario(readFile(CUSTOM_PACKAGE_STUB_FILE), updatedPackageValue);
String putBody = readFile("requests/kb-ebsco/package/put-package-custom-multiple-attributes.json");
Package aPackage = putWithOk(PACKAGES_PATH, putBody, STUB_TOKEN_HEADER).as(Package.class);
verify(putRequestedFor(PACKAGE_URL_PATTERN).withRequestBody(putBodyPattern));
assertEquals(updatedSelected, aPackage.getData().getAttributes().getIsSelected());
assertEquals(updatedHidden, aPackage.getData().getAttributes().getVisibilityData().getIsHidden());
assertEquals(updatedBeginCoverage, aPackage.getData().getAttributes().getCustomCoverage().getBeginCoverage());
assertEquals(updatedEndCoverage, aPackage.getData().getAttributes().getCustomCoverage().getEndCoverage());
assertEquals(updatedPackageName, aPackage.getData().getAttributes().getName());
assertEquals(ContentType.STREAMING_MEDIA, aPackage.getData().getAttributes().getContentType());
List<AccessTypeMapping> accessTypeMappingsInDB = getAccessTypeMappings(vertx);
assertEquals(0, accessTypeMappingsInDB.size());
assertNotNull(aPackage.getIncluded());
assertEquals(0, aPackage.getIncluded().size());
assertNull(aPackage.getData().getRelationships().getAccessType());
}
use of com.github.tomakehurst.wiremock.matching.EqualToJsonPattern in project mod-kb-ebsco-java by folio-org.
the class EholdingsPackagesTest method shouldUpdateAllAttributesInCustomPackageAndUpdateAccessTypeMapping.
@Test
public void shouldUpdateAllAttributesInCustomPackageAndUpdateAccessTypeMapping() throws URISyntaxException, IOException {
List<AccessType> accessTypes = insertAccessTypes(testData(configuration.getId()), vertx);
String currentAccessTypeId = accessTypes.get(0).getId();
String newAccessTypeId = accessTypes.get(1).getId();
insertAccessTypeMapping(FULL_PACKAGE_ID, PACKAGE, currentAccessTypeId, vertx);
boolean updatedSelected = true;
boolean updatedHidden = true;
String updatedBeginCoverage = "2003-01-01";
String updatedEndCoverage = "2004-01-01";
String updatedPackageName = "name of the ages forever and ever";
EqualToJsonPattern putBodyPattern = new EqualToJsonPattern(readFile("requests/rmapi/packages/put-package-custom.json"), true, true);
PackageByIdData packageData = mapper.readValue(getFile(CUSTOM_PACKAGE_STUB_FILE), PackageByIdData.class);
packageData = packageData.toByIdBuilder().isSelected(updatedSelected).visibilityData(packageData.getVisibilityData().toBuilder().isHidden(updatedHidden).build()).customCoverage(CoverageDates.builder().beginCoverage(updatedBeginCoverage).endCoverage(updatedEndCoverage).build()).packageName(updatedPackageName).contentType("streamingmedia").build();
String updatedPackageValue = mapper.writeValueAsString(packageData);
mockUpdateScenario(readFile(CUSTOM_PACKAGE_STUB_FILE), updatedPackageValue);
String putBody = String.format(readFile("requests/kb-ebsco/package/put-package-custom-with-access-type.json"), newAccessTypeId);
Package aPackage = putWithOk(PACKAGES_PATH, putBody, STUB_TOKEN_HEADER).as(Package.class);
verify(putRequestedFor(PACKAGE_URL_PATTERN).withRequestBody(putBodyPattern));
assertEquals(updatedSelected, aPackage.getData().getAttributes().getIsSelected());
assertEquals(updatedHidden, aPackage.getData().getAttributes().getVisibilityData().getIsHidden());
assertEquals(updatedBeginCoverage, aPackage.getData().getAttributes().getCustomCoverage().getBeginCoverage());
assertEquals(updatedEndCoverage, aPackage.getData().getAttributes().getCustomCoverage().getEndCoverage());
assertEquals(updatedPackageName, aPackage.getData().getAttributes().getName());
assertEquals(ContentType.STREAMING_MEDIA, aPackage.getData().getAttributes().getContentType());
List<AccessTypeMapping> accessTypeMappingsInDB = getAccessTypeMappings(vertx);
assertEquals(1, accessTypeMappingsInDB.size());
assertEquals(aPackage.getData().getId(), accessTypeMappingsInDB.get(0).getRecordId());
assertEqualsUUID(newAccessTypeId, accessTypeMappingsInDB.get(0).getAccessTypeId());
assertEquals(PACKAGE, accessTypeMappingsInDB.get(0).getRecordType());
assertNotNull(aPackage.getIncluded());
assertEquals(newAccessTypeId, aPackage.getData().getRelationships().getAccessType().getData().getId());
assertEquals(newAccessTypeId, ((LinkedHashMap<?, ?>) aPackage.getIncluded().get(0)).get("id"));
}
Aggregations