public class JerseyClientTest {
private final String ERROR_MSG = "Status code: <404>. Message: Failed to get response from the server. Info: Error";
- private JerseyClient jerseyClient = new JerseyClient();
+ private JerseyClient jerseyClient = JerseyClient.newInstance();
private String url = "http://www.onap.org/holmes/test";
+
@Rule
private ExpectedException exception = ExpectedException.none();
EasyMock.expect(mockedTarget.request()).andReturn(mockedBuilder);
EasyMock.expect(mockedBuilder.header("Accept", MediaType.APPLICATION_JSON)).andReturn(mockedBuilder);
EasyMock.expect(mockedBuilder.get()).andReturn(mockedResponse);
- EasyMock.expect(mockedResponse.getStatus()).andReturn(200);
+ EasyMock.expect(mockedResponse.getStatusInfo()).andReturn(Response.Status.OK);
EasyMock.expect(mockedResponse.readEntity(String.class)).andReturn("Normal");
WhiteboxImpl.setInternalState(jerseyClient, "client", mockedClient);
EasyMock.expect(mockedClient.target(url)).andReturn(mockedTarget);
EasyMock.expect(mockedTarget.request()).andReturn(mockedBuilder);
EasyMock.expect(mockedBuilder.get()).andReturn(mockedResponse);
- EasyMock.expect(mockedResponse.getStatus()).andReturn(200);
+ EasyMock.expect(mockedResponse.getStatusInfo()).andReturn(Response.Status.OK);
EasyMock.expect(mockedResponse.readEntity(String.class)).andReturn(GsonUtil.beanToJson(bean));
WhiteboxImpl.setInternalState(jerseyClient, "client", mockedClient);
EasyMock.expect(mockedClient.target(url)).andReturn(mockedTarget);
EasyMock.expect(mockedTarget.request()).andReturn(mockedBuilder);
EasyMock.expect(mockedBuilder.get()).andReturn(mockedResponse);
- EasyMock.expect(mockedResponse.getStatus()).andReturn(200);
+ EasyMock.expect(mockedResponse.getStatusInfo()).andReturn(Response.Status.OK);
EasyMock.expect(mockedResponse.readEntity(String.class)).andReturn("Normal");
WhiteboxImpl.setInternalState(jerseyClient, "client", mockedClient);
EasyMock.expect(mockedTarget.request()).andReturn(mockedBuilder);
EasyMock.expect(mockedBuilder.get()).andReturn(mockedResponse);
EasyMock.expect(mockedResponse.getStatus()).andReturn(404);
+ EasyMock.expect(mockedResponse.getStatusInfo()).andReturn(Response.Status.NOT_FOUND);
EasyMock.expect(mockedResponse.readEntity(String.class)).andReturn("Error");
WhiteboxImpl.setInternalState(jerseyClient, "client", mockedClient);
EasyMock.expect(mockedClient.target(url)).andReturn(mockedTarget);
EasyMock.expect(mockedTarget.request()).andReturn(mockedBuilder);
EasyMock.expect(mockedBuilder.post(null)).andReturn(mockedResponse);
- EasyMock.expect(mockedResponse.getStatus()).andReturn(200);
+ EasyMock.expect(mockedResponse.getStatusInfo()).andReturn(Response.Status.OK);
EasyMock.expect(mockedResponse.readEntity(String.class)).andReturn("Normal");
WhiteboxImpl.setInternalState(jerseyClient, "client", mockedClient);
EasyMock.expect(mockedTarget.request()).andReturn(mockedBuilder);
EasyMock.expect(mockedBuilder.post(null)).andReturn(mockedResponse);
EasyMock.expect(mockedResponse.getStatus()).andReturn(404);
+ EasyMock.expect(mockedResponse.getStatusInfo()).andReturn(Response.Status.NOT_FOUND);
EasyMock.expect(mockedResponse.readEntity(String.class)).andReturn("Error");
WhiteboxImpl.setInternalState(jerseyClient, "client", mockedClient);
EasyMock.expect(mockedClient.target(url)).andReturn(mockedTarget);
EasyMock.expect(mockedTarget.request()).andReturn(mockedBuilder);
EasyMock.expect(mockedBuilder.post(null)).andReturn(mockedResponse);
- EasyMock.expect(mockedResponse.getStatus()).andReturn(200);
+ EasyMock.expect(mockedResponse.getStatusInfo()).andReturn(Response.Status.OK);
EasyMock.expect(mockedResponse.readEntity(String.class)).andReturn(GsonUtil.beanToJson(bean));
WhiteboxImpl.setInternalState(jerseyClient, "client", mockedClient);
EasyMock.expect(mockedClient.target(url)).andReturn(mockedTarget);
EasyMock.expect(mockedTarget.request()).andReturn(mockedBuilder);
EasyMock.expect(mockedBuilder.put(null)).andReturn(mockedResponse);
- EasyMock.expect(mockedResponse.getStatus()).andReturn(200);
+ EasyMock.expect(mockedResponse.getStatusInfo()).andReturn(Response.Status.OK);
EasyMock.expect(mockedResponse.readEntity(String.class)).andReturn("Normal");
WhiteboxImpl.setInternalState(jerseyClient, "client", mockedClient);
EasyMock.expect(mockedClient.target(url)).andReturn(mockedTarget);
EasyMock.expect(mockedTarget.request()).andReturn(mockedBuilder);
EasyMock.expect(mockedBuilder.put(null)).andReturn(mockedResponse);
- EasyMock.expect(mockedResponse.getStatus()).andReturn(200);
+ EasyMock.expect(mockedResponse.getStatusInfo()).andReturn(Response.Status.OK);
EasyMock.expect(mockedResponse.readEntity(String.class)).andReturn(GsonUtil.beanToJson(bean));
WhiteboxImpl.setInternalState(jerseyClient, "client", mockedClient);
EasyMock.expect(mockedClient.target(url)).andReturn(mockedTarget);
EasyMock.expect(mockedTarget.request()).andReturn(mockedBuilder);
EasyMock.expect(mockedBuilder.put(null)).andReturn(mockedResponse);
- EasyMock.expect(mockedResponse.getStatus()).andReturn(200);
+ EasyMock.expect(mockedResponse.getStatusInfo()).andReturn(Response.Status.OK);
EasyMock.expect(mockedResponse.readEntity(String.class)).andReturn(GsonUtil.beanToJson(bean));
WhiteboxImpl.setInternalState(jerseyClient, "client", mockedClient);
EasyMock.expect(mockedTarget.request()).andReturn(mockedBuilder);
EasyMock.expect(mockedBuilder.put(null)).andReturn(mockedResponse);
EasyMock.expect(mockedResponse.getStatus()).andReturn(404);
+ EasyMock.expect(mockedResponse.getStatusInfo()).andReturn(Response.Status.NOT_FOUND);
EasyMock.expect(mockedResponse.readEntity(String.class)).andReturn("Error");
WhiteboxImpl.setInternalState(jerseyClient, "client", mockedClient);
EasyMock.expect(mockedClient.target(url)).andReturn(mockedTarget);
EasyMock.expect(mockedTarget.request()).andReturn(mockedBuilder);
EasyMock.expect(mockedBuilder.delete()).andReturn(mockedResponse);
- EasyMock.expect(mockedResponse.getStatus()).andReturn(200);
+ EasyMock.expect(mockedResponse.getStatusInfo()).andReturn(Response.Status.OK);
EasyMock.expect(mockedResponse.readEntity(String.class)).andReturn("Normal");
WhiteboxImpl.setInternalState(jerseyClient, "client", mockedClient);
EasyMock.expect(mockedClient.target(url)).andReturn(mockedTarget);
EasyMock.expect(mockedTarget.request()).andReturn(mockedBuilder);
EasyMock.expect(mockedBuilder.delete()).andReturn(mockedResponse);
- EasyMock.expect(mockedResponse.getStatus()).andReturn(200);
+ EasyMock.expect(mockedResponse.getStatusInfo()).andReturn(Response.Status.OK);
EasyMock.expect(mockedResponse.readEntity(String.class)).andReturn(GsonUtil.beanToJson(bean));
WhiteboxImpl.setInternalState(jerseyClient, "client", mockedClient);
EasyMock.expect(mockedClient.target(url)).andReturn(mockedTarget);
EasyMock.expect(mockedTarget.request()).andReturn(mockedBuilder);
EasyMock.expect(mockedBuilder.delete()).andReturn(mockedResponse);
- EasyMock.expect(mockedResponse.getStatus()).andReturn(200);
+ EasyMock.expect(mockedResponse.getStatusInfo()).andReturn(Response.Status.OK);
EasyMock.expect(mockedResponse.readEntity(String.class)).andReturn("Normal");
WhiteboxImpl.setInternalState(jerseyClient, "client", mockedClient);
EasyMock.expect(mockedTarget.request()).andReturn(mockedBuilder);
EasyMock.expect(mockedBuilder.delete()).andReturn(mockedResponse);
EasyMock.expect(mockedResponse.getStatus()).andReturn(404);
+ EasyMock.expect(mockedResponse.getStatusInfo()).andReturn(Response.Status.NOT_FOUND);
EasyMock.expect(mockedResponse.readEntity(String.class)).andReturn("Error");
WhiteboxImpl.setInternalState(jerseyClient, "client", mockedClient);