### Question:
ViewLocator extends RoundRobinLocator { @Override protected boolean nodeCanBeUsed(final Node node, final Request<? extends Response> request, final ClusterConfig config) { if (request instanceof ScopedRequest && config.bucketConfig(((ScopedRequest) request).bucket()) instanceof CouchbaseBucketConfig) { return ((CouchbaseBucketConfig) config.bucketConfig(((ScopedRequest) request).bucket())) .hasPrimaryPartitionsOnNode(node.identifier().address()); } return false; } ViewLocator();   }### Answer:
@Test void dispatchesOnlyToHostsWithPrimaryPartitionsEnabled() { ViewLocator locator = new ViewLocator(); ViewRequest request = mock(ViewRequest.class); when(request.bucket()).thenReturn("bucket"); CouchbaseBucketConfig bucketConfig = mock(CouchbaseBucketConfig.class); ClusterConfig config = mock(ClusterConfig.class); when(config.bucketConfig("bucket")).thenReturn(bucketConfig); when(bucketConfig.hasPrimaryPartitionsOnNode("1.2.3.4")).thenReturn(true); when(bucketConfig.hasPrimaryPartitionsOnNode("1.2.3.5")).thenReturn(false); Node node1 = mock(Node.class); when(node1.identifier()).thenReturn(new NodeIdentifier("1.2.3.4", 1234)); assertTrue(locator.nodeCanBeUsed(node1, request, config)); Node node2 = mock(Node.class); when(node2.identifier()).thenReturn(new NodeIdentifier("1.2.3.5", 1234)); assertFalse(locator.nodeCanBeUsed(node2, request, config)); }