Skip to content

Commit 35fd327

Browse files
committed
added matchup dimension name to config
1 parent 67c066d commit 35fd327

File tree

2 files changed

+51
-1
lines changed

2 files changed

+51
-1
lines changed

post-processing-tool/src/main/java/com/bc/fiduceo/post/PostProcessingConfig.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,13 @@ public class PostProcessingConfig {
4040
static final String TAG_NAME_NEW_FILES = "create-new-files";
4141
static final String TAG_NAME_OUTPUT_DIR = "output-directory";
4242
static final String TAG_NAME_OVERWRITE = "overwrite";
43+
static final String TAG_NAME_MATCHUP_DIMENSION= "matchup-dimension-name";
4344

4445
final transient private Document document;
4546
private boolean newFiles;
4647
private String outputDirectory;
4748
private boolean overwrite;
49+
private String matchupDimensionName;
4850
private List<Element> postProcessingElements;
4951

5052
private PostProcessingConfig(Document document) {
@@ -87,6 +89,10 @@ boolean isOverwrite() {
8789
return overwrite;
8890
}
8991

92+
public String getMatchupDimensionName() {
93+
return matchupDimensionName;
94+
}
95+
9096
@SuppressWarnings("unchecked")
9197
private void init() {
9298
final Element rootElement = JDomUtils.getMandatoryRootElement(TAG_NAME_ROOT, document);
@@ -106,6 +112,11 @@ private void init() {
106112
throw new RuntimeException("Either <" + TAG_NAME_NEW_FILES + "> or <" + TAG_NAME_OVERWRITE + "> must be configured.");
107113
}
108114

115+
final Element matchupDimElem = rootElement.getChild(TAG_NAME_MATCHUP_DIMENSION);
116+
if (matchupDimElem != null) {
117+
matchupDimensionName = JDomUtils.getMandatoryText(matchupDimElem);
118+
}
119+
109120
final Element processingsElem = JDomUtils.getMandatoryChild(rootElement, TAG_NAME_POST_PROCESSINGS);
110121
postProcessingElements = processingsElem.getChildren();
111122
if (postProcessingElements.size() == 0) {

post-processing-tool/src/test/java/com/bc/fiduceo/post/PostProcessingConfigTest.java

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public class PostProcessingConfigTest {
4242
private static final String NEW_FILES = PostProcessingConfig.TAG_NAME_NEW_FILES;
4343
private static final String OUTPUT_DIR = PostProcessingConfig.TAG_NAME_OUTPUT_DIR;
4444
private static final String OVERWRITE = PostProcessingConfig.TAG_NAME_OVERWRITE;
45+
private static final String MATCHUP_DIM = PostProcessingConfig.TAG_NAME_MATCHUP_DIMENSION;
4546

4647
private static final String DUMMY_NAME = DummyPostProcessingPlugin.DUMMY_POST_PROCESSING_NAME;
4748
private Element root;
@@ -77,7 +78,32 @@ public void testStore() throws Exception {
7778
pw.println(" <" + DUMMY_NAME + ">C</" + DUMMY_NAME + ">");
7879
pw.println(" </post-processings>");
7980
pw.println("</post-processing-config>");
80-
// pw.println();
81+
pw.flush();
82+
83+
assertEquals(sw.toString().replaceAll("\\s+",""), outputStream.toString().replaceAll("\\s+",""));
84+
}
85+
86+
@Test
87+
public void testStoreWithMatchup() throws Exception {
88+
final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
89+
getConfigWithMatchupDimension("matching").store(outputStream);
90+
91+
final StringWriter sw = new StringWriter();
92+
final PrintWriter pw = new PrintWriter(sw);
93+
pw.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
94+
pw.println("<post-processing-config>");
95+
pw.println(" <create-new-files>");
96+
pw.println(" <output-directory>An_Output_Directory</output-directory>");
97+
pw.println(" </create-new-files>");
98+
pw.println(" <post-processings>");
99+
pw.println(" <" + DUMMY_NAME + ">A</" + DUMMY_NAME + ">");
100+
pw.println(" <" + DUMMY_NAME + ">B</" + DUMMY_NAME + ">");
101+
pw.println(" <" + DUMMY_NAME + ">C</" + DUMMY_NAME + ">");
102+
pw.println(" </post-processings>");
103+
pw.println(" <matchup-dimension-name>");
104+
pw.println(" matching");
105+
pw.println(" </matchup-dimension-name>");
106+
pw.println("</post-processing-config>");
81107
pw.flush();
82108

83109
assertEquals(sw.toString().replaceAll("\\s+",""), outputStream.toString().replaceAll("\\s+",""));
@@ -117,6 +143,13 @@ public void testLoad_createNewFiles() throws Exception {
117143
assertEquals("An_Output_Directory", config.getOutputDirectory());
118144
}
119145

146+
@Test
147+
public void testLoad_matchupDimension() throws Exception {
148+
final PostProcessingConfig config = getConfigWithMatchupDimension("theDimension");
149+
150+
assertEquals("theDimension", config.getMatchupDimensionName());
151+
}
152+
120153
@Test
121154
public void testLoad_overwrite() throws Exception {
122155
root.removeChild(NEW_FILES);
@@ -217,4 +250,10 @@ private PostProcessingConfig getConfig() throws Exception {
217250

218251
return PostProcessingConfig.load(new ByteArrayInputStream(bs.toByteArray()));
219252
}
253+
254+
private PostProcessingConfig getConfigWithMatchupDimension(String dimensionName) throws Exception {
255+
root.addContent(new Element(MATCHUP_DIM).addContent(dimensionName));
256+
257+
return getConfig();
258+
}
220259
}

0 commit comments

Comments
 (0)