private ImmutableList<String> findOurParty(FpmlPartySelector ourPartySelector) { // check for "any" selector to avoid logging message in normal case if (ourPartySelector == FpmlPartySelector.any()) { return ImmutableList.of(); } List<String> selected = ourPartySelector.selectParties(parties); if (!selected.isEmpty()) { for (String id : selected) { if (!parties.keySet().contains(id)) { throw new FpmlParseException(Messages.format( "Selector returned an ID '{}' that is not present in the document: {}", id, parties)); } } return ImmutableList.copyOf(selected); } log.warn("Failed to resolve \"our\" counterparty from FpML document, using leg defaults instead: " + parties); return ImmutableList.of(); }
public void test_matchingRegex() { assertEquals(FpmlPartySelector.matchingRegex(Pattern.compile("a[12]")).selectParties(MAP), ImmutableList.of("A")); assertEquals(FpmlPartySelector.matchingRegex(Pattern.compile("b")).selectParties(MAP), ImmutableList.of("B")); assertEquals(FpmlPartySelector.matchingRegex(Pattern.compile("c[0-9]")).selectParties(MAP), ImmutableList.of("C1", "C2")); assertEquals(FpmlPartySelector.matchingRegex(Pattern.compile("d")).selectParties(MAP), ImmutableList.of()); }
public void test_matching() { assertEquals(FpmlPartySelector.matching("a1").selectParties(MAP), ImmutableList.of("A")); assertEquals(FpmlPartySelector.matching("a2").selectParties(MAP), ImmutableList.of("A")); assertEquals(FpmlPartySelector.matching("b").selectParties(MAP), ImmutableList.of("B")); assertEquals(FpmlPartySelector.matching("c").selectParties(MAP), ImmutableList.of()); }
public void test_any() { assertEquals(FpmlPartySelector.any().selectParties(MAP), ImmutableList.of()); }