@@ -0,0 +1,2676 @@
+package fi.csc.chipster.sessionstorage;%0A%0Aimport static org.junit.Assert.assertEquals;%0A%0Aimport java.io.File;%0Aimport java.io.IOException;%0A%0Aimport javax.ws.rs.client.Entity;%0Aimport javax.ws.rs.client.WebTarget;%0Aimport javax.ws.rs.core.MediaType;%0Aimport javax.ws.rs.core.Response;%0A%0Aimport org.junit.After;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0A%0Aimport com.fasterxml.jackson.core.JsonGenerationException;%0Aimport com.fasterxml.jackson.databind.JsonMappingException;%0A%0Aimport fi.csc.chipster.sessionstorage.model.Job;%0Aimport fi.csc.chipster.sessionstorage.rest.RestUtils;%0A%0Apublic class JobResourceTest %7B%0A%0A%09private static final MediaType JSON = MediaType.APPLICATION_JSON_TYPE;%0A    private static final String jobsPath = %22jobs%22;%0A    private WebTarget target;%0A%09private String path;%0A%09private TestServer server;%0A%0A    @Before%0A    public void setUp() throws Exception %7B%0A    %09server = new TestServer();%0A        target = server.getTarget(this);%0A        %0A        path = SessionResourceTest.postSession(target) + %22/%22 + jobsPath;%0A    %7D%0A%0A    @After%0A    public void tearDown() throws Exception %7B%0A    %09server.stop(this);%0A    %7D           %0A    %0A    private String postJob() %7B%0A    %09Job job = RestUtils.getRandomJob();%0A    %09Response response = target.path(path).request(JSON).post(Entity.entity(job, JSON),Response.class);        %0A        assertEquals(201, response.getStatus());%0A        %0A        return path + %22/%22 + new File(response.getLocation().getPath()).getName();%0A%09%7D%0A    %0A    @Test%0A    public void post() %7B%0A    %09postJob();%0A    %7D%0A%0A%0A%09@Test%0A    public void get() throws JsonGenerationException, JsonMappingException, IOException %7B%0A        %0A%09%09String objPath = postJob();        %0A        Job dataset2 = target.path(objPath).request().get(Job.class);        %0A        assertEquals(true, dataset2 != null);%0A    %7D%0A%09%0A%09@Test%0A    public void getAll() %7B%0A        %0A%09%09String id1 = new File(postJob()).getName();%0A%09%09String id2 = new File(postJob()).getName();%0A%09%09%0A        String json = target.path(path).request().get(String.class);%0A        assertEquals(json == null, false);%0A        %0A        //TODO parse json%0A        assertEquals(true, json.contains(id1));%0A        assertEquals(true, json.contains(id2));%0A    %7D%0A%09%0A%09@Test%0A    public void put() %7B%0A        %0A%09%09String objPath = postJob();%0A%09%09Job newObj = RestUtils.getRandomJob();%0A%09%09Response response = target.path(objPath).request(JSON).put(Entity.entity(newObj, JSON),Response.class);%0A        assertEquals(204, response.getStatus());%0A    %7D%0A%09%0A%09@Test%0A    public void delete() %7B%0A        %0A%09%09String objPath = postJob();%0A%09%09Response response = target.path(objPath).request().delete(Response.class);        %0A        assertEquals(204, response.getStatus());%0A    %7D%0A%7D%0A

Add tests for JobResource