@Test void createReturnsNullBodyIfBodyIsNull() throws Exception { when(request.getPath()).thenReturn(path); when(request.getMethod()).thenReturn(requestMethod); when(request.getHeaders()).thenReturn(headers); when(request.getQueryParams()).thenReturn(queryParams); when(request.getBody()).thenReturn(null); when(deserializer.deserialize(expectedMap, AppRequest.class)).thenReturn(new AppRequest(appRequest)); final AppRequest got = appRequestFactory.create(request); assertThat(got).isEqualTo(appRequest); }
public AppRequest create(Request request) { final String bodyString = request.getBody(); final BodyContent bodyContent = getBodyContent(bodyString); final Map<String, Object> primedRequestMap = new HashMap<>(); primedRequestMap.put("path", request.getPath()); primedRequestMap.put("method", request.getMethod()); primedRequestMap.put("queryParams", request.getQueryParams()); primedRequestMap.put("headers", request.getHeaders()); final AppRequest deserializedAppRequest = deserializer.deserialize(primedRequestMap, AppRequest.class); return deserializedAppRequest.withBody(bodyContent); }
AppRequestFactory { public AppRequest create(Request request) { final String bodyString = request.getBody(); final BodyContent bodyContent = getBodyContent(bodyString); final Map<String, Object> primedRequestMap = new HashMap<>(); primedRequestMap.put("path", request.getPath()); primedRequestMap.put("method", request.getMethod()); primedRequestMap.put("queryParams", request.getQueryParams()); primedRequestMap.put("headers", request.getHeaders()); final AppRequest deserializedAppRequest = deserializer.deserialize(primedRequestMap, AppRequest.class); return deserializedAppRequest.withBody(bodyContent); } }
AppRequestFactory { public AppRequest create(Request request) { final String bodyString = request.getBody(); final BodyContent bodyContent = getBodyContent(bodyString); final Map<String, Object> primedRequestMap = new HashMap<>(); primedRequestMap.put("path", request.getPath()); primedRequestMap.put("method", request.getMethod()); primedRequestMap.put("queryParams", request.getQueryParams()); primedRequestMap.put("headers", request.getHeaders()); final AppRequest deserializedAppRequest = deserializer.deserialize(primedRequestMap, AppRequest.class); return deserializedAppRequest.withBody(bodyContent); } AppRequestFactory(Deserializer deserializer); }
AppRequestFactory { public AppRequest create(Request request) { final String bodyString = request.getBody(); final BodyContent bodyContent = getBodyContent(bodyString); final Map<String, Object> primedRequestMap = new HashMap<>(); primedRequestMap.put("path", request.getPath()); primedRequestMap.put("method", request.getMethod()); primedRequestMap.put("queryParams", request.getQueryParams()); primedRequestMap.put("headers", request.getHeaders()); final AppRequest deserializedAppRequest = deserializer.deserialize(primedRequestMap, AppRequest.class); return deserializedAppRequest.withBody(bodyContent); } AppRequestFactory(Deserializer deserializer); AppRequest create(Request request); }
AppRequestFactory { public AppRequest create(Request request) { final String bodyString = request.getBody(); final BodyContent bodyContent = getBodyContent(bodyString); final Map<String, Object> primedRequestMap = new HashMap<>(); primedRequestMap.put("path", request.getPath()); primedRequestMap.put("method", request.getMethod()); primedRequestMap.put("queryParams", request.getQueryParams()); primedRequestMap.put("headers", request.getHeaders()); final AppRequest deserializedAppRequest = deserializer.deserialize(primedRequestMap, AppRequest.class); return deserializedAppRequest.withBody(bodyContent); } AppRequestFactory(Deserializer deserializer); AppRequest create(Request request);  }