AdminDistributionUtils { public void convertFileLocationToDataIfEnabled(EDXLDistribution request) throws LargePayloadException { if (fileUtils.isParsePayloadAsFileLocationEnabled()) { try { if (request.getContentObject() != null) { for (ContentObjectType co : request.getContentObject()) { convertToDataHandler(co); } } } catch (Exception e) { throw new LargePayloadException("Failed to attach payload to message.", e); } } } AdminDistributionUtils(); static AdminDistributionUtils getInstance(); void convertFileLocationToDataIfEnabled(EDXLDistribution request); void convertDataToFileLocationIfEnabled(EDXLDistribution request);  }
@Test public void testConvertFileLocationToDataIfEnabled() throws Exception { AdminDistributionUtils adminUtils = createAdminDistributionUtils(); context.checking(new Expectations() { { oneOf(mockFileUtils).isParsePayloadAsFileLocationEnabled(); will(returnValue(true)); oneOf(mockFileUtils).parseBase64DataAsUri(with(any(DataHandler.class))); will(returnValue(new URI(URI_SAVED_FILE_STRING))); oneOf(mockFileUtils).convertToDataHandler(with(any(File.class))); will(returnValue(createDataHandler())); } }); EDXLDistribution request = createEDXLDistribution(); adminUtils.convertFileLocationToDataIfEnabled(request); DataHandler dh = request.getContentObject().get(0).getNonXMLContent().getContentData(); assertNotNull(dh); }