### Question:
MultipartRequest extends BaseRequest<T> { @Nullable public HashMap<String, List<RequestData>> getMultiPartData() { return multiPartData; } private  MultipartRequest(Builder<T> builder); @Override @NonNull String getBodyContentType(); @Nullable HashMap<String, List<RequestData>> getMultiPartData(); @NonNull String getJsonKey();  }### Answer:
@Test public void builderPostGeneration() throws Exception { MultipartRequest.Builder<DummyResponse> builder = new MultipartRequest.Builder<>(Request.Method.POST, url, DummyResponse.class); builder.parameters(parameters); builder.json(dummyRequestObject); builder.headers(headers); builder.multiPartDataList(dummyDataMap); MultipartRequest<DummyResponse> baseRequest = builder.build(); assertEquals("The url should be the same", url, baseRequest.getUrl()); assertEquals("The method should be the same", Request.Method.POST, baseRequest.getMethod()); assertEquals("The parameters should be the same", parameters, baseRequest.getParams()); assertEquals("The object should be the same", dummyRequestObject, baseRequest.getJsonObject()); assertEquals("The multi part should be the same", dummyDataMap, baseRequest.getMultiPartData()); Map returnedMap = baseRequest.getHeaders(); for (String key : headers.keySet()) { assertTrue("The key should be contained", returnedMap.containsKey(key)); assertEquals("The same value should be contained", headers.get(key), returnedMap.get(key)); } }
@Test public void builderPostGenerationWithPutMultipartSimple() throws Exception { MultipartRequest.Builder<DummyResponse> builder = new MultipartRequest.Builder<>(Request.Method.POST, url, DummyResponse.class); builder.parameters(parameters); builder.json(dummyRequestObject); builder.headers(headers); builder.multiPartData(dummyDataMapNoList); MultipartRequest<DummyResponse> baseRequest = builder.build(); assertEquals("The url should be the same", url, baseRequest.getUrl()); assertEquals("The method should be the same", Request.Method.POST, baseRequest.getMethod()); assertEquals("The parameters should be the same", parameters, baseRequest.getParams()); assertEquals("The object should be the same", dummyRequestObject, baseRequest.getJsonObject()); assertEquals("The multi part should be the same", dummyDataMap, baseRequest.getMultiPartData()); Map returnedMap = baseRequest.getHeaders(); for (String key : headers.keySet()) { assertTrue("The key should be contained", returnedMap.containsKey(key)); assertEquals("The same value should be contained", headers.get(key), returnedMap.get(key)); } }
@Test public void builderPostGenerationWithInsertMultipart() throws Exception { MultipartRequest.Builder<DummyResponse> builder = new MultipartRequest.Builder<>(Request.Method.POST, url, DummyResponse.class); builder.parameters(parameters); builder.json(dummyRequestObject); builder.headers(headers); for (Map.Entry<String, List<RequestData>> entry : dummyDataMap.entrySet()) { for (RequestData datapart : entry.getValue()) { builder.insertMultiPartData(entry.getKey(), datapart); } } MultipartRequest<DummyResponse> baseRequest = builder.build(); assertEquals("The url should be the same", url, baseRequest.getUrl()); assertEquals("The method should be the same", Request.Method.POST, baseRequest.getMethod()); assertEquals("The parameters should be the same", parameters, baseRequest.getParams()); assertEquals("The object should be the same", dummyRequestObject, baseRequest.getJsonObject()); assertEquals("The multi part should be the same", dummyDataMap, baseRequest.getMultiPartData()); Map returnedMap = baseRequest.getHeaders(); for (String key : headers.keySet()) { assertTrue("The key should be contained", returnedMap.containsKey(key)); assertEquals("The same value should be contained", headers.get(key), returnedMap.get(key)); } }