use of com.devonfw.cobigen.api.extension.Merger in project cobigen by devonfw.
the class JavaPluginActivator method bindMerger.
@Override
public List<Merger> bindMerger() {
List<Merger> merger = Lists.newLinkedList();
merger.add(new JavaMerger(JAVAMERGE, false));
merger.add(new JavaMerger(JAVAMERGE_OVERRIDE, true));
return merger;
}
use of com.devonfw.cobigen.api.extension.Merger in project cobigen by devonfw.
the class XmlPluginActivator method bindMerger.
@Override
public List<Merger> bindMerger() {
List<Merger> merger = Lists.newLinkedList();
merger.add(new XmlMergerDelegate(defaultMergeSchemaLocation, MergeType.BASEOVERWRITE, false));
merger.add(new XmlMergerDelegate(defaultMergeSchemaLocation, MergeType.BASEATTACHOROVERWRITE, false));
merger.add(new XmlMergerDelegate(defaultMergeSchemaLocation, MergeType.PATCHOVERWRITE, false));
merger.add(new XmlMergerDelegate(defaultMergeSchemaLocation, MergeType.PATCHATTACHOROVERWRITE, false));
// mergers with validation enabled
merger.add(new XmlMergerDelegate(defaultMergeSchemaLocation, MergeType.BASEOVERWRITEVALIDATE, true));
merger.add(new XmlMergerDelegate(defaultMergeSchemaLocation, MergeType.BASEATTACHOROVERWRITEVALIDATE, true));
merger.add(new XmlMergerDelegate(defaultMergeSchemaLocation, MergeType.PATCHOVERWRITEVALIDATE, true));
merger.add(new XmlMergerDelegate(defaultMergeSchemaLocation, MergeType.PATCHATTACHOROVERWRITEVALIDATE, true));
mergerList = merger;
return merger;
}
use of com.devonfw.cobigen.api.extension.Merger in project cobigen by devonfw.
the class TypeScriptMergerTest method testNullAndUndefinedTypes.
/**
* Tests if TypeScript can handle null- and undefined-aware types
*/
@Test
public void testNullAndUndefinedTypes() {
Merger tsMerger = this.activator.bindMerger().stream().filter(e -> e.getType().equals(TypeScriptPluginActivator.TSMERGE)).findFirst().get();
File baseFile = new File(testFileRootPath + "nullBase.ts");
String mergedContents = tsMerger.merge(baseFile, readTSFile("nullPatch.ts"), "UTF-8");
assertEquals(false, mergedContents.contains("Not able to merge") || mergedContents.isEmpty());
}
use of com.devonfw.cobigen.api.extension.Merger in project cobigen by devonfw.
the class TypeScriptMergerTest method testReadingEncoding.
/**
* Tests whether the contents will be rewritten after parsing and printing with the right encoding
*
* @throws IOException test fails
*/
@Test
public void testReadingEncoding() throws IOException {
// Arrange
Merger tsMerger = this.activator.bindMerger().stream().filter(e -> e.getType().equals(TypeScriptPluginActivator.TSMERGE)).findFirst().get();
File baseFile = new File(testFileRootPath + "baseFile_encoding_UTF-8.ts");
File patchFile = new File(testFileRootPath + "patchFile.ts");
String mergedContents = tsMerger.merge(baseFile, FileUtils.readFileToString(patchFile), "UTF-8");
assertThat(mergedContents.contains("Ñ")).isTrue();
baseFile = new File(testFileRootPath + "baseFile_encoding_ISO-8859-1.ts");
mergedContents = "";
assertThat(mergedContents.contains("Ñ"));
}
use of com.devonfw.cobigen.api.extension.Merger in project cobigen by devonfw.
the class TypeScriptMergerTest method testMergingOverrides.
/**
* Checks if the ts-merger can be launched and if the output is correct with patchOverrides = true
*/
@Test
public void testMergingOverrides() {
// arrange
Merger tsMerger = this.activator.bindMerger().stream().filter(e -> e.getType().equals(TypeScriptPluginActivator.TSMERGE_OVERRIDE)).findFirst().get();
File baseFile = new File(testFileRootPath + "baseFile.ts");
// act
String mergedContents = tsMerger.merge(baseFile, readTSFile("patchFile.ts"), "UTF-8");
assertThat(mergedContents).contains("bProperty");
assertThat(mergedContents).contains("aProperty: number = 3");
assertThat(mergedContents).contains("bMethod");
assertThat(mergedContents).contains("aMethod");
assertThat(mergedContents).contains("bProperty");
assertThat(mergedContents).contains("import { c, f } from 'd'");
assertThat(mergedContents).contains("import { a, e } from 'b'");
assertThat(mergedContents).contains("export { e, g } from 'f';");
assertThat(mergedContents).contains("interface a {");
assertThat(mergedContents).contains("private b: string;");
// Should merge comments
assertThat(mergedContents).contains("// Should contain this comment");
mergedContents = tsMerger.merge(baseFile, readTSFile("patchFile.ts"), "ISO-8859-1");
assertThat(mergedContents).contains("aProperty: number = 3");
assertThat(mergedContents).contains("bProperty");
assertThat(mergedContents).contains("bMethod");
assertThat(mergedContents).contains("aMethod");
assertThat(mergedContents).contains("bProperty");
assertThat(mergedContents).contains("import { c, f } from 'd'");
assertThat(mergedContents).contains("import { a, e } from 'b'");
assertThat(mergedContents).contains("export { e, g } from 'f';");
assertThat(mergedContents).contains("interface a {");
assertThat(mergedContents).contains("private b: string;");
// Should merge comments
assertThat(mergedContents).contains("// Should contain this comment");
}
Aggregations