MultiParts { public static String getContentType(ParamConfig paramConfig){ return (String) paramConfig.getMetaDatas().get(CONTENT_TYPE); } private  MultiParts(); static String getContentType(ParamConfig paramConfig); static String getFileName(ParamConfig paramConfig); static String getContentType(Param param); static String getFileName(Param param); static boolean hasMultiPart(ParamConfig[] paramConfigs); static boolean hasMultiPart(Map<String,Object> metadatas); static boolean hasMultiPart(Param param); static void putMetaDatas(Map<String, Object> metadatas, String contentType, String fileName); static Map<String,Object> toMetaDatas(String contentType, String fileName); static void asMultipart(Map<String, Object> metadatas);  }
@Test public void getContentTypeShouldGetContentTypeFromParamConfig(){ Map<String,Object> metaDatas = Collections.singletonMap("multipart.content-type", (Object)"expected"); ParamConfig paramConfig = mock(ParamConfig.class); when(paramConfig.getMetaDatas()).thenReturn(metaDatas); assertEquals("expected", MultiParts.getContentType(paramConfig)); }
@Test public void getContentTypeShouldReturnNullWhenNoContentTypeIsFoundInParamConfigMetas(){ Map<String,Object> metaDatas = new HashMap<String, Object>(); ParamConfig paramConfig = mock(ParamConfig.class); when(paramConfig.getMetaDatas()).thenReturn(metaDatas); assertNull(MultiParts.getContentType(paramConfig)); }
@Test public void getContentTypeShouldGetContentTypeFromParam(){ Map<String,Object> metaDatas = Collections.singletonMap("multipart.content-type", (Object)"expected"); Param param = mock(Param.class); ParamConfig paramConfig = mock(ParamConfig.class); when(paramConfig .getMetaDatas()).thenReturn(metaDatas); when(param.getParamConfig()).thenReturn(paramConfig); assertEquals("expected", MultiParts.getContentType(param)); }
@Test public void getContentTypeShouldReturnNullWhenNoContentTypeIsFoundInParamMetas(){ Map<String,Object> metaDatas = new HashMap<String, Object>(); Param param = mock(Param.class); ParamConfig paramConfig = mock(ParamConfig.class); when(paramConfig .getMetaDatas()).thenReturn(metaDatas); when(param.getParamConfig()).thenReturn(paramConfig); assertNull(MultiParts.getContentType(param)); }