private void addBundleToProduct( final WARProductModelFactory factory, final String id, final IWARProduct product) { IProductPlugin bundle = factory.createPlugin(); bundle.setId(id); bundle.setVersion("0.0.0"); product.addPlugins(new IProductPlugin[] {bundle}); }
private void checkForBannedBundle(final String id) throws Exception { IWARProduct product = createBasicProductWithLibraries(); IProductPlugin plugin = new ProductPlugin(product.getModel()); plugin.setId(id); IProductPlugin[] plugins = new IProductPlugin[] {plugin}; product.addPlugins(plugins); Validator validator = new Validator(product); Validation validation = validator.validate(); assertFalse(validation.isValid()); ValidationError[] errors = validation.getErrors(); boolean foundBannedBundle = false; for (int i = 0; i < errors.length && !foundBannedBundle; i++) { ValidationError error = errors[i]; if (error.getType() == ValidationError.BUNDLE_BANNED) { IProductPlugin bannedPlugin = (IProductPlugin) error.getCausingObject(); String message = error.getMessage(); if (bannedPlugin.getId().equals(id) && message.indexOf(id) != -1) { foundBannedBundle = true; } } } assertTrue(foundBannedBundle); }