ShardStrategyFactory { public ShardStrategy getStrategy(final YangInstanceIdentifier path) { final String moduleName = getModuleName(requireNonNull(path, "path should not be null")); final ShardStrategy shardStrategy = configuration.getStrategyForModule(moduleName); if (shardStrategy == null) { final ShardStrategy strategyForPrefix = configuration.getStrategyForPrefix(new DOMDataTreeIdentifier(logicalStoreType, path)); if (strategyForPrefix == null) { return DefaultShardStrategy.getInstance(); } return strategyForPrefix; } return shardStrategy; } ShardStrategyFactory(final Configuration configuration, final LogicalDatastoreType logicalStoreType); ShardStrategy getStrategy(final YangInstanceIdentifier path); static ShardStrategy newShardStrategyInstance(final String moduleName, final String strategyName,
            final Configuration configuration);  }
@Test public void testGetStrategy() { ShardStrategy strategy = factory.getStrategy(TestModel.TEST_PATH); assertNotNull(strategy); }
@Test public void testGetStrategyForKnownModuleName() { ShardStrategy strategy = factory.getStrategy(YangInstanceIdentifier.of(CarsModel.BASE_QNAME)); assertTrue(strategy instanceof ModuleShardStrategy); }
@Test public void testGetStrategyNullPointerExceptionWhenPathIsNull() { final NullPointerException ex = assertThrows(NullPointerException.class, () -> factory.getStrategy(null)); assertEquals("path should not be null", ex.getMessage()); }