@Test public void makePutRequestSendsPut() throws IOException, TmcCoreException, URISyntaxException { settings.setUsername("test"); settings.setPassword("1234"); Map<String, String> body = new HashMap<>(); body.put("mark_as_read", "1"); HttpResult makePutRequest = urlCommunicator.makePutRequest(URI.create(serverAddress + "/putty"), Optional.of(body)); assertEquals(200, makePutRequest.getStatusCode()); }
@Test public void httpPostAddsFileToRequest() throws IOException, TmcCoreException { settings.setUsername("test"); settings.setPassword("1234"); File testFile = new File("testResources/test.zip"); HttpResult result = urlCommunicator.makePostWithFile( new FileBody(testFile), URI.create(serverAddress + "/kivaurl"), new HashMap<String, String>()); assertEquals("All tests passed", result.getData()); }
@Test public void notFoundWithoutValidParams() throws IOException, TmcCoreException { HttpResult result = urlCommunicator.makeGetRequest(URI.create(serverAddress), "ihanvaaraheaderi:1234"); assertEquals(403, result.getStatusCode()); }
@Test public void badRequestWithoutValidUrl() throws IOException, TmcCoreException { HttpResult result = urlCommunicator.makeGetRequest(URI.create(serverAddress + "/vaaraurl"), "test:1234"); assertEquals(400, result.getStatusCode()); }
@Test public void okWithValidParams() throws IOException, TmcCoreException { HttpResult result = urlCommunicator.makeGetRequest(URI.create(serverAddress), "test:1234"); assertEquals(200, result.getStatusCode()); }
@Test(expected = IOException.class) public void badGetRequestIsThrown() throws IOException, TmcCoreException { urlCommunicator.makeGetRequest(URI.create("asasdasd"), "chang:/\\\\eiparas"); }