Skip to content

Commit

Permalink
#ODOC-115
Browse files Browse the repository at this point in the history
  • Loading branch information
donmendelson committed Jul 7, 2021
1 parent bf1b0d2 commit 4a2a83f
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,29 @@ public DatatypeUnion build() {
}
}
}
if (!found && !DEFAULT_SCENARIO.equals(scenario)) {
CodeSetType codeset = repositoryAdapter.findCodesetByName(type, DEFAULT_SCENARIO);
if (codeset != null) {
CodeSetType clone = repositoryAdapter.copyCodeset(codeset);
clone.setScenario(scenario);
found = true;
union = new DatatypeUnion(clone);
eventLogger.warn(
"RepositoryBuilder missing definition of codeset name={0} scenario={1}; cloning 'base' scenario",
type, scenario);
} else if (referenceRepositoryAdapter != null) {
codeset = referenceRepositoryAdapter.findCodesetByName(type, DEFAULT_SCENARIO);
if (codeset != null) {
CodeSetType clone = repositoryAdapter.copyCodeset(codeset);
clone.setScenario(scenario);
found = true;
union = new DatatypeUnion(clone);
eventLogger.warn(
"RepositoryBuilder missing definition of codeset name={0} scenario={1}; cloning 'base' scenario from reference file",
type, scenario);
}
}
}
if (!found) {
// if not found as a datatype or codeset in either current or referenceRepositoryAdapter
// repository, then assume its a datatype name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,66 @@ void missingCodesetType() throws Exception {
assertTrue(xml.contains("type=\"int\""));
}

@Test // ODOC-115
void codesetType() throws Exception {
String text =
"## Group Parties scenario Test\n"
+ "\n"
+ "| Name | Tag | Presence | Scenario\n"
+ "|---------------------|--------|----------|----------\n"
+ "| NoPartyIDs | 453 | req |\n"
+ "| PartyID | 448 | req |\n"
+ "| PartyIDSource | 447 | req |\n"
+ "| PartyRole | 452 | req |\n"
+ "| PartyRoleQualifier | 2376 | opt | Test\n"
+ "\n"
+ "## Codeset PartyRoleQualifierCodeSet type int scenario Test\n"
+ "\n"
+ "| Name | Value |\n"
+ "|------------------|-------|\n"
+ "| Algorithm | 22 |\n"
+ "| FirmOrLegalEntity| 23 |\n"
+ "| NaturalPerson | 24 |";
InputStream inputStream = new ByteArrayInputStream(text.getBytes());
InputStream referenceStream = new FileInputStream("src/test/resources/OrchestraFIXLatest.xml");
RepositoryBuilder builder = RepositoryBuilder.instance(referenceStream , jsonOutputStream);
ByteArrayOutputStream xmlStream = new ByteArrayOutputStream(8096);
builder.appendInput(inputStream);
builder.write(xmlStream);
builder.closeEventLogger();
String xml = xmlStream.toString();
//System.out.println(xml);
builder.closeEventLogger();
String errors = jsonOutputStream.toString();
//System.out.println(errors);
assertTrue(xml.contains("type=\"int\""));
assertFalse(errors.contains("Datatype added"));
}

@Test // ODOC-115
void codesetType2() throws Exception {
String text =
"## Message NewOrderSingle\n"
+ "\n"
+ "| Name | Tag | Presence | Scenario |\n"
+ "|----------------|----:|:---------:|--------------|\n"
+ "| ClOrdID | 11 | r | |\n"
+ "| OrdType | 40 | r | Test |";
InputStream inputStream = new ByteArrayInputStream(text.getBytes());
InputStream referenceStream = new FileInputStream("src/test/resources/OrchestraFIXLatest.xml");
RepositoryBuilder builder = RepositoryBuilder.instance(referenceStream , jsonOutputStream);
ByteArrayOutputStream xmlStream = new ByteArrayOutputStream(8096);
builder.appendInput(inputStream);
builder.write(xmlStream);
builder.closeEventLogger();
//String xml = xmlStream.toString();
//System.out.println(xml);
builder.closeEventLogger();
String errors = jsonOutputStream.toString();
//System.out.println(errors);
assertFalse(errors.contains("Datatype added"));
}

@Test // ODOC-40
void missingFieldId() throws Exception {
String text =
Expand Down

0 comments on commit 4a2a83f

Please sign in to comment.