- WebTarget target = PowerMock.createMock(WebTarget.class);
- Client client = PowerMock.createMock(Client.class);
- Builder builder = PowerMock.createMock(Builder.class);
- Response response = PowerMock.createMock(Response.class);
- PowerMock.mockStatic(ClientBuilder.class);
-
- EasyMock.expect(ClientBuilder.newClient()).andReturn(client);
- EasyMock.expect(client.target(publisher.getUrl())).andReturn(target);
- EasyMock.expect(target.request(MediaType.APPLICATION_JSON)).andReturn(builder);
- EasyMock.expect(builder.post(EasyMock.anyObject(Entity.class))).andReturn(response);
- EasyMock.expect(response.getStatus()).andReturn(HttpStatus.SC_OK);
+ PowerMockito.mockStatic(HttpsUtils.class);
+ HttpResponse httpResponse = PowerMockito.mock(HttpResponse.class);
+ PowerMockito.when(HttpsUtils.post(Matchers.eq("http://localhost/dmaapTopic"),
+ Matchers.any(HashMap.class), Matchers.any(HashMap.class), Matchers.any(StringEntity.class))).thenReturn(httpResponse);
+ StatusLine statusLine = PowerMockito.mock(StatusLine.class);
+ PowerMockito.when(httpResponse.getStatusLine()).thenReturn(statusLine);
+ PowerMockito.when(statusLine.getStatusCode()).thenReturn(HttpStatus.SC_OK);