@Test public void testResolve_CustomCommands() throws Exception { List<CustomCommandDefinition> customCommands = new ArrayList<CustomCommandDefinition>(); CustomCommandDefinition cmd1 = new CustomCommandDefinition(); setPrivateField(cmd1, "name", "cmd1"); setPrivateField(cmd1, "background", false); CustomCommandDefinition cmd2 = new CustomCommandDefinition(); setPrivateField(cmd2, "name", "cmd2"); customCommands.add(cmd1); customCommands.add(cmd2); // specified in child only ServiceInfo info = new ServiceInfo(); ServiceInfo parentInfo = new ServiceInfo(); info.setCustomCommands(customCommands); ServiceModule service = resolveService(info, parentInfo); assertEquals(customCommands, service.getModuleInfo().getCustomCommands()); // specified in parent only info.setCustomCommands(null); parentInfo.setCustomCommands(customCommands); service = resolveService(info, parentInfo); assertEquals(customCommands, service.getModuleInfo().getCustomCommands()); // specified in both List<CustomCommandDefinition> parentCustomCommands = new ArrayList<CustomCommandDefinition>(); CustomCommandDefinition cmd3 = new CustomCommandDefinition(); setPrivateField(cmd3, "name", "cmd1"); setPrivateField(cmd3, "background", true); CustomCommandDefinition cmd4 = new CustomCommandDefinition(); setPrivateField(cmd4, "name", "cmd4"); parentCustomCommands.add(cmd3); parentCustomCommands.add(cmd4); info.setCustomCommands(customCommands); parentInfo.setCustomCommands(parentCustomCommands); service = resolveService(info, parentInfo); Collection<CustomCommandDefinition> mergedCommands = service.getModuleInfo().getCustomCommands(); assertEquals(3, mergedCommands.size()); assertTrue(mergedCommands.contains(cmd2)); assertTrue(mergedCommands.contains(cmd3)); assertTrue(mergedCommands.contains(cmd4)); // not set in either info.setCustomCommands(null); parentInfo.setCustomCommands(null); service = resolveService(info, parentInfo); assertTrue(service.getModuleInfo().getCustomCommands().isEmpty()); }