Skip to content

Commit

Permalink
Bulk Measurable Rating import
Browse files Browse the repository at this point in the history
- fixing test data

#CTCTOWALTZ-3335
#7145
  • Loading branch information
db-waltz committed Sep 24, 2024
1 parent 85ecde6 commit 1190c0c
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@
import org.finos.waltz.common.SetUtilities;
import org.finos.waltz.model.bulk_upload.measurable_rating.BulkMeasurableRatingItem;
import org.finos.waltz.model.bulk_upload.measurable_rating.BulkMeasurableRatingParseResult;
import org.finos.waltz.model.bulk_upload.taxonomy.BulkTaxonomyParseResult;
import org.finos.waltz.service.taxonomy_management.BulkTaxonomyItemParser;
import org.junit.jupiter.api.Test;

import java.util.List;
import java.util.Set;

import static org.finos.waltz.common.IOUtilities.readAsString;
import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class BulkMeasurableRatingItemParserTest {

Expand All @@ -22,23 +23,23 @@ void simpleTSV() {
BulkMeasurableRatingParseResult result = parser.parse(readTestFile("test-measurable-rating-items.tsv"), BulkMeasurableItemParser.InputFormat.TSV);
assertNull(result.error());
assertEquals(3, result.parsedItems().size());
assertNarIds(result.parsedItems(), "109235-1", "109235-1", "324234-1");
assertNarIds(result.parsedItems(), "109-1", "109-1", "324-1");
}

@Test
void simpleCSV() {
BulkMeasurableRatingParseResult result = parser.parse(readTestFile("test-measurable-rating-items.csv"), BulkMeasurableItemParser.InputFormat.CSV);
assertNull(result.error());
assertEquals(3, result.parsedItems().size());
assertNarIds(result.parsedItems(), "109235-1", "109235-1", "324234-1");
assertNarIds(result.parsedItems(), "109-1", "109-1", "324-1");
}

@Test
void simpleJSON() {
BulkMeasurableRatingParseResult result = parser.parse(readTestFile("test-measurable-rating-items.json"), BulkMeasurableItemParser.InputFormat.JSON);
assertNull(result.error());
assertEquals(3, result.parsedItems().size());
assertNarIds(result.parsedItems(), "109235-1", "109235-1", "324234-1");
assertNarIds(result.parsedItems(), "109-1", "109-1", "324-1");
}

private void assertNarIds(List<BulkMeasurableRatingItem> parsedItems, String... resultNarIds) {
Expand Down Expand Up @@ -73,14 +74,14 @@ void parseFailsIfGivenBlanks() {
void parseIgnoresEmptyLines() {
BulkMeasurableRatingParseResult result = parser.parse(readTestFile("test-measurable-rating-items-with-blanks.tsv"), BulkMeasurableItemParser.InputFormat.TSV);
assertEquals(3, result.parsedItems().size());
assertNarIds(result.parsedItems(), "109235-1", "109235-1", "324234-1");
assertNarIds(result.parsedItems(), "109-1", "109-1", "324-1");
}

@Test
void parseIgnoresCommentedLines() {
BulkMeasurableRatingParseResult result = parser.parse(readTestFile("test-measurable-rating-items-with-commented-lines.csv"), BulkMeasurableItemParser.InputFormat.CSV);
assertEquals(2, result.parsedItems().size());
assertNarIds(result.parsedItems(), "109235-1", "324234-1");
assertNarIds(result.parsedItems(), "109-1", "324-1");
}

private void expectEmptyError(BulkMeasurableRatingParseResult result) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
assetCode taxonomy_external_id ratingCode isPrimary comment
109235-1 CT-001 A TRUE comment
109-1 CT-001 A TRUE comment


109235-1 CT-001 A FALSE comment
324234-1 CT-003 A FALSE comment
109-1 CT-001 A FALSE comment
324-1 CT-003 A FALSE comment
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
assetCode, taxonomy_external_id, ratingCode, isPrimary, comment
#109235-1 CT-001 A TRUE comment
#109-1 CT-001 A TRUE comment


109235-1, CT-001, A, FALSE, comment
324234-1, CT-003, A, FALSE, comment
109-1, CT-001, A, FALSE, comment
324-1, CT-003, A, FALSE, comment
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
assetCode, taxonomyExternalId, ratingCode, isPrimary, comment
109235-1, CT-001, A, TRUE, comment
109235-1, CT-001, A, FALSE, comment
324234-1, CT-003, A, FALSE, comment
109-1, CT-001, A, TRUE, comment
109-1, CT-001, A, FALSE, comment
324-1, CT-003, A, FALSE, comment
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
[
{
"assetCode": "109235-1",
"assetCode": "109-1",
"taxonomyExternalId": "CT-001",
"ratingCode": "A",
"isPrimary": "TRUE",
"comment": "comment"
},
{
"assetCode": "109235-1",
"assetCode": "109-1",
"taxonomyExternalId": "CT-001",
"ratingCode": "A",
"isPrimary": "FALSE",
"comment": "comment"
},
{
"assetCode": "324234-1",
"assetCode": "324-1",
"taxonomyExternalId": "CT-003",
"ratingCode": "A",
"isPrimary": "FALSE",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
assetCode taxonomyExternalId ratingCode isPrimary comment
109235-1 CT-001 A TRUE comment
109235-1 CT-001 A FALSE comment
324234-1 CT-003 A FALSE comment
109-1 CT-001 A TRUE comment
109-1 CT-001 A FALSE comment
324-1 CT-003 A FALSE comment

0 comments on commit 1190c0c

Please sign in to comment.