GtidSet { public boolean isContainedWithin(GtidSet other) { if (other == null) { return false; } if (this.equals(other)) { return true; } for (UUIDSet uuidSet : uuidSetsByServerId.values()) { UUIDSet thatSet = other.forServerWithId(uuidSet.getUUID()); if (!uuidSet.isContainedWithin(thatSet)) { return false; } } return true; } protected  GtidSet(Map<String, UUIDSet> uuidSetsByServerId);  GtidSet(String gtids); GtidSet retainAll(Predicate<String> sourceFilter); Collection<UUIDSet> getUUIDSets(); UUIDSet forServerWithId(String uuid); boolean isContainedWithin(GtidSet other); GtidSet with(GtidSet other); GtidSet getGtidSetBeginning(); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString();  }
@Test public void shouldCorrectlyDetermineIfSimpleGtidSetIsContainedWithinAnother() { gtids = new GtidSet("7c1de3f2-3fd2-11e6-9cdc-42010af000bc:1-41"); assertThat(gtids.isContainedWithin(new GtidSet("7c1de3f2-3fd2-11e6-9cdc-42010af000bc:1-41"))).isTrue(); assertThat(gtids.isContainedWithin(new GtidSet("7c1de3f2-3fd2-11e6-9cdc-42010af000bc:1-42"))).isTrue(); assertThat(gtids.isContainedWithin(new GtidSet("7c1de3f2-3fd2-11e6-9cdc-42010af000bc:2-41"))).isFalse(); assertThat(gtids.isContainedWithin(new GtidSet("7145bf69-d1ca-11e5-a588-0242ac110004:1"))).isFalse(); }
@Test public void shouldCorrectlyDetermineIfComplexGtidSetIsContainedWithinAnother() { GtidSet connector = new GtidSet("036d85a9-64e5-11e6-9b48-42010af0000c:1-2," + "7145bf69-d1ca-11e5-a588-0242ac110004:1-3200," + "7c1de3f2-3fd2-11e6-9cdc-42010af000bc:1-41"); GtidSet server = new GtidSet("036d85a9-64e5-11e6-9b48-42010af0000c:1-2," + "7145bf69-d1ca-11e5-a588-0242ac110004:1-3202," + "7c1de3f2-3fd2-11e6-9cdc-42010af000bc:1-41"); assertThat(connector.isContainedWithin(server)).isTrue(); }
@Test public void shouldCorrectlyDetermineIfComplexGtidSetWithVariousLineSeparatorsIsContainedWithinAnother() { GtidSet connector = new GtidSet("036d85a9-64e5-11e6-9b48-42010af0000c:1-2," + "7145bf69-d1ca-11e5-a588-0242ac110004:1-3200," + "7c1de3f2-3fd2-11e6-9cdc-42010af000bc:1-41"); Arrays.stream(new String[]{ "\r\n", "\n", "\r" }) .forEach(separator -> { GtidSet server = new GtidSet("036d85a9-64e5-11e6-9b48-42010af0000c:1-2," + separator + "7145bf69-d1ca-11e5-a588-0242ac110004:1-3202," + separator + "7c1de3f2-3fd2-11e6-9cdc-42010af000bc:1-41"); assertThat(connector.isContainedWithin(server)).isTrue(); }); }