• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

devonfw / IDEasy / 9890974755

11 Jul 2024 11:59AM UTC coverage: 61.761% (+0.003%) from 61.758%
9890974755

push

github

web-flow
#472: added missing directory (#473)

1987 of 3535 branches covered (56.21%)

Branch coverage included in aggregate %.

5278 of 8228 relevant lines covered (64.15%)

2.81 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

57.58
cli/src/main/java/com/devonfw/tools/ide/merge/TextMerger.java
1
package com.devonfw.tools.ide.merge;
2

3
import com.devonfw.tools.ide.context.IdeContext;
4
import com.devonfw.tools.ide.environment.EnvironmentVariables;
5

6
import java.io.BufferedReader;
7
import java.io.IOException;
8
import java.nio.file.Files;
9
import java.nio.file.Path;
10

11
/**
12
 * Implementation of {@link FileMerger} for Text files.
13
 */
14
public class TextMerger extends FileMerger {
1✔
15

16
  /**
17
   * The constructor.
18
   *
19
   * @param context the {@link #context}.
20
   */
21
  public TextMerger(IdeContext context) {
22

23
    super(context);
3✔
24
  }
1✔
25

26
  @Override
27
  public void merge(Path setup, Path update, EnvironmentVariables variables, Path workspace) {
28

29
    Path template = update;
2✔
30
    if (!Files.exists(template)) {
5!
31
      template = setup;
×
32
      assert Files.exists(template);
×
33
      if (Files.exists(workspace)) {
×
34
        return; // setup is only applied for initial setup if workspace file does not yet exist
×
35
      }
36
    }
37
    StringBuilder inputBuffer = new StringBuilder();
4✔
38
    try (BufferedReader reader = Files.newBufferedReader(template)) {
3✔
39
      String line;
40
      String resolvedValue;
41
      while ((line = reader.readLine()) != null) {
5✔
42
        resolvedValue = variables.resolve(line, template.toString(), this.legacySupport);
8✔
43
        inputBuffer.append(resolvedValue);
4✔
44
        inputBuffer.append('\n');
5✔
45
      }
46
    } catch (IOException e) {
×
47
      throw new IllegalStateException("Could not read text file: " + workspace, e);
×
48
    }
1✔
49
    try {
50
      ensureParentDirectoryExists(workspace);
2✔
51
      Files.write(workspace, inputBuffer.toString().getBytes());
8✔
52
    } catch (IOException e) {
×
53
      throw new IllegalStateException("Could not write to text file: " + workspace, e);
×
54
    }
1✔
55

56
  }
1✔
57

58
  @Override
59
  public void inverseMerge(Path workspace, EnvironmentVariables variables, boolean addNewProperties, Path update) {
60

61
  }
×
62
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc