GolangHostedFacetImpl extends FacetSupport implements GolangHostedFacet { @Transactional @Override public Content getList(final String module) { checkNotNull(module); StorageTx tx = UnitOfWork.currentTx(); Iterable<Asset> assetsForModule = golangDataAccess.findAssetsForModule(tx, getRepository(), module); List<String> collection = StreamSupport.stream(assetsForModule.spliterator(), false) .filter(asset -> PACKAGE.name().equals(asset.formatAttributes().get(P_ASSET_KIND))) .map(Asset::name) .map(name -> name.split("/@v/")[1]) .map(name -> name.replaceAll(".zip", "")) .collect(Collectors.toList()); if (collection.isEmpty()) { return null; } String listOfVersions = String.join("\n", collection); return new Content(new BytesPayload(listOfVersions.getBytes(UTF_8), TEXT_PLAIN)); } @Inject  GolangHostedFacetImpl(final GolangDataAccess golangDataAccess,
                               final CompressedContentExtractor compressedContentExtractor); @Override @Nullable @Transactional Content getInfo(final String path,
                         final GolangAttributes golangAttributes); @Transactional @Override Content getList(final String module); @Nullable @TransactionalTouchBlob @Override Content getPackage(final String path); @Nullable @TransactionalTouchBlob @Override Content getMod(final String path); @Override void upload(final String path,
                     final GolangAttributes golangAttributes,
                     final Payload payload,
                     final AssetKind assetKind);  }
@Test public void getList() throws IOException { String expected = "v1.0.0\nv1.0.1"; String name = "module/@v/v1.0.0.list"; NestedAttributesMap attributesMap = mock(NestedAttributesMap.class); when(attributesMap.get("asset_kind")).thenReturn(PACKAGE.name()); when(asset1.name()).thenReturn("modulename/@v/v1.0.0.zip"); when(asset1.formatAttributes()).thenReturn(attributesMap); when(asset2.name()).thenReturn("modulename/@v/v1.0.1.zip"); when(asset2.formatAttributes()).thenReturn(attributesMap); when(dataAccess.findAssetsForModule(tx, repository, name)).thenReturn( ImmutableList.of(asset1, asset2) ); Content content = underTest.getList(name); String response = CharStreams.toString(new InputStreamReader(content.openInputStream(), Charsets.UTF_8)); assertThat(response, is(equalTo(expected))); }