@Test
public void testServiceCustomCommandScriptInheritance() throws Exception {
// Test custom command script determination in parent
ServiceInfo service = metaInfo.getService(STACK_NAME_HDP, "2.0.7", "HDFS");
CustomCommandDefinition ccd = findCustomCommand("RESTART", service);
Assert.assertEquals("scripts/restart_parent.py",
ccd.getCommandScript().getScript());
ccd = findCustomCommand("YET_ANOTHER_PARENT_SRV_COMMAND", service);
Assert.assertEquals("scripts/yet_another_parent_srv_command.py",
ccd.getCommandScript().getScript());
Assert.assertEquals(2, service.getCustomCommands().size());
// Test custom command script inheritance
service = metaInfo.getService(STACK_NAME_HDP, "2.0.8", "HDFS");
Assert.assertEquals(3, service.getCustomCommands().size());
ccd = findCustomCommand("YET_ANOTHER_PARENT_SRV_COMMAND", service);
Assert.assertEquals("scripts/yet_another_parent_srv_command.py",
ccd.getCommandScript().getScript());
// Test custom command script override
service = metaInfo.getService(STACK_NAME_HDP, "2.0.8", "HDFS");
ccd = findCustomCommand("RESTART", service);
Assert.assertEquals("scripts/restart_child.py",
ccd.getCommandScript().getScript());
ccd = findCustomCommand("YET_ANOTHER_CHILD_SRV_COMMAND", service);
Assert.assertEquals("scripts/yet_another_child_srv_command.py",
ccd.getCommandScript().getScript());
}