@Test public void testGetServiceAccessPoints() throws Exception { CSVRecordInfo<BrahmsCsvField> record = mock(CSVRecordInfo.class); ETLStatistics etlStatistics = new ETLStatistics(); when(record.get(BrahmsCsvField.IMAGELIST)).thenReturn("http: BrahmsSpecimenTransformer brahmsSpecimenTransformer = new BrahmsSpecimenTransformer(etlStatistics); CommonReflectionUtil.setField(AbstractTransformer.class, brahmsSpecimenTransformer, "objectID", "L.3355550"); CommonReflectionUtil.setField(AbstractTransformer.class, brahmsSpecimenTransformer, "input", record); Object obj = CommonReflectionUtil.callMethod(null, CSVRecordInfo.class, brahmsSpecimenTransformer, "getServiceAccessPoints"); List<ServiceAccessPoint> actualList = (List<ServiceAccessPoint>) obj; String expectedAccessPoint = "https: String actualAccessPoint = actualList.stream().map(i -> i.getAccessUri().toString()).findFirst().get(); assertNotNull("01",actualList); assertEquals("02",expectedAccessPoint, actualAccessPoint); }
private List<ServiceAccessPoint> getServiceAccessPoints() { String images = input.get(IMAGELIST); if (images == null) { return null; } String[] urls = images.split(","); List<ServiceAccessPoint> saps = new ArrayList<>(urls.length); for (int i = 0; i < urls.length; ++i) { String url = urls[i].trim().replaceAll(" ", "%20"); if (url.length() == 0) continue; if (url.startsWith(MEDIALIB_HTTP_URL) && !url.startsWith(MEDIALIB_HTTPS_URL)) { url = url.replace(MEDIALIB_HTTP_URL, MEDIALIB_HTTPS_URL); } String mimeType = DEFAULT_MIME_TYPE; Pattern pattern = Pattern.compile("^.*id/(.*)/format/.*$"); Matcher matcher = pattern.matcher(url); String mediaObjectId = ""; if (matcher.matches()) { mediaObjectId = matcher.group(1); mimeType = mimetypeCache.getMimeType(mediaObjectId); } if (!medialibIdsCache.contains(mediaObjectId)) { if (!suppressErrors) { warn("Not an existing medialib URL: %s", url); } continue; } try { URI uri = new URI(url); saps.add(new ServiceAccessPoint(uri, mimeType, DEFAULT_IMAGE_QUALITY)); } catch (URISyntaxException e) { if (!suppressErrors) { warn("Invalid multimedia URL: %s", url); } } } return saps.size() == 0 ? null : saps; }
BrahmsSpecimenTransformer extends BrahmsTransformer<Specimen> { private List<ServiceAccessPoint> getServiceAccessPoints() { String images = input.get(IMAGELIST); if (images == null) { return null; } String[] urls = images.split(","); List<ServiceAccessPoint> saps = new ArrayList<>(urls.length); for (int i = 0; i < urls.length; ++i) { String url = urls[i].trim().replaceAll(" ", "%20"); if (url.length() == 0) continue; if (url.startsWith(MEDIALIB_HTTP_URL) && !url.startsWith(MEDIALIB_HTTPS_URL)) { url = url.replace(MEDIALIB_HTTP_URL, MEDIALIB_HTTPS_URL); } String mimeType = DEFAULT_MIME_TYPE; Pattern pattern = Pattern.compile("^.*id/(.*)/format/.*$"); Matcher matcher = pattern.matcher(url); String mediaObjectId = ""; if (matcher.matches()) { mediaObjectId = matcher.group(1); mimeType = mimetypeCache.getMimeType(mediaObjectId); } if (!medialibIdsCache.contains(mediaObjectId)) { if (!suppressErrors) { warn("Not an existing medialib URL: %s", url); } continue; } try { URI uri = new URI(url); saps.add(new ServiceAccessPoint(uri, mimeType, DEFAULT_IMAGE_QUALITY)); } catch (URISyntaxException e) { if (!suppressErrors) { warn("Invalid multimedia URL: %s", url); } } } return saps.size() == 0 ? null : saps; } }
BrahmsSpecimenTransformer extends BrahmsTransformer<Specimen> { private List<ServiceAccessPoint> getServiceAccessPoints() { String images = input.get(IMAGELIST); if (images == null) { return null; } String[] urls = images.split(","); List<ServiceAccessPoint> saps = new ArrayList<>(urls.length); for (int i = 0; i < urls.length; ++i) { String url = urls[i].trim().replaceAll(" ", "%20"); if (url.length() == 0) continue; if (url.startsWith(MEDIALIB_HTTP_URL) && !url.startsWith(MEDIALIB_HTTPS_URL)) { url = url.replace(MEDIALIB_HTTP_URL, MEDIALIB_HTTPS_URL); } String mimeType = DEFAULT_MIME_TYPE; Pattern pattern = Pattern.compile("^.*id/(.*)/format/.*$"); Matcher matcher = pattern.matcher(url); String mediaObjectId = ""; if (matcher.matches()) { mediaObjectId = matcher.group(1); mimeType = mimetypeCache.getMimeType(mediaObjectId); } if (!medialibIdsCache.contains(mediaObjectId)) { if (!suppressErrors) { warn("Not an existing medialib URL: %s", url); } continue; } try { URI uri = new URI(url); saps.add(new ServiceAccessPoint(uri, mimeType, DEFAULT_IMAGE_QUALITY)); } catch (URISyntaxException e) { if (!suppressErrors) { warn("Invalid multimedia URL: %s", url); } } } return saps.size() == 0 ? null : saps; } BrahmsSpecimenTransformer(ETLStatistics stats); }
BrahmsSpecimenTransformer extends BrahmsTransformer<Specimen> { private List<ServiceAccessPoint> getServiceAccessPoints() { String images = input.get(IMAGELIST); if (images == null) { return null; } String[] urls = images.split(","); List<ServiceAccessPoint> saps = new ArrayList<>(urls.length); for (int i = 0; i < urls.length; ++i) { String url = urls[i].trim().replaceAll(" ", "%20"); if (url.length() == 0) continue; if (url.startsWith(MEDIALIB_HTTP_URL) && !url.startsWith(MEDIALIB_HTTPS_URL)) { url = url.replace(MEDIALIB_HTTP_URL, MEDIALIB_HTTPS_URL); } String mimeType = DEFAULT_MIME_TYPE; Pattern pattern = Pattern.compile("^.*id/(.*)/format/.*$"); Matcher matcher = pattern.matcher(url); String mediaObjectId = ""; if (matcher.matches()) { mediaObjectId = matcher.group(1); mimeType = mimetypeCache.getMimeType(mediaObjectId); } if (!medialibIdsCache.contains(mediaObjectId)) { if (!suppressErrors) { warn("Not an existing medialib URL: %s", url); } continue; } try { URI uri = new URI(url); saps.add(new ServiceAccessPoint(uri, mimeType, DEFAULT_IMAGE_QUALITY)); } catch (URISyntaxException e) { if (!suppressErrors) { warn("Invalid multimedia URL: %s", url); } } } return saps.size() == 0 ? null : saps; } BrahmsSpecimenTransformer(ETLStatistics stats);  }
BrahmsSpecimenTransformer extends BrahmsTransformer<Specimen> { private List<ServiceAccessPoint> getServiceAccessPoints() { String images = input.get(IMAGELIST); if (images == null) { return null; } String[] urls = images.split(","); List<ServiceAccessPoint> saps = new ArrayList<>(urls.length); for (int i = 0; i < urls.length; ++i) { String url = urls[i].trim().replaceAll(" ", "%20"); if (url.length() == 0) continue; if (url.startsWith(MEDIALIB_HTTP_URL) && !url.startsWith(MEDIALIB_HTTPS_URL)) { url = url.replace(MEDIALIB_HTTP_URL, MEDIALIB_HTTPS_URL); } String mimeType = DEFAULT_MIME_TYPE; Pattern pattern = Pattern.compile("^.*id/(.*)/format/.*$"); Matcher matcher = pattern.matcher(url); String mediaObjectId = ""; if (matcher.matches()) { mediaObjectId = matcher.group(1); mimeType = mimetypeCache.getMimeType(mediaObjectId); } if (!medialibIdsCache.contains(mediaObjectId)) { if (!suppressErrors) { warn("Not an existing medialib URL: %s", url); } continue; } try { URI uri = new URI(url); saps.add(new ServiceAccessPoint(uri, mimeType, DEFAULT_IMAGE_QUALITY)); } catch (URISyntaxException e) { if (!suppressErrors) { warn("Invalid multimedia URL: %s", url); } } } return saps.size() == 0 ? null : saps; } BrahmsSpecimenTransformer(ETLStatistics stats);   }