@SuppressWarnings("deprecation")
  @Test
  public void testLoadContentGenerators() throws PlatformPluginRegistrationException {
    microPlatform.define(ISolutionRepository.class, FileBasedSolutionRepository.class).init();
    List<IPlatformPlugin> plugins = provider.getPlugins(new StandaloneSession());

    IPlatformPlugin plugin =
        (IPlatformPlugin)
            CollectionUtils.find(
                plugins, new PluginNameMatcherPredicate("content-generator-plugin"));
    assertNotNull("content-generator-plugin should have been found", plugin);

    List<IContentInfo> contentTypes = plugin.getContentInfos();

    Object contentType =
        CollectionUtils.find(
            contentTypes,
            new Predicate() {
              public boolean evaluate(Object object) {
                IContentInfo type = (IContentInfo) object;
                return type.getTitle().equals("Good Test Type");
              }
            });
    assertNotNull("\"Good Test Type\" should have been loaded", contentType);
    assertNotNull(
        "\"Good Test Type\" extension definition is incorrect",
        ((IContentInfo) contentType).getExtension().equals("good-content-type"));

    assertEquals(
        "\"Test Type Missing type\" should not have been loaded",
        0,
        CollectionUtils.countMatches(
            contentTypes,
            new Predicate() {
              public boolean evaluate(Object object) {
                IContentInfo contentType = (IContentInfo) object;
                return contentType.getTitle().equals("Test Type Missing type");
              }
            }));

    assertEquals(
        "\"test-type-missing-title\" should not have been loaded",
        0,
        CollectionUtils.countMatches(
            contentTypes,
            new Predicate() {
              public boolean evaluate(Object object) {
                IContentInfo contentType = (IContentInfo) object;
                return contentType.getExtension().equals("test-type-missing-title");
              }
            }));
  }
  @SuppressWarnings("deprecation")
  @Test
  public void testLoadBeanDefinition() throws PlatformPluginRegistrationException {
    microPlatform.define(ISolutionRepository.class, FileBasedSolutionRepository.class).init();

    List<IPlatformPlugin> plugins = provider.getPlugins(new StandaloneSession());

    IPlatformPlugin plugin =
        (IPlatformPlugin) CollectionUtils.find(plugins, new PluginNameMatcherPredicate("Plugin 1"));
    assertNotNull("Plugin 1 should have been found", plugin);

    Collection<PluginBeanDefinition> beans = plugin.getBeans();

    assertEquals(
        "FooComponent was not loaded",
        1,
        CollectionUtils.countMatches(
            beans,
            new Predicate() {
              public boolean evaluate(Object object) {
                PluginBeanDefinition bean = (PluginBeanDefinition) object;
                return bean.getBeanId().equals("FooComponent")
                    && bean.getClassname()
                        .equals("org.pentaho.test.platform.plugin.pluginmgr.FooComponent");
              }
            }));
    assertEquals(
        "genericBean was not loaded",
        1,
        CollectionUtils.countMatches(
            beans,
            new Predicate() {
              public boolean evaluate(Object object) {
                PluginBeanDefinition bean = (PluginBeanDefinition) object;
                return bean.getBeanId().equals("genericBean")
                    && bean.getClassname().equals("java.lang.Object");
              }
            }));
  }
Пример #3
0
 private boolean isBarkRecognized(Bark bark) {
   int matches =
       CollectionUtils.countMatches(door.getAllowedBarks(), PredicateUtils.equalPredicate(bark));
   return matches > 0;
 }