@Test (expected = IOException.class) public void getNoneP2FileFromJarInputStream() throws AttributeParsingException, IOException { when(tempBlob.get()).thenAnswer((a) -> getClass().getResourceAsStream(NON_P2_JAR)); underTest.getAttributesFromBlob(tempBlob, "zip"); }
@Override public P2Attributes getAttributesFromBlob(final TempBlob tempBlob, final String extension) throws IOException, AttributeParsingException { Builder p2AttributesBuilder = P2Attributes.builder(); Optional<Document> featureXmlOpt = documentJarExtractor.getSpecificEntity(tempBlob, extension, XML_FILE_NAME); Optional<PropertyResourceBundle> propertiesOpt = propertyParser.getBundleProperties(tempBlob, extension, FEATURE_PROPERTIES); if (featureXmlOpt.isPresent()) { Document document = featureXmlOpt.get(); String pluginId = extractValueFromDocument(XML_PLUGIN_NAME_PATH, document); if (pluginId == null) { pluginId = extractValueFromDocument(XML_PLUGIN_ID_PATH, document); } String componentName = propertyParser.extractValueFromProperty(pluginId, propertiesOpt); p2AttributesBuilder .componentName(componentName) .pluginName( propertyParser.extractValueFromProperty(extractValueFromDocument(XML_NAME_PATH, document), propertiesOpt)) .componentVersion(extractValueFromDocument(XML_VERSION_PATH, document)); } return p2AttributesBuilder.build(); }
AttributesParserFeatureXml implements AttributesParser { @Override public P2Attributes getAttributesFromBlob(final TempBlob tempBlob, final String extension) throws IOException, AttributeParsingException { Builder p2AttributesBuilder = P2Attributes.builder(); Optional<Document> featureXmlOpt = documentJarExtractor.getSpecificEntity(tempBlob, extension, XML_FILE_NAME); Optional<PropertyResourceBundle> propertiesOpt = propertyParser.getBundleProperties(tempBlob, extension, FEATURE_PROPERTIES); if (featureXmlOpt.isPresent()) { Document document = featureXmlOpt.get(); String pluginId = extractValueFromDocument(XML_PLUGIN_NAME_PATH, document); if (pluginId == null) { pluginId = extractValueFromDocument(XML_PLUGIN_ID_PATH, document); } String componentName = propertyParser.extractValueFromProperty(pluginId, propertiesOpt); p2AttributesBuilder .componentName(componentName) .pluginName( propertyParser.extractValueFromProperty(extractValueFromDocument(XML_NAME_PATH, document), propertiesOpt)) .componentVersion(extractValueFromDocument(XML_VERSION_PATH, document)); } return p2AttributesBuilder.build(); } }
AttributesParserFeatureXml implements AttributesParser { @Override public P2Attributes getAttributesFromBlob(final TempBlob tempBlob, final String extension) throws IOException, AttributeParsingException { Builder p2AttributesBuilder = P2Attributes.builder(); Optional<Document> featureXmlOpt = documentJarExtractor.getSpecificEntity(tempBlob, extension, XML_FILE_NAME); Optional<PropertyResourceBundle> propertiesOpt = propertyParser.getBundleProperties(tempBlob, extension, FEATURE_PROPERTIES); if (featureXmlOpt.isPresent()) { Document document = featureXmlOpt.get(); String pluginId = extractValueFromDocument(XML_PLUGIN_NAME_PATH, document); if (pluginId == null) { pluginId = extractValueFromDocument(XML_PLUGIN_ID_PATH, document); } String componentName = propertyParser.extractValueFromProperty(pluginId, propertiesOpt); p2AttributesBuilder .componentName(componentName) .pluginName( propertyParser.extractValueFromProperty(extractValueFromDocument(XML_NAME_PATH, document), propertiesOpt)) .componentVersion(extractValueFromDocument(XML_VERSION_PATH, document)); } return p2AttributesBuilder.build(); } @Inject  AttributesParserFeatureXml(final TempBlobConverter tempBlobConverter, final PropertyParser propertyParser); }
AttributesParserFeatureXml implements AttributesParser { @Override public P2Attributes getAttributesFromBlob(final TempBlob tempBlob, final String extension) throws IOException, AttributeParsingException { Builder p2AttributesBuilder = P2Attributes.builder(); Optional<Document> featureXmlOpt = documentJarExtractor.getSpecificEntity(tempBlob, extension, XML_FILE_NAME); Optional<PropertyResourceBundle> propertiesOpt = propertyParser.getBundleProperties(tempBlob, extension, FEATURE_PROPERTIES); if (featureXmlOpt.isPresent()) { Document document = featureXmlOpt.get(); String pluginId = extractValueFromDocument(XML_PLUGIN_NAME_PATH, document); if (pluginId == null) { pluginId = extractValueFromDocument(XML_PLUGIN_ID_PATH, document); } String componentName = propertyParser.extractValueFromProperty(pluginId, propertiesOpt); p2AttributesBuilder .componentName(componentName) .pluginName( propertyParser.extractValueFromProperty(extractValueFromDocument(XML_NAME_PATH, document), propertiesOpt)) .componentVersion(extractValueFromDocument(XML_VERSION_PATH, document)); } return p2AttributesBuilder.build(); } @Inject  AttributesParserFeatureXml(final TempBlobConverter tempBlobConverter, final PropertyParser propertyParser); @Override P2Attributes getAttributesFromBlob(final TempBlob tempBlob, final String extension); }
AttributesParserFeatureXml implements AttributesParser { @Override public P2Attributes getAttributesFromBlob(final TempBlob tempBlob, final String extension) throws IOException, AttributeParsingException { Builder p2AttributesBuilder = P2Attributes.builder(); Optional<Document> featureXmlOpt = documentJarExtractor.getSpecificEntity(tempBlob, extension, XML_FILE_NAME); Optional<PropertyResourceBundle> propertiesOpt = propertyParser.getBundleProperties(tempBlob, extension, FEATURE_PROPERTIES); if (featureXmlOpt.isPresent()) { Document document = featureXmlOpt.get(); String pluginId = extractValueFromDocument(XML_PLUGIN_NAME_PATH, document); if (pluginId == null) { pluginId = extractValueFromDocument(XML_PLUGIN_ID_PATH, document); } String componentName = propertyParser.extractValueFromProperty(pluginId, propertiesOpt); p2AttributesBuilder .componentName(componentName) .pluginName( propertyParser.extractValueFromProperty(extractValueFromDocument(XML_NAME_PATH, document), propertiesOpt)) .componentVersion(extractValueFromDocument(XML_VERSION_PATH, document)); } return p2AttributesBuilder.build(); } @Inject  AttributesParserFeatureXml(final TempBlobConverter tempBlobConverter, final PropertyParser propertyParser); @Override P2Attributes getAttributesFromBlob(final TempBlob tempBlob, final String extension);  }