GolangHostedFacetImpl extends FacetSupport implements GolangHostedFacet { @Override public void upload(final String path, final GolangAttributes golangAttributes, final Payload payload, final AssetKind assetKind) throws IOException { checkNotNull(path); checkNotNull(golangAttributes); checkNotNull(payload); checkNotNull(assetKind); if (assetKind != PACKAGE) { throw new IllegalArgumentException("Unsupported AssetKind"); } storeContent(path, golangAttributes, payload, assetKind); extractAndSaveMod(path, golangAttributes); } @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 upload() throws IOException { String path = "modulename/@v/v1.0.0.zip"; String gomod_path = "modulename/@v/v1.0.0.mod"; GolangAttributes goAttributes = new GolangAttributes(); goAttributes.setModule("modulename"); goAttributes.setVersion("v1.0.0"); StorageFacet storageFacet = mock(StorageFacet.class); TempBlob tempBlob = mock(TempBlob.class); InputStream payloadStream = mock(InputStream.class); when(payload.openInputStream()).thenReturn(payloadStream); when(repository.facet(StorageFacet.class)).thenReturn(storageFacet); when(storageFacet.createTempBlob(payloadStream, GolangDataAccess.HASH_ALGORITHMS)).thenReturn(tempBlob); when(dataAccess.findAsset(any(), any(), any())).thenReturn(asset1); when(dataAccess.getBlobAsPayload(tx, asset1)).thenReturn(payload); when(compressExtractor.fileExists(payload, path, GO_MOD)).thenReturn(true); when(compressExtractor.extractFile(payloadStream, GO_MOD)).thenReturn(payloadStream); underTest.upload(path, goAttributes, payload, PACKAGE); verify(dataAccess).maybeCreateAndSaveComponent(repository, goAttributes, path, tempBlob, payload, PACKAGE); verify(dataAccess).maybeCreateAndSaveComponent(eq(repository), eq(goAttributes), eq(gomod_path), eq(tempBlob), any(), eq(MODULE)); }