Search in sources :

Example 6 with Merger

use of com.devonfw.cobigen.api.extension.Merger in project cobigen by devonfw.

the class HTMLPluginActivator method bindMerger.

@Override
public List<Merger> bindMerger() {
    List<Merger> merger = Lists.newLinkedList();
    merger.add(new AngularMerger(NG_MERGE, false));
    merger.add(new AngularMerger(NG_MERGE_OVERRIDE, true));
    return merger;
}
Also used : AngularMerger(com.devonfw.cobigen.htmlplugin.merger.AngularMerger) Merger(com.devonfw.cobigen.api.extension.Merger) AngularMerger(com.devonfw.cobigen.htmlplugin.merger.AngularMerger)

Example 7 with Merger

use of com.devonfw.cobigen.api.extension.Merger in project cobigen by devonfw.

the class TypeScriptPluginActivator method bindMerger.

@Override
public List<Merger> bindMerger() {
    List<Merger> merger = Lists.newLinkedList();
    merger.add(new TypeScriptMerger(this.externalProcess, TSMERGE, false));
    merger.add(new TypeScriptMerger(this.externalProcess, TSMERGE_OVERRIDE, true));
    return merger;
}
Also used : TypeScriptMerger(com.devonfw.cobigen.tsplugin.merger.TypeScriptMerger) Merger(com.devonfw.cobigen.api.extension.Merger) TypeScriptMerger(com.devonfw.cobigen.tsplugin.merger.TypeScriptMerger)

Example 8 with Merger

use of com.devonfw.cobigen.api.extension.Merger in project cobigen by devonfw.

the class JSONPluginActivator method bindMerger.

@Override
public List<Merger> bindMerger() {
    List<Merger> merger = Lists.newLinkedList();
    merger.add(new JSONMerger(JSONMERGE, false));
    merger.add(new JSONMerger(JSONMERGE_OVERRIDE, true));
    return merger;
}
Also used : JSONMerger(com.devonfw.cobigen.jsonplugin.merger.JSONMerger) Merger(com.devonfw.cobigen.api.extension.Merger) JSONMerger(com.devonfw.cobigen.jsonplugin.merger.JSONMerger)

Example 9 with Merger

use of com.devonfw.cobigen.api.extension.Merger in project cobigen by devonfw.

the class TypeScriptMergerTest method testMergingMassiveFile.

/**
 * We need to test whether we are able to send large amount of data to the server.
 */
@Test
public void testMergingMassiveFile() {
    // arrange
    Merger tsMerger = this.activator.bindMerger().stream().filter(e -> e.getType().equals(TypeScriptPluginActivator.TSMERGE)).findFirst().get();
    File baseFile = new File(testFileRootPath + "massiveFile.ts");
    // act
    String mergedContents = tsMerger.merge(baseFile, readTSFile("patchFile.ts"), "UTF-8");
    assertEquals(false, mergedContents.contains("Not able to merge") || mergedContents.isEmpty());
}
Also used : Merger(com.devonfw.cobigen.api.extension.Merger) File(java.io.File) Test(org.junit.Test)

Example 10 with Merger

use of com.devonfw.cobigen.api.extension.Merger in project cobigen by devonfw.

the class TypeScriptMergerTest method testMergingNoOverrides.

/**
 * Checks if the ts-merger can be launched and if the output is correct with patchOverrides = false
 */
@Test
public void testMergingNoOverrides() {
    // arrange
    Merger tsMerger = this.activator.bindMerger().stream().filter(e -> e.getType().equals(TypeScriptPluginActivator.TSMERGE)).findFirst().get();
    File baseFile = new File(testFileRootPath + "baseFile.ts");
    // Should merge comments
    String regex = " * Should format correctly this line";
    // act
    String mergedContents = tsMerger.merge(baseFile, readTSFile("patchFile.ts"), "UTF-8");
    assertThat(mergedContents).contains("bProperty");
    assertThat(mergedContents).contains("aProperty: number = 2");
    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("export interface a {");
    assertThat(mergedContents).contains("private b: number;");
    assertThat(mergedContents).containsPattern(regex);
    mergedContents = tsMerger.merge(baseFile, readTSFile("patchFile.ts"), "ISO-8859-1");
    assertThat(mergedContents).contains("bProperty");
    assertThat(mergedContents).contains("aProperty: number = 2");
    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("export interface a {");
    assertThat(mergedContents).contains("private b: number;");
    assertThat(mergedContents).containsPattern(regex);
}
Also used : Merger(com.devonfw.cobigen.api.extension.Merger) File(java.io.File) Test(org.junit.Test)

Aggregations

Merger (com.devonfw.cobigen.api.extension.Merger)14 File (java.io.File)7 Test (org.junit.Test)6 CobiGenRuntimeException (com.devonfw.cobigen.api.exception.CobiGenRuntimeException)2 Activation (com.devonfw.cobigen.api.annotation.Activation)1 MergeException (com.devonfw.cobigen.api.exception.MergeException)1 PluginNotAvailableException (com.devonfw.cobigen.api.exception.PluginNotAvailableException)1 GeneratorPluginActivator (com.devonfw.cobigen.api.extension.GeneratorPluginActivator)1 InputReader (com.devonfw.cobigen.api.extension.InputReader)1 TextTemplateEngine (com.devonfw.cobigen.api.extension.TextTemplateEngine)1 TriggerInterpreter (com.devonfw.cobigen.api.extension.TriggerInterpreter)1 AngularMerger (com.devonfw.cobigen.htmlplugin.merger.AngularMerger)1 TemplatesConfiguration (com.devonfw.cobigen.impl.config.TemplatesConfiguration)1 Template (com.devonfw.cobigen.impl.config.entity.Template)1 Trigger (com.devonfw.cobigen.impl.config.entity.Trigger)1 PathExpressionResolver (com.devonfw.cobigen.impl.config.resolver.PathExpressionResolver)1 PluginProcessingException (com.devonfw.cobigen.impl.exceptions.PluginProcessingException)1 UnknownTemplateException (com.devonfw.cobigen.impl.exceptions.UnknownTemplateException)1 JavaMerger (com.devonfw.cobigen.javaplugin.merger.JavaMerger)1 JSONMerger (com.devonfw.cobigen.jsonplugin.merger.JSONMerger)1