@Test public void testCreateRepeatingGroupWithFieldsInGroup() { Cdr parent = new Cdr("Parent"); CdrItem groupItem = new CdrItem(CdrItem.CdrItemType.CDR_ARRAY); groupItem.setCdrs(new ArrayList<>()); parent.setItem("Child", groupItem); when(handlers.preTreatParams(anyString())).thenCallRealMethod(); when(handlers.getSentMessage("Parent")).thenReturn(parent); fixtures.createRepeatingGroupWithFieldsInGroup("Child2", "field1=value1,field2=value2", "Child", "Parent"); assertNotNull(groupItem.getCdrs()); assertEquals(1, groupItem.getCdrs().size()); Cdr child = groupItem.getCdrs().get(0); assertEquals("Child", child.getType()); assertTrue(child.containsKey("Child2")); CdrItem child2 = child.getItem("Child2"); assertEquals(CdrItem.CdrItemType.CDR_ARRAY, child2.getType()); assertEquals(1, child2.getCdrs().size()); Cdr nestedChild = child2.getCdrs().get(0); assertTrue(nestedChild.containsKey("field1")); assertEquals("value1", nestedChild.getAsString("field1")); assertTrue(nestedChild.containsKey("field2")); assertEquals("value2", nestedChild.getAsString("field2")); }
@Then("create a repeating group \"([^\"]*)\" with \"([^\"]*)\" in group \"([^\"]*)\" in message \"([^\"]*)\"") public void createRepeatingGroupWithFieldsInGroup(String groupType, String params, String existingGroup, String messageName) { Cdr message = getMessage(messageName); Cdr group = getGroup(message, messageName, existingGroup); Cdr fields = ParserUtils.stringToCdr(groupType, handlers.preTreatParams(params)); if (group.containsKey(groupType)) { group.getItem(groupType).addCdrToList(fields); } else { CdrItem cdrItem = new CdrItem(CdrItem.CdrItemType.CDR_ARRAY); cdrItem.addCdrToList(fields); group.setItem(groupType, cdrItem); } }
FixFixtures { @Then("create a repeating group \"([^\"]*)\" with \"([^\"]*)\" in group \"([^\"]*)\" in message \"([^\"]*)\"") public void createRepeatingGroupWithFieldsInGroup(String groupType, String params, String existingGroup, String messageName) { Cdr message = getMessage(messageName); Cdr group = getGroup(message, messageName, existingGroup); Cdr fields = ParserUtils.stringToCdr(groupType, handlers.preTreatParams(params)); if (group.containsKey(groupType)) { group.getItem(groupType).addCdrToList(fields); } else { CdrItem cdrItem = new CdrItem(CdrItem.CdrItemType.CDR_ARRAY); cdrItem.addCdrToList(fields); group.setItem(groupType, cdrItem); } } }
FixFixtures { @Then("create a repeating group \"([^\"]*)\" with \"([^\"]*)\" in group \"([^\"]*)\" in message \"([^\"]*)\"") public void createRepeatingGroupWithFieldsInGroup(String groupType, String params, String existingGroup, String messageName) { Cdr message = getMessage(messageName); Cdr group = getGroup(message, messageName, existingGroup); Cdr fields = ParserUtils.stringToCdr(groupType, handlers.preTreatParams(params)); if (group.containsKey(groupType)) { group.getItem(groupType).addCdrToList(fields); } else { CdrItem cdrItem = new CdrItem(CdrItem.CdrItemType.CDR_ARRAY); cdrItem.addCdrToList(fields); group.setItem(groupType, cdrItem); } } FixFixtures(EtiqetHandlers handlers); }
FixFixtures { @Then("create a repeating group \"([^\"]*)\" with \"([^\"]*)\" in group \"([^\"]*)\" in message \"([^\"]*)\"") public void createRepeatingGroupWithFieldsInGroup(String groupType, String params, String existingGroup, String messageName) { Cdr message = getMessage(messageName); Cdr group = getGroup(message, messageName, existingGroup); Cdr fields = ParserUtils.stringToCdr(groupType, handlers.preTreatParams(params)); if (group.containsKey(groupType)) { group.getItem(groupType).addCdrToList(fields); } else { CdrItem cdrItem = new CdrItem(CdrItem.CdrItemType.CDR_ARRAY); cdrItem.addCdrToList(fields); group.setItem(groupType, cdrItem); } } FixFixtures(EtiqetHandlers handlers); @Then("create a repeating group \"([^\"]*)\" in message \"([^\"]*)\"") void createRepeatingGroup(String groupType, String messageName); @Then("create a repeating group \"([^\"]*)\" with \"([^\"]*)\" in message \"([^\"]*)\"") void createRepeatingGroupWithFields(String groupType, String params, String messageName); @Then("create a repeating group \"([^\"]*)\" in group \"([^\"]*)\" in message \"([^\"]*)\"") void createRepeatingGroupInGroup(String groupType, String existingGroup, String messageName); @Then("create a repeating group \"([^\"]*)\" with \"([^\"]*)\" in group \"([^\"]*)\" in message \"([^\"]*)\"") void createRepeatingGroupWithFieldsInGroup(String groupType, String params, String existingGroup, String messageName); @Then("add fields \"([^\"]*)\" to \"([^\"]*)\" group in message \"([^\"]*)\"") void addFieldsToRepeatingGroup(String params, String groupType, String messageName); }
FixFixtures { @Then("create a repeating group \"([^\"]*)\" with \"([^\"]*)\" in group \"([^\"]*)\" in message \"([^\"]*)\"") public void createRepeatingGroupWithFieldsInGroup(String groupType, String params, String existingGroup, String messageName) { Cdr message = getMessage(messageName); Cdr group = getGroup(message, messageName, existingGroup); Cdr fields = ParserUtils.stringToCdr(groupType, handlers.preTreatParams(params)); if (group.containsKey(groupType)) { group.getItem(groupType).addCdrToList(fields); } else { CdrItem cdrItem = new CdrItem(CdrItem.CdrItemType.CDR_ARRAY); cdrItem.addCdrToList(fields); group.setItem(groupType, cdrItem); } } FixFixtures(EtiqetHandlers handlers); @Then("create a repeating group \"([^\"]*)\" in message \"([^\"]*)\"") void createRepeatingGroup(String groupType, String messageName); @Then("create a repeating group \"([^\"]*)\" with \"([^\"]*)\" in message \"([^\"]*)\"") void createRepeatingGroupWithFields(String groupType, String params, String messageName); @Then("create a repeating group \"([^\"]*)\" in group \"([^\"]*)\" in message \"([^\"]*)\"") void createRepeatingGroupInGroup(String groupType, String existingGroup, String messageName); @Then("create a repeating group \"([^\"]*)\" with \"([^\"]*)\" in group \"([^\"]*)\" in message \"([^\"]*)\"") void createRepeatingGroupWithFieldsInGroup(String groupType, String params, String existingGroup, String messageName); @Then("add fields \"([^\"]*)\" to \"([^\"]*)\" group in message \"([^\"]*)\"") void addFieldsToRepeatingGroup(String params, String groupType, String messageName);  }