-
- @Rule
- public ExpectedException expectedEx = ExpectedException.none();
-
- @Test
- public void testGetStrategy(){
- ShardStrategy strategy = ShardStrategyFactory.getStrategy(TestModel.TEST_PATH);
- assertNotNull(strategy);
- }
-
- @Test
- public void testGetStrategyNullPointerExceptionWhenPathIsNull(){
- expectedEx.expect(NullPointerException.class);
- expectedEx.expectMessage("path should not be null");
-
- ShardStrategyFactory.getStrategy(null);
- }
-
-}
\ No newline at end of file
+ private ShardStrategyFactory factory;
+
+ @Before
+ public void setUp() {
+ factory = new ShardStrategyFactory(new ConfigurationImpl("module-shards.conf", "modules.conf"),
+ LogicalDatastoreType.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());
+ }
+}