http-service: set content-type to application/json in various responses
This commit is contained in:
@@ -43,11 +43,14 @@ import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Answers;
|
||||
import org.mockito.Matchers;
|
||||
import org.mockito.Mock;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.sql2o.Sql2o;
|
||||
import spark.Request;
|
||||
import spark.Response;
|
||||
import spark.Spark;
|
||||
|
||||
public class ServiceTest
|
||||
@@ -102,7 +105,7 @@ public class ServiceTest
|
||||
HiscoreResult result = new HiscoreResult();
|
||||
result.setAttack(new Skill(1, 99, 42));
|
||||
|
||||
when(hiscoreService.lookup("zezima")).thenReturn(result);
|
||||
when(hiscoreService.lookup(Matchers.any(Request.class), Matchers.any(Response.class))).thenReturn(result);
|
||||
|
||||
URL url = new URL(URL_BASE + "/hiscore?username=zezima");
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
|
||||
@@ -32,6 +32,9 @@ import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import spark.Request;
|
||||
import spark.Response;
|
||||
|
||||
public class HiscoreServiceTest
|
||||
{
|
||||
@@ -91,7 +94,10 @@ public class HiscoreServiceTest
|
||||
HiscoreService hiscores = new HiscoreService();
|
||||
hiscores.setUrl(server.url("/"));
|
||||
|
||||
HiscoreResult result = hiscores.lookup("zezima");
|
||||
Request request = mock(Request.class);
|
||||
Response response = mock(Response.class);
|
||||
|
||||
HiscoreResult result = hiscores.lookup(request, response);
|
||||
|
||||
Assert.assertEquals(50, result.getAttack().getLevel());
|
||||
Assert.assertEquals(159727L, result.getFishing().getExperience());
|
||||
|
||||
Reference in New Issue
Block a user