Search in sources :

Example 1 with CommunicatorMessage

use of fi.otavanopisto.muikku.atests.CommunicatorMessage in project muikku by otavanopisto.

the class AbstractUITest method createCommunicatorMesssage.

protected void createCommunicatorMesssage(String caption, String content, Long sender, Long recipient) throws JsonParseException, JsonMappingException, IOException {
    ObjectMapper objectMapper = new ObjectMapper().registerModule(new JSR310Module()).disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
    Date created = new Date();
    Set<String> tags = new HashSet<>();
    List<Long> recipientIds = new ArrayList<>();
    recipientIds.add(recipient);
    CommunicatorMessage payload = new CommunicatorMessage(null, null, sender, "test", caption, content, created, tags, recipientIds, new ArrayList<Long>(), new ArrayList<Long>(), new ArrayList<Long>());
    Response response = asAdmin().contentType("application/json").body(payload).post("test/communicator/messages");
    response.then().statusCode(200);
    CommunicatorMessage result = objectMapper.readValue(response.asString(), CommunicatorMessage.class);
    assertNotNull(result);
    assertNotNull(result.getId());
}
Also used : Response(com.jayway.restassured.response.Response) CommunicatorMessage(fi.otavanopisto.muikku.atests.CommunicatorMessage) JSR310Module(com.fasterxml.jackson.datatype.jsr310.JSR310Module) ArrayList(java.util.ArrayList) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Date(java.util.Date) HashSet(java.util.HashSet)

Aggregations

ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 JSR310Module (com.fasterxml.jackson.datatype.jsr310.JSR310Module)1 Response (com.jayway.restassured.response.Response)1 CommunicatorMessage (fi.otavanopisto.muikku.atests.CommunicatorMessage)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 HashSet (java.util.HashSet)1