use of org.wildfly.clustering.ee.infinispan.GroupedKey in project wildfly by wildfly.
the class PrimaryOwnerRouteLocatorTestCase method test.
@Test
public void test() {
Function<GroupedKey<String>, Node> locator = mock(Function.class);
Registry<String, Void> registry = mock(Registry.class);
Group group = mock(Group.class);
Node primary = mock(Node.class);
Node local = mock(Node.class);
Node missing = mock(Node.class);
String primaryRoute = "primary";
String localRoute = "local";
when(registry.getGroup()).thenReturn(group);
when(group.getLocalMember()).thenReturn(local);
when(registry.getEntry(local)).thenReturn(new SimpleImmutableEntry<>(localRoute, null));
RouteLocator routeLocator = new PrimaryOwnerRouteLocator(locator, registry);
when(locator.apply(new GroupedKey<>("session"))).thenReturn(primary);
when(registry.getEntry(primary)).thenReturn(new SimpleImmutableEntry<>(primaryRoute, null));
String result = routeLocator.locate("session");
assertSame(primaryRoute, result);
when(locator.apply(new GroupedKey<>("missing"))).thenReturn(missing);
when(registry.getEntry(missing)).thenReturn(null);
result = routeLocator.locate("missing");
assertSame(localRoute, result);
}
Aggregations