| | |
| | | import static java.util.Collections.*; |
| | | |
| | | import static org.assertj.core.api.Assertions.*; |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | @SuppressWarnings("javadoc") |
| | |
| | | { |
| | | byte z = 0; |
| | | final RSInfo info = new RSInfo(rsServerId, rsServerId + ":1389", 0, z, 0); |
| | | return new ReplicationServerInfo(info, newSet(dsIds)); |
| | | return new ReplicationServerInfo(info, newHashSet(dsIds)); |
| | | } |
| | | |
| | | private Map<Integer, ReplicationServerInfo> newMap(ReplicationServerInfo... infos) |
| | |
| | | Map<Integer, ReplicationServerInfo> rsInfos, |
| | | ReplicationServerInfo rsInfo, Integer... connectedDSs) |
| | | { |
| | | return assertContainsRSWithDSs(rsInfos, rsInfo, newSet(connectedDSs)); |
| | | return assertContainsRSWithDSs(rsInfos, rsInfo, newHashSet(connectedDSs)); |
| | | } |
| | | |
| | | private ReplicationServerInfo assertContainsRSWithDSs( |
| | |
| | | public void topologyShouldContainRSWithoutOtherDS(TopologyCtorToUse toUse) |
| | | { |
| | | final Topology topo = newTopology(toUse, |
| | | newMap(OTHER_DS), newList(CURRENT_RS.toRSInfo()), |
| | | newMap(OTHER_DS), newArrayList(CURRENT_RS.toRSInfo()), |
| | | CURRENT_DS.getDsId(), CURRENT_RS.getServerId(), EMPTY_SET, EMPTY_MAP); |
| | | assertInvariants(topo); |
| | | assertThat(topo.rsInfos).hasSize(1); |
| | |
| | | public void topologyShouldContainRSWithAllDSs_buildWithTopologyMsg() |
| | | { |
| | | final Topology topo = newTopology(TopologyCtorToUse.BUILD_WITH_TOPOLOGY_MSG, |
| | | newMap(CURRENT_DS, OTHER_DS), newList(CURRENT_RS.toRSInfo()), |
| | | newMap(CURRENT_DS, OTHER_DS), newArrayList(CURRENT_RS.toRSInfo()), |
| | | CURRENT_DS.getDsId(), CURRENT_RS.getServerId(), EMPTY_SET, EMPTY_MAP); |
| | | assertInvariants(topo); |
| | | assertThat(topo.rsInfos).hasSize(1); |
| | |
| | | { |
| | | final Map<Integer, ReplicationServerInfo> previousRSs = newMap(CURRENT_RS); |
| | | final Topology topo = newTopology(toUse, |
| | | newMap(OTHER_DS), newList(CURRENT_RS.toRSInfo()), |
| | | newMap(OTHER_DS), newArrayList(CURRENT_RS.toRSInfo()), |
| | | CURRENT_DS.getDsId(), CURRENT_RS.getServerId(), EMPTY_SET, previousRSs); |
| | | assertInvariants(topo); |
| | | assertThat(topo.rsInfos).hasSize(1); |
| | |
| | | final ReplicationServerInfo CURRENT_RS_WITHOUT_DS = rsInfo(CURRENT_RS_ID); |
| | | final Map<Integer, ReplicationServerInfo> previousRSs = newMap(CURRENT_RS_WITHOUT_DS); |
| | | final Topology topo = newTopology(toUse, |
| | | newMap(OTHER_DS), newList(CURRENT_RS.toRSInfo()), |
| | | newMap(OTHER_DS), newArrayList(CURRENT_RS.toRSInfo()), |
| | | CURRENT_DS.getDsId(), CURRENT_RS.getServerId(), EMPTY_SET, previousRSs); |
| | | assertInvariants(topo); |
| | | assertThat(topo.rsInfos).hasSize(1); |
| | |
| | | { |
| | | final Map<Integer, ReplicationServerInfo> previousRSs = newMap(CURRENT_RS, MISSING_RS); |
| | | final Topology topo = newTopology(toUse, |
| | | newMap(OTHER_DS), newList(CURRENT_RS.toRSInfo()), |
| | | newMap(OTHER_DS), newArrayList(CURRENT_RS.toRSInfo()), |
| | | CURRENT_DS.getDsId(), CURRENT_RS.getServerId(), EMPTY_SET, previousRSs); |
| | | assertInvariants(topo); |
| | | assertThat(topo.rsInfos).hasSize(1); |
| | |
| | | @SuppressWarnings("unchecked") |
| | | public void topologyShouldHaveStampedLocallyConfiguredRSs_buildWithDsRsLists() |
| | | { |
| | | final Set<String> locallyConfigured = newSet(CURRENT_RS.getServerURL()); |
| | | final Set<String> locallyConfigured = newHashSet(CURRENT_RS.getServerURL()); |
| | | final Topology topo = newTopology(TopologyCtorToUse.BUILD_WITH_DS_RS_LISTS, |
| | | newMap(OTHER_DS), newList(CURRENT_RS.toRSInfo(), ANOTHER_RS.toRSInfo()), |
| | | newMap(OTHER_DS), newArrayList(CURRENT_RS.toRSInfo(), ANOTHER_RS.toRSInfo()), |
| | | CURRENT_DS.getDsId(), CURRENT_RS.getServerId(), locallyConfigured, EMPTY_MAP); |
| | | assertInvariants(topo); |
| | | assertThat(topo.rsInfos).hasSize(2); |
| | |
| | | assertThat(currentRS.isLocallyConfigured()).isTrue(); |
| | | assertThat(anotherRS.isLocallyConfigured()).isFalse(); |
| | | } |
| | | |
| | | } |