Example #1
0
  @Test
  public void test_loading_of_module_settings() {
    BatchSettings batchSettings = mock(BatchSettings.class);
    when(batchSettings.getDefinitions()).thenReturn(new PropertyDefinitions());
    when(batchSettings.getProperties())
        .thenReturn(
            ImmutableMap.of(
                "overridding", "batch",
                "on-batch", "true"));
    when(batchSettings.getModuleProperties("struts-core"))
        .thenReturn(
            ImmutableMap.of(
                "on-module", "true",
                "overridding", "module"));

    ProjectDefinition module = ProjectDefinition.create().setKey("struts-core");
    Configuration deprecatedConf = new PropertiesConfiguration();

    ModuleSettings moduleSettings = new ModuleSettings(batchSettings, module, deprecatedConf);

    assertThat(moduleSettings.getString("overridding")).isEqualTo("module");
    assertThat(moduleSettings.getString("on-batch")).isEqualTo("true");
    assertThat(moduleSettings.getString("on-module")).isEqualTo("true");

    assertThat(deprecatedConf.getString("overridding")).isEqualTo("module");
    assertThat(deprecatedConf.getString("on-batch")).isEqualTo("true");
    assertThat(deprecatedConf.getString("on-module")).isEqualTo("true");
  }
 @Override
 public boolean isConversionNeeded(ModuleSettings moduleSettings) {
   for (String facetName : myFacetNames) {
     if (facetName != null && !moduleSettings.getFacetElements(facetName).isEmpty()) {
       return true;
     }
   }
   return false;
 }
Example #3
0
  @Test
  public void testOrderedProjects() {
    ProjectDefinition grandParent = ProjectDefinition.create();
    ProjectDefinition parent = ProjectDefinition.create();
    ProjectDefinition child = ProjectDefinition.create();
    grandParent.addSubProject(parent);
    parent.addSubProject(child);

    List<ProjectDefinition> hierarchy = ModuleSettings.getTopDownParentProjects(child);
    assertThat(hierarchy.get(0)).isEqualTo(grandParent);
    assertThat(hierarchy.get(1)).isEqualTo(parent);
    assertThat(hierarchy.get(2)).isEqualTo(child);
  }
  @Override
  public void process(ModuleSettings moduleSettings) throws CannotConvertException {
    final Element facetManagerElement =
        moduleSettings.getComponentElement(FacetManagerImpl.COMPONENT_NAME);
    if (facetManagerElement == null) return;

    final Element[] facetElements =
        getChildren(facetManagerElement, FacetManagerImpl.FACET_ELEMENT);
    for (Element facetElement : facetElements) {
      final String facetType = facetElement.getAttributeValue(FacetManagerImpl.TYPE_ATTRIBUTE);
      for (String facetName : myFacetNames) {
        if (facetName.equals(facetType)) {
          facetElement.detach();
        }
      }
    }
  }