MetadataServiceImpl implements MetadataServerSideService { @Override public List<String> getTags(final Path resource) { checkNotNull("MetadataServiceImpl.resource", resource); return getTags(Paths.convert(resource)); } MetadataServiceImpl(); @Inject  MetadataServiceImpl(@Named("ioStrategy") IOService ioService,
                               @Named("configIO") IOService configIOService,
                               CommentedOptionFactory commentedOptionFactory,
                               SessionInfo sessionInfo); @Override Path saveMetadata(final Path path,
                             final Metadata metadata,
                             final String comment); @Override Metadata getMetadata(final Path pathToResource); @Override Metadata getMetadata(org.uberfire.java.nio.file.Path path); @Override List<String> getTags(final Path resource); @Override List<String> getTags(final org.uberfire.java.nio.file.Path resource); @Override Map<String, Object> configAttrs(final Map<String, Object> _attrs,
                                           final Metadata metadata); @Override Map<String, Object> setUpAttributes(final Path path,
                                               final Metadata metadata);  }
@Test public void testGetEmptyTagsNoOtherMetaView() { final List<String> tags = service.getTags(path); assertNotNull(tags); assertEquals(0, tags.size()); }
@Test public void testGetEmptyTags() { when(otherMetaView.readAttributes()).thenReturn(new OtherMetaAttributesMock()); when(ioService.getFileAttributeView(path, OtherMetaView.class)).thenReturn(otherMetaView); final List<String> tags = service.getTags(path); assertNotNull(tags); assertEquals(0, tags.size()); }
@Test public void testGetTags() { when(otherMetaView.readAttributes()).thenReturn(new OtherMetaAttributesMock() { List<String> tags = new ArrayList<String>() {{ add("tag1"); }}; @Override public List<String> tags() { return tags; } }); when(ioService.getFileAttributeView(path, OtherMetaView.class)).thenReturn(otherMetaView); final List<String> tags = service.getTags(path); assertNotNull(tags); assertEquals(1, tags.size()); }