CocoapodsFacetImpl extends FacetSupport implements CocoapodsFacet { @Override @TransactionalStoreBlob public Content getOrCreateAsset(final String assetPath, final Content content, final String componentName, final String componentVersion) throws IOException { return getOrCreateAsset(assetPath, content, componentName, componentVersion, null); }  @Override @Nullable @TransactionalTouchBlob Content get(final String assetPath); @Override @TransactionalDeleteBlob boolean delete(final String assetPath); @Override @TransactionalStoreBlob Content getOrCreateAsset(final String assetPath,
                                  final Content content,
                                  final String componentName,
                                  final String componentVersion); @Override @TransactionalStoreBlob Content getOrCreateAsset(final String assetPath,
                                  final Content content); @Override @TransactionalStoreBlob Content getOrCreateAsset(final String assetPath,
                                  final Content content,
                                  @Nullable final Map<String, String> formatAttributes); @Override @Nullable @TransactionalTouchBlob T getAssetFormatAttribute(final String assetPath, final String attributeName);  }
@Test public void shouldStorePodAssetAndComponent() throws IOException { when(storageTx.findAssetWithProperty(any(), any(), eq(bucket))).thenReturn(null); when(storageTx.findComponents(any(), any())).thenReturn(Collections.emptyList()); component = spy(new DefaultComponent()); when(storageTx.createComponent(any(), any())).thenReturn(component); asset = spy(new Asset()); configAttributeMap(); when(storageTx.createAsset(any(), eq(component))).thenReturn(asset); cocoapodsFacet.getOrCreateAsset(POD_PATH, content, NAME, VERSION); verify(storageTx, times(1)).createAsset(bucket, component); verify(storageTx, times(1)).saveAsset(asset); verify(storageTx, times(1)).createComponent(bucket, format); verify(storageTx, times(1)).saveComponent(component); assertEquals(POD_PATH, asset.name()); assertEquals(NAME, component.name()); assertEquals(VERSION, component.version()); }
@Test public void shouldStoreMetadataAsset() throws IOException { when(storageTx.findAssetWithProperty(any(), any(), eq(bucket))).thenReturn(null); asset = spy(new Asset()); configAttributeMap(); when(storageTx.createAsset(any(), eq(format))).thenReturn(asset); cocoapodsFacet.getOrCreateAsset(POD_PATH, content); verify(storageTx, times(1)).createAsset(bucket, format); verify(storageTx, times(1)).saveAsset(asset); verify(storageTx, times(0)).createComponent(bucket, format); verify(storageTx, times(0)).saveComponent(component); assertEquals(POD_PATH, asset.name()); }
@Test public void shouldStorePodAssetAndGetPodComponent() throws IOException { when(storageTx.findAssetWithProperty(any(), any(), eq(bucket))).thenReturn(null); component = spy(new DefaultComponent()).name(NAME).version(VERSION); when(storageTx.findComponents(any(), any())).thenReturn(Collections.singletonList(component)); asset = spy(new Asset()); configAttributeMap(); when(storageTx.createAsset(any(), eq(component))).thenReturn(asset); cocoapodsFacet.getOrCreateAsset(POD_PATH, content, NAME, VERSION); verify(storageTx, times(1)).createAsset(bucket, component); verify(storageTx, times(1)).saveAsset(asset); verify(storageTx, times(0)).createComponent(bucket, format); verify(storageTx, times(0)).saveComponent(component); assertEquals(POD_PATH, asset.name()); assertEquals(NAME, component.name()); assertEquals(VERSION, component.version()); }
@Test public void shouldGetPodAsset() throws IOException { asset = spy(new Asset()).name(POD_PATH); configAttributeMap(); when(storageTx.findAssetWithProperty(any(), any(), eq(bucket))).thenReturn(asset); cocoapodsFacet.getOrCreateAsset(POD_PATH, content, NAME, VERSION); verify(storageTx, times(0)).createAsset(bucket, component); verify(storageTx, times(1)).saveAsset(asset); verify(storageTx, times(0)).createComponent(bucket, format); verify(storageTx, times(0)).saveComponent(component); assertEquals(POD_PATH, asset.name()); }
@Test public void shouldGetMetadataAsset() throws IOException { asset = spy(new Asset()).name(POD_PATH); configAttributeMap(); when(storageTx.findAssetWithProperty(any(), any(), eq(bucket))).thenReturn(asset); cocoapodsFacet.getOrCreateAsset(POD_PATH, content); verify(storageTx, times(0)).createAsset(bucket, format); verify(storageTx, times(1)).saveAsset(asset); verify(storageTx, times(0)).createComponent(bucket, format); verify(storageTx, times(0)).saveComponent(component); assertEquals(POD_PATH, asset.name()); }