use of com.fasterxml.jackson.datatype.jsr310.JSR310Module in project muikku by otavanopisto.
the class PyramusMocksRest method mockPerson.
private static Person mockPerson(Long personId, OffsetDateTime birthday, String socialSecurityNumber, Sex sex, Long defaultUserId) throws JsonProcessingException {
ObjectMapper objectMapper = new ObjectMapper().registerModule(new JSR310Module()).disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
Person person = new Person(personId, birthday, socialSecurityNumber, sex, false, "empty", defaultUserId);
String personJson = objectMapper.writeValueAsString(person);
stubFor(get(urlEqualTo("/1/persons/persons/" + personId)).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(personJson).withStatus(200)));
return person;
}
use of com.fasterxml.jackson.datatype.jsr310.JSR310Module in project muikku by otavanopisto.
the class PyramusMocksRest method adminLoginMock.
public static void adminLoginMock() throws JsonProcessingException {
stubFor(get(urlEqualTo("/dnm")).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody("").withStatus(204)));
stubFor(get(urlMatching("/users/authorize.*")).willReturn(aResponse().withStatus(302).withHeader("Location", "http://dev.muikku.fi:" + System.getProperty("it.port.http") + "/login?_stg=rsp&code=1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111")));
stubFor(post(urlEqualTo("/1/oauth/token")).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody("{\"expires_in\":3600,\"refresh_token\":\"12312ewsdf34fsd234r43rfsw32rf33e\",\"access_token\":\"ur84ur839843ruwf39843ru39ru37y2e\"}").withStatus(200)));
List<String> emails = new ArrayList<String>();
emails.add("admin@example.com");
WhoAmI whoAmI = new WhoAmI((long) 4, "Admin", "User", emails);
ObjectMapper objectMapper = new ObjectMapper().registerModule(new JSR310Module()).disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
String whoAmIJson = objectMapper.writeValueAsString(whoAmI);
stubFor(get(urlEqualTo("/1/system/whoami")).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(whoAmIJson).withStatus(200)));
}
use of com.fasterxml.jackson.datatype.jsr310.JSR310Module in project muikku by otavanopisto.
the class CourseManagementTestsBase method changeWorkspaceTypeTest.
@Test
@TestEnvironments(browsers = { TestEnvironments.Browser.CHROME, TestEnvironments.Browser.FIREFOX, TestEnvironments.Browser.INTERNET_EXPLORER, TestEnvironments.Browser.EDGE, TestEnvironments.Browser.PHANTOMJS })
public void changeWorkspaceTypeTest() throws Exception {
MockStaffMember admin = new MockStaffMember(1l, 1l, "Admin", "User", UserRole.ADMINISTRATOR, "121212-1234", "admin@example.com", Sex.MALE);
Builder mockBuilder = mocker();
try {
mockBuilder.addStaffMember(admin).mockLogin(admin).build();
login();
long courseId = 1l;
Workspace workspace = createWorkspace("testcourse", "test course for testing", String.valueOf(courseId), Boolean.TRUE);
try {
navigate(String.format("/workspace/%s/workspace-management", workspace.getUrlName()), true);
waitForPresent(".additionalinfo-data .workspace-type");
scrollIntoView(".additionalinfo-data .workspace-type");
selectOption(".additionalinfo-data .workspace-type", "PYRAMUS-2");
waitAndClick(".workspace-management-footer .workspace-management-footer-actions-container button.save");
waitForNotVisible(".loading");
ObjectMapper objectMapper = new ObjectMapper().registerModule(new JSR310Module()).disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS).setSerializationInclusion(Include.NON_NULL);
OffsetDateTime created = OffsetDateTime.of(1990, 2, 2, 0, 0, 0, 0, ZoneOffset.UTC);
OffsetDateTime begin = OffsetDateTime.of(2000, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC);
OffsetDateTime end = OffsetDateTime.of(2050, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC);
Course course = new Course(courseId, "testcourse", created, created, "<p>test course for testing</p>\n", false, 1, (long) 25, begin, end, "test extension", (double) 15, (double) 45, (double) 45, (double) 15, (double) 45, (double) 45, end, (long) 1, (long) 1, (long) 1, null, (double) 45, (long) 1, (long) 1, (long) 1, (long) 2, null, null);
String courseJson = objectMapper.writeValueAsString(course);
stubFor(put(urlEqualTo(String.format("/1/courses/courses/%d", courseId))).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(courseJson).withStatus(200)));
stubFor(get(urlEqualTo(String.format("/1/courses/courses/%d", courseId))).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(courseJson).withStatus(200)));
String payload = objectMapper.writeValueAsString(new WebhookCourseUpdatePayload(course.getId()));
TestUtilities.webhookCall("http://dev.muikku.fi:" + System.getProperty("it.port.http") + "/pyramus/webhook", payload);
navigate(String.format("/workspace/%s", workspace.getUrlName()), true);
waitForPresent(".workspace-meta-wrapper .workspace-meta-item-wrapper:nth-child(3) .workspace-meta-desc");
assertTextIgnoreCase(".workspace-meta-wrapper .workspace-meta-item-wrapper:nth-child(3) .workspace-meta-desc", "Ryhmäkurssi");
} finally {
deleteWorkspace(workspace.getId());
}
} finally {
mockBuilder.wiremockReset();
}
}
use of com.fasterxml.jackson.datatype.jsr310.JSR310Module in project muikku by otavanopisto.
the class AbstractUITest method createDiscussionGroup.
protected DiscussionGroup createDiscussionGroup(String name) throws IOException {
ObjectMapper objectMapper = new ObjectMapper().registerModule(new JSR310Module()).disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
DiscussionGroup payload = new DiscussionGroup(null, name);
Response response = asAdmin().contentType("application/json").body(payload).post("/test/discussiongroups");
response.then().statusCode(200);
DiscussionGroup discussionGroup = objectMapper.readValue(response.asString(), DiscussionGroup.class);
assertNotNull(discussionGroup);
assertNotNull(discussionGroup.getId());
return discussionGroup;
}
use of com.fasterxml.jackson.datatype.jsr310.JSR310Module in project muikku by otavanopisto.
the class AbstractUITest method loginStudent2.
protected void loginStudent2() throws JsonProcessingException, Exception {
PyramusMocks.student2LoginMock();
PyramusMocks.personsPyramusMocks();
ObjectMapper objectMapper = new ObjectMapper().registerModule(new JSR310Module()).disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
String payload = objectMapper.writeValueAsString(new WebhookStudentCreatePayload((long) 2));
webhookCall("http://dev.muikku.fi:" + getPortHttp() + "/pyramus/webhook", payload);
payload = objectMapper.writeValueAsString(new WebhookPersonCreatePayload((long) 2));
webhookCall("http://dev.muikku.fi:" + getPortHttp() + "/pyramus/webhook", payload);
navigate("/login?authSourceId=1", true);
waitForPresent(".index");
}
Aggregations