Skip to content

Commit

Permalink
Address review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
mindula committed Aug 13, 2024
1 parent 311d04e commit d5ae614
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ public class XMLToRecordConverterTests {
.resolve("sample_36.xml");
private final Path sample37Bal = RES_DIR.resolve(BAL_DIR)
.resolve("sample_37.bal");
private final Path sample38Bal = RES_DIR.resolve(BAL_DIR)
.resolve("sample_38.bal");

private static final String XMLToRecordServiceEP = "xmlToRecord/convert";

Expand Down Expand Up @@ -589,4 +591,13 @@ public void textXMLWithoutMultipleAttributeAnnotation() throws IOException {
String expectedCodeBlock = Files.readString(sample37Bal).replaceAll("\\s+", "");
Assert.assertEquals(generatedCodeBlock, expectedCodeBlock);
}

@Test(description = "textXMLWithNamespacesAndWithoutAttributeAnnotation")
public void textXMLWithNamespacesAndWithoutAttributeAnnotation() throws IOException {
String xmlFileContent = Files.readString(sample36XML);
String generatedCodeBlock = XMLToRecordConverter.convert(xmlFileContent, false, false, false,
"__text", true, false, true).getCodeBlock().replaceAll("\\s+", "");
String expectedCodeBlock = Files.readString(sample38Bal).replaceAll("\\s+", "");
Assert.assertEquals(generatedCodeBlock, expectedCodeBlock);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
type Book_Title record {
string __text;
string edition;
string format;
string lang;
string pages;
};

type Book_Price record {
decimal __text;
string currency;
};

type Book_Book record {
@xmldata:Namespace {prefix: "book", uri: "http://example.com/books"}
Book_Title title;
@xmldata:Namespace {prefix: "book", uri: "http://example.com/books"}
string author;
@xmldata:Namespace {prefix: "book", uri: "http://example.com/books"}
string publisher;
@xmldata:Namespace {prefix: "book", uri: "http://example.com/books"}
string publish_date;
@xmldata:Namespace {prefix: "book", uri: "http://example.com/books"}
int isbn;
@xmldata:Namespace {prefix: "book", uri: "http://example.com/books"}
Book_Price price;
string available;
string id;
string shelf;
};

type Books record {
string genre;
@xmldata:Namespace {prefix: "book", uri: "http://example.com/books"}
Book_Book book;
};

@xmldata:Name {value: "library"}
type Library record {
Books books;
string established;
string genre;
string location;
};

0 comments on commit d5ae614

Please sign in to comment.