@Test public void testNewServiceAccessPoint() throws Exception { ETLStatistics etlStatistics = new ETLStatistics(); CSVRecordInfo<BrahmsCsvField> record = mock(CSVRecordInfo.class); when(record.get(BrahmsCsvField.IMAGELIST)).thenReturn("http: BrahmsMultiMediaTransformer brahmsMultiMediaTransformer = new BrahmsMultiMediaTransformer(etlStatistics); CommonReflectionUtil.setField(AbstractTransformer.class, brahmsMultiMediaTransformer, "objectID", "L.3355550"); CommonReflectionUtil.setField(AbstractTransformer.class, brahmsMultiMediaTransformer, "input", record); URI uri = new URI("https: Object obj = CommonReflectionUtil.callMethod(uri, URI.class, brahmsMultiMediaTransformer, "newServiceAccessPoint"); ServiceAccessPoint serviceAccessPoint = (ServiceAccessPoint) obj; assertNotNull("01", obj); assertEquals("02", ServiceAccessPoint.class, serviceAccessPoint.getClass()); assertEquals("03", uri, serviceAccessPoint.getAccessUri()); assertEquals("04", "image/jpeg", serviceAccessPoint.getFormat()); assertEquals("05", "ac:GoodQuality", serviceAccessPoint.getVariant()); uri = new URI("https: obj = CommonReflectionUtil.callMethod(uri, URI.class, brahmsMultiMediaTransformer, "newServiceAccessPoint"); serviceAccessPoint = (ServiceAccessPoint) obj; assertEquals("06", uri, serviceAccessPoint.getAccessUri()); uri = new URI("https: obj = CommonReflectionUtil.callMethod(uri, URI.class, brahmsMultiMediaTransformer, "newServiceAccessPoint"); assertNull("07", obj); }
private ServiceAccessPoint newServiceAccessPoint(URI uri) { String mimeType = DEFAULT_MIME_TYPE; Pattern pattern = Pattern.compile("^.*id/(.*)/format/(.*)$"); Matcher matcher = pattern.matcher(uri.getRawPath()); String mediaObjectId = ""; String format = "large"; if (matcher.matches()) { mediaObjectId = matcher.group(1); if (!medialibIdsCache.contains(mediaObjectId)) { if (!suppressErrors) { warn("Not an existing medialib URL: %s", uri.toString()); } return null; } format = matcher.group(2); mimeType = mimetypeCache.getMimeType(mediaObjectId); } else { return null; } URI httpsUri; try { httpsUri = new URI(MEDIALIB_HTTPS_URL + mediaObjectId + "/format/" + format ); } catch (URISyntaxException e) { warn("Incorrect URI for use in ServiceAccessPoint: %s", MEDIALIB_HTTPS_URL + mediaObjectId + "/format/" + format); return null; } return new ServiceAccessPoint(httpsUri, mimeType, DEFAULT_IMAGE_QUALITY); }
BrahmsMultiMediaTransformer extends BrahmsTransformer<MultiMediaObject> { private ServiceAccessPoint newServiceAccessPoint(URI uri) { String mimeType = DEFAULT_MIME_TYPE; Pattern pattern = Pattern.compile("^.*id/(.*)/format/(.*)$"); Matcher matcher = pattern.matcher(uri.getRawPath()); String mediaObjectId = ""; String format = "large"; if (matcher.matches()) { mediaObjectId = matcher.group(1); if (!medialibIdsCache.contains(mediaObjectId)) { if (!suppressErrors) { warn("Not an existing medialib URL: %s", uri.toString()); } return null; } format = matcher.group(2); mimeType = mimetypeCache.getMimeType(mediaObjectId); } else { return null; } URI httpsUri; try { httpsUri = new URI(MEDIALIB_HTTPS_URL + mediaObjectId + "/format/" + format ); } catch (URISyntaxException e) { warn("Incorrect URI for use in ServiceAccessPoint: %s", MEDIALIB_HTTPS_URL + mediaObjectId + "/format/" + format); return null; } return new ServiceAccessPoint(httpsUri, mimeType, DEFAULT_IMAGE_QUALITY); } }
BrahmsMultiMediaTransformer extends BrahmsTransformer<MultiMediaObject> { private ServiceAccessPoint newServiceAccessPoint(URI uri) { String mimeType = DEFAULT_MIME_TYPE; Pattern pattern = Pattern.compile("^.*id/(.*)/format/(.*)$"); Matcher matcher = pattern.matcher(uri.getRawPath()); String mediaObjectId = ""; String format = "large"; if (matcher.matches()) { mediaObjectId = matcher.group(1); if (!medialibIdsCache.contains(mediaObjectId)) { if (!suppressErrors) { warn("Not an existing medialib URL: %s", uri.toString()); } return null; } format = matcher.group(2); mimeType = mimetypeCache.getMimeType(mediaObjectId); } else { return null; } URI httpsUri; try { httpsUri = new URI(MEDIALIB_HTTPS_URL + mediaObjectId + "/format/" + format ); } catch (URISyntaxException e) { warn("Incorrect URI for use in ServiceAccessPoint: %s", MEDIALIB_HTTPS_URL + mediaObjectId + "/format/" + format); return null; } return new ServiceAccessPoint(httpsUri, mimeType, DEFAULT_IMAGE_QUALITY); } BrahmsMultiMediaTransformer(ETLStatistics stats); }
BrahmsMultiMediaTransformer extends BrahmsTransformer<MultiMediaObject> { private ServiceAccessPoint newServiceAccessPoint(URI uri) { String mimeType = DEFAULT_MIME_TYPE; Pattern pattern = Pattern.compile("^.*id/(.*)/format/(.*)$"); Matcher matcher = pattern.matcher(uri.getRawPath()); String mediaObjectId = ""; String format = "large"; if (matcher.matches()) { mediaObjectId = matcher.group(1); if (!medialibIdsCache.contains(mediaObjectId)) { if (!suppressErrors) { warn("Not an existing medialib URL: %s", uri.toString()); } return null; } format = matcher.group(2); mimeType = mimetypeCache.getMimeType(mediaObjectId); } else { return null; } URI httpsUri; try { httpsUri = new URI(MEDIALIB_HTTPS_URL + mediaObjectId + "/format/" + format ); } catch (URISyntaxException e) { warn("Incorrect URI for use in ServiceAccessPoint: %s", MEDIALIB_HTTPS_URL + mediaObjectId + "/format/" + format); return null; } return new ServiceAccessPoint(httpsUri, mimeType, DEFAULT_IMAGE_QUALITY); } BrahmsMultiMediaTransformer(ETLStatistics stats);  }
BrahmsMultiMediaTransformer extends BrahmsTransformer<MultiMediaObject> { private ServiceAccessPoint newServiceAccessPoint(URI uri) { String mimeType = DEFAULT_MIME_TYPE; Pattern pattern = Pattern.compile("^.*id/(.*)/format/(.*)$"); Matcher matcher = pattern.matcher(uri.getRawPath()); String mediaObjectId = ""; String format = "large"; if (matcher.matches()) { mediaObjectId = matcher.group(1); if (!medialibIdsCache.contains(mediaObjectId)) { if (!suppressErrors) { warn("Not an existing medialib URL: %s", uri.toString()); } return null; } format = matcher.group(2); mimeType = mimetypeCache.getMimeType(mediaObjectId); } else { return null; } URI httpsUri; try { httpsUri = new URI(MEDIALIB_HTTPS_URL + mediaObjectId + "/format/" + format ); } catch (URISyntaxException e) { warn("Incorrect URI for use in ServiceAccessPoint: %s", MEDIALIB_HTTPS_URL + mediaObjectId + "/format/" + format); return null; } return new ServiceAccessPoint(httpsUri, mimeType, DEFAULT_IMAGE_QUALITY); } BrahmsMultiMediaTransformer(ETLStatistics stats);   }