RHostedFacetImpl extends FacetSupport implements RHostedFacet { @TransactionalStoreBlob protected Asset doPutArchive(final String path, final TempBlob archiveContent, final Payload payload) throws IOException { StorageTx tx = UnitOfWork.currentTx(); RFacet rFacet = facet(RFacet.class); Map<String, String> attributes; try (InputStream is = archiveContent.get()) { attributes = extractDescriptionFromArchive(path, is); } Component component = rFacet.findOrCreateComponent(tx, path, attributes); Asset asset = rFacet.findOrCreateAsset(tx, component, path, attributes); saveAsset(tx, asset, archiveContent, payload); return asset; }  @Override @TransactionalTouchBlob Content getStoredContent(final String contentPath); @Override Asset upload(final String path, final Payload payload); @Override @TransactionalTouchMetadata Content buildAndPutPackagesGz(final String basePath);  }
@Test public void putArchive() throws Exception { List<Component> list = ImmutableList.of(component); when(tempBlob.get()).thenReturn(getClass().getResourceAsStream( "/org/sonatype/nexus/repository/r/internal/" + REAL_PACKAGE)); when(asset.name()).thenReturn(REAL_PACKAGE_PATH); when(assetBlob.getBlob()) .thenReturn(blob); doReturn(assetBlob) .when(storageTx).setBlob(any(), any(), any(), any(), any(), any(), anyBoolean()); when(storageTx.findComponents(any(), any())) .thenReturn(list); when(rFacet.findOrCreateComponent(any(storageTx.getClass()), anyString(), anyMapOf(String.class, String.class))) .thenReturn(component); when(rFacet.findOrCreateAsset(any(storageTx.getClass()), any(component.getClass()), eq(REAL_PACKAGE_PATH), anyMapOf(String.class, String.class))) .thenReturn(asset); underTest.doPutArchive(REAL_PACKAGE_PATH, tempBlob, payload); verify(storageTx).saveAsset(asset); }