From ff6c3f24e8889ac5a7acc914fdaa64f25bada7f4 Mon Sep 17 00:00:00 2001 From: "milo.simpson" Date: Wed, 22 Jun 2016 10:00:48 -0500 Subject: [PATCH] Bug in duplicate spec line logic. Fixes #218 --- .../common/pathelement/AmpPathElement.java | 1 + .../java/com/bazaarvoice/jolt/ShiftrTest.java | 1 + ...pollaxman_218_duplicate_speclines_bug.json | 34 +++++++++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 jolt-core/src/test/resources/json/shiftr/pollaxman_218_duplicate_speclines_bug.json diff --git a/jolt-core/src/main/java/com/bazaarvoice/jolt/common/pathelement/AmpPathElement.java b/jolt-core/src/main/java/com/bazaarvoice/jolt/common/pathelement/AmpPathElement.java index c662c85c..8d3e86a3 100644 --- a/jolt-core/src/main/java/com/bazaarvoice/jolt/common/pathelement/AmpPathElement.java +++ b/jolt-core/src/main/java/com/bazaarvoice/jolt/common/pathelement/AmpPathElement.java @@ -69,6 +69,7 @@ public AmpPathElement( String key ) { } if ( literal.length() > 0 ) { tok.add( literal.toString() ); + canonicalBuilder.append( literal.toString() ); } tok.trimToSize(); diff --git a/jolt-core/src/test/java/com/bazaarvoice/jolt/ShiftrTest.java b/jolt-core/src/test/java/com/bazaarvoice/jolt/ShiftrTest.java index 1f2c0854..49e6f0c7 100644 --- a/jolt-core/src/test/java/com/bazaarvoice/jolt/ShiftrTest.java +++ b/jolt-core/src/test/java/com/bazaarvoice/jolt/ShiftrTest.java @@ -56,6 +56,7 @@ public Object[][] getTestCaseUnits() { {"objectToArray"}, {"passNullThru"}, {"passThru"}, + {"pollaxman_218_duplicate_speclines_bug"}, {"prefixDataToArray"}, {"prefixedData"}, {"prefixSoupToBuckets"}, diff --git a/jolt-core/src/test/resources/json/shiftr/pollaxman_218_duplicate_speclines_bug.json b/jolt-core/src/test/resources/json/shiftr/pollaxman_218_duplicate_speclines_bug.json new file mode 100644 index 00000000..3bca9739 --- /dev/null +++ b/jolt-core/src/test/resources/json/shiftr/pollaxman_218_duplicate_speclines_bug.json @@ -0,0 +1,34 @@ +{ + "input" : { + "clone1_Physician" : "Physician_10000", + "clone2_Physician" : "Physician_10000", + "clone1_GCPerProIdenInfoPhyInfoStreet" : "Street", + "clone1_GCPerProIdenInfoPhyInfoAddLin2" : "Address1", + "clone1_GCPerProIdenInfoPhyInfoAddLin3" : "Address3", + "clone2_GCPerProIdenInfoPhyInfoStreet" : "Address1", + "clone2_GCPerProIdenInfoPhyInfoAddLin2" : "addresdd" + }, + "spec" : { + // match clone1_Physician and clone2_Physician + "clone*_Physician" : { + // match the RHS of Physician_10000 + "Physician_1000*" : { + // if we matched then grab the "number" of the physician and use that to process the address + "@(2,clone&(1,1)_GCPerProIdenInfoPhyInfoStreet)" : "Physician&(2,1).street", + "@(2,clone&(1,1)_GCPerProIdenInfoPhyInfoAddLin2)" : "Physician&(2,1).adderLin2", + "@(2,clone&(1,1)_GCPerProIdenInfoPhyInfoAddLin3)" : "Physician&(2,1).adderLin3" + } + } + }, + "expected" : { + "Physician1" : { + "street" : "Street", + "adderLin2" : "Address1", + "adderLin3" : "Address3" + }, + "Physician2" : { + "street" : "Address1", + "adderLin2" : "addresdd" + } + } +}