@Test public void getVersion() throws Exception { when(tempBlob.get()).thenReturn(getClass().getResourceAsStream(JAR_NAME)); doReturn(buildWithVersionAndExtension()).when(manifestParser).getAttributesFromBlob(any(), any()); P2Attributes p2Attributes = p2TempBlobUtils .mergeAttributesFromTempBlob(tempBlob, buildWithVersionAndExtension()); assertThat(p2Attributes.getComponentVersion(), is(equalTo(FAKE_VERSION))); }
@VisibleForTesting public P2Attributes mergeAttributesFromTempBlob(final TempBlob tempBlob, final P2Attributes sourceP2Attributes) throws IOException { checkNotNull(sourceP2Attributes.getExtension()); P2Attributes p2Attributes = null; try { p2Attributes = featureXmlParser.getAttributesFromBlob(tempBlob, sourceP2Attributes.getExtension()); if (p2Attributes.isEmpty()) { p2Attributes = manifestParser.getAttributesFromBlob(tempBlob, sourceP2Attributes.getExtension()); } } catch (AttributeParsingException ex) { log.warn("Could not get attributes from feature.xml due to following exception: {}", ex.getMessage()); } return Optional.ofNullable(p2Attributes) .filter(jarP2Attributes -> !jarP2Attributes.isEmpty()) .map(jarP2Attributes -> P2Attributes.builder().merge(sourceP2Attributes, jarP2Attributes).build()) .orElse(sourceP2Attributes); }
P2TempBlobUtils extends ComponentSupport { @VisibleForTesting public P2Attributes mergeAttributesFromTempBlob(final TempBlob tempBlob, final P2Attributes sourceP2Attributes) throws IOException { checkNotNull(sourceP2Attributes.getExtension()); P2Attributes p2Attributes = null; try { p2Attributes = featureXmlParser.getAttributesFromBlob(tempBlob, sourceP2Attributes.getExtension()); if (p2Attributes.isEmpty()) { p2Attributes = manifestParser.getAttributesFromBlob(tempBlob, sourceP2Attributes.getExtension()); } } catch (AttributeParsingException ex) { log.warn("Could not get attributes from feature.xml due to following exception: {}", ex.getMessage()); } return Optional.ofNullable(p2Attributes) .filter(jarP2Attributes -> !jarP2Attributes.isEmpty()) .map(jarP2Attributes -> P2Attributes.builder().merge(sourceP2Attributes, jarP2Attributes).build()) .orElse(sourceP2Attributes); } }
P2TempBlobUtils extends ComponentSupport { @VisibleForTesting public P2Attributes mergeAttributesFromTempBlob(final TempBlob tempBlob, final P2Attributes sourceP2Attributes) throws IOException { checkNotNull(sourceP2Attributes.getExtension()); P2Attributes p2Attributes = null; try { p2Attributes = featureXmlParser.getAttributesFromBlob(tempBlob, sourceP2Attributes.getExtension()); if (p2Attributes.isEmpty()) { p2Attributes = manifestParser.getAttributesFromBlob(tempBlob, sourceP2Attributes.getExtension()); } } catch (AttributeParsingException ex) { log.warn("Could not get attributes from feature.xml due to following exception: {}", ex.getMessage()); } return Optional.ofNullable(p2Attributes) .filter(jarP2Attributes -> !jarP2Attributes.isEmpty()) .map(jarP2Attributes -> P2Attributes.builder().merge(sourceP2Attributes, jarP2Attributes).build()) .orElse(sourceP2Attributes); } @Inject  P2TempBlobUtils(final AttributesParserFeatureXml featureXmlParser,
                         final AttributesParserManifest manifestParser); }
P2TempBlobUtils extends ComponentSupport { @VisibleForTesting public P2Attributes mergeAttributesFromTempBlob(final TempBlob tempBlob, final P2Attributes sourceP2Attributes) throws IOException { checkNotNull(sourceP2Attributes.getExtension()); P2Attributes p2Attributes = null; try { p2Attributes = featureXmlParser.getAttributesFromBlob(tempBlob, sourceP2Attributes.getExtension()); if (p2Attributes.isEmpty()) { p2Attributes = manifestParser.getAttributesFromBlob(tempBlob, sourceP2Attributes.getExtension()); } } catch (AttributeParsingException ex) { log.warn("Could not get attributes from feature.xml due to following exception: {}", ex.getMessage()); } return Optional.ofNullable(p2Attributes) .filter(jarP2Attributes -> !jarP2Attributes.isEmpty()) .map(jarP2Attributes -> P2Attributes.builder().merge(sourceP2Attributes, jarP2Attributes).build()) .orElse(sourceP2Attributes); } @Inject  P2TempBlobUtils(final AttributesParserFeatureXml featureXmlParser,
                         final AttributesParserManifest manifestParser); @VisibleForTesting P2Attributes mergeAttributesFromTempBlob(final TempBlob tempBlob, final P2Attributes sourceP2Attributes); }
P2TempBlobUtils extends ComponentSupport { @VisibleForTesting public P2Attributes mergeAttributesFromTempBlob(final TempBlob tempBlob, final P2Attributes sourceP2Attributes) throws IOException { checkNotNull(sourceP2Attributes.getExtension()); P2Attributes p2Attributes = null; try { p2Attributes = featureXmlParser.getAttributesFromBlob(tempBlob, sourceP2Attributes.getExtension()); if (p2Attributes.isEmpty()) { p2Attributes = manifestParser.getAttributesFromBlob(tempBlob, sourceP2Attributes.getExtension()); } } catch (AttributeParsingException ex) { log.warn("Could not get attributes from feature.xml due to following exception: {}", ex.getMessage()); } return Optional.ofNullable(p2Attributes) .filter(jarP2Attributes -> !jarP2Attributes.isEmpty()) .map(jarP2Attributes -> P2Attributes.builder().merge(sourceP2Attributes, jarP2Attributes).build()) .orElse(sourceP2Attributes); } @Inject  P2TempBlobUtils(final AttributesParserFeatureXml featureXmlParser,
                         final AttributesParserManifest manifestParser); @VisibleForTesting P2Attributes mergeAttributesFromTempBlob(final TempBlob tempBlob, final P2Attributes sourceP2Attributes);  }