ResourceStringConverterImpl implements ResourceStringConverter { @Override public ResourceInfo getResourceInfo(String resourceString) { if (resourceString == null) { return new eu.clarin.cmdi.vlo.pojo.ResourceInfo(null, null, null, null, null, ResourceType.OTHER); } else { eu.clarin.cmdi.vlo.ResourceInfo resourceInfo = eu.clarin.cmdi.vlo.ResourceInfo.fromJson(objectMapper, resourceString); if (resourceInfo == null) { logger.warn("Resource string could not be parsed: {}", resourceString); return new eu.clarin.cmdi.vlo.pojo.ResourceInfo(null, null, null, null, null, ResourceType.OTHER); } final String mimeType = resourceInfo.getType(); final String href = resourceInfo.getUrl(); final String fileName; if (resolver == null) { fileName = getFileName(href); } else { fileName = getFileName(resolver.resolve(href)); } final ResourceType resourceType = determineResourceType(mimeType); return new ResourceInfo( href, (fileName == null || fileName.isEmpty()) ? href : fileName, mimeType, resourceInfo.getStatus(), resourceInfo.getLastChecked(), resourceType); } } ResourceStringConverterImpl();  ResourceStringConverterImpl(UriResolver resolver); @Override ResourceInfo getResourceInfo(String resourceString); @Override void doPreflight(String uri); @Override UriResolver getResolver();  }
@Test public void testGetResourceInfoVideo() { final String resourceString = createResourceString("video/mpeg", "href"); ResourceInfo result = instance.getResourceInfo(resourceString); assertEquals("href", result.getHref()); assertEquals("video/mpeg", result.getMimeType()); assertEquals(ResourceType.VIDEO, result.getResourceType()); }
@Test public void testGetResourceInfoVideoInvalid() { final String resourceString = createResourceString("video/mpeg", "video href"); ResourceInfo result = instance.getResourceInfo(resourceString); assertEquals("video href", result.getHref()); }
@Test public void testGetResourceInfoAudio() { final String resourceString = createResourceString("audio/ogg", "href"); ResourceInfo result = instance.getResourceInfo(resourceString); assertEquals("href", result.getHref()); assertEquals("audio/ogg", result.getMimeType()); assertEquals(ResourceType.AUDIO, result.getResourceType()); }
@Test public void testGetResourceInfoText() { final String resourceString = createResourceString("text/plain", "href"); ResourceInfo result = instance.getResourceInfo(resourceString); assertEquals("href", result.getHref()); assertEquals("text/plain", result.getMimeType()); assertEquals(ResourceType.TEXT, result.getResourceType()); }
@Test public void testGetResourceInfoAnnotation() { final String resourceString = createResourceString("text/x-chat", "href"); ResourceInfo result = instance.getResourceInfo(resourceString); assertEquals("href", result.getHref()); assertEquals("text/x-chat", result.getMimeType()); assertEquals(ResourceType.ANNOTATION, result.getResourceType()); }
@Test public void testGetResourceInfoArchive() { final String resourceString = createResourceString("application/zip", "href"); ResourceInfo result = instance.getResourceInfo(resourceString); assertEquals("href", result.getHref()); assertEquals("application/zip", result.getMimeType()); assertEquals(ResourceType.ARCHIVE, result.getResourceType()); }
@Test public void testGetResourceInfoOther() { final String resourceString = createResourceString("application/octet-stream", "href"); ResourceInfo result = instance.getResourceInfo(resourceString); assertEquals("href", result.getHref()); assertEquals("application/octet-stream", result.getMimeType()); assertEquals(ResourceType.OTHER, result.getResourceType()); }