@Test public void testResolve() throws Exception { File parentThemeFile = new File(this.getClass().getClassLoader().getResource("parent-theme.json").getFile()); File childThemeFile = new File(this.getClass().getClassLoader().getResource("child-theme.json").getFile()); ThemeModule parentModule = new ThemeModule(parentThemeFile); ThemeModule childModule = new ThemeModule(childThemeFile); childModule.resolve(parentModule, null, null, null); Theme childTheme = childModule.getModuleInfo().getThemeMap().get(ThemeModule.THEME_KEY); Theme parentTheme = parentModule.getModuleInfo().getThemeMap().get(ThemeModule.THEME_KEY); assertNotNull(childTheme.getThemeConfiguration().getLayouts()); assertEquals(10, parentTheme.getThemeConfiguration().getPlacement().getConfigs().size()); assertEquals(12, childTheme.getThemeConfiguration().getPlacement().getConfigs().size()); assertEquals(10, parentTheme.getThemeConfiguration().getWidgets().size()); assertEquals(12, childTheme.getThemeConfiguration().getWidgets().size()); }
@Override public void resolve(ThemeModule parent, Map<String, StackModule> allStacks, Map<String, ServiceModule> commonServices, Map<String, ExtensionModule> extensions) throws AmbariException { ThemeInfo parentModuleInfo = parent.getModuleInfo(); if (parent.getModuleInfo() != null && !moduleInfo.isDeleted()) { if (moduleInfo.getThemeMap() == null || moduleInfo.getThemeMap().isEmpty()) { moduleInfo.setThemeMap(parentModuleInfo.getThemeMap()); } else if(parentModuleInfo.getThemeMap() != null && !parentModuleInfo.getThemeMap().isEmpty()) { Theme childTheme = moduleInfo.getThemeMap().get(THEME_KEY); Theme parentTheme = parentModuleInfo.getThemeMap().get(THEME_KEY); childTheme.mergeWithParent(parentTheme); } } }
ThemeModule extends BaseModule<ThemeModule, ThemeInfo> implements Validable { @Override public void resolve(ThemeModule parent, Map<String, StackModule> allStacks, Map<String, ServiceModule> commonServices, Map<String, ExtensionModule> extensions) throws AmbariException { ThemeInfo parentModuleInfo = parent.getModuleInfo(); if (parent.getModuleInfo() != null && !moduleInfo.isDeleted()) { if (moduleInfo.getThemeMap() == null || moduleInfo.getThemeMap().isEmpty()) { moduleInfo.setThemeMap(parentModuleInfo.getThemeMap()); } else if(parentModuleInfo.getThemeMap() != null && !parentModuleInfo.getThemeMap().isEmpty()) { Theme childTheme = moduleInfo.getThemeMap().get(THEME_KEY); Theme parentTheme = parentModuleInfo.getThemeMap().get(THEME_KEY); childTheme.mergeWithParent(parentTheme); } } } }
ThemeModule extends BaseModule<ThemeModule, ThemeInfo> implements Validable { @Override public void resolve(ThemeModule parent, Map<String, StackModule> allStacks, Map<String, ServiceModule> commonServices, Map<String, ExtensionModule> extensions) throws AmbariException { ThemeInfo parentModuleInfo = parent.getModuleInfo(); if (parent.getModuleInfo() != null && !moduleInfo.isDeleted()) { if (moduleInfo.getThemeMap() == null || moduleInfo.getThemeMap().isEmpty()) { moduleInfo.setThemeMap(parentModuleInfo.getThemeMap()); } else if(parentModuleInfo.getThemeMap() != null && !parentModuleInfo.getThemeMap().isEmpty()) { Theme childTheme = moduleInfo.getThemeMap().get(THEME_KEY); Theme parentTheme = parentModuleInfo.getThemeMap().get(THEME_KEY); childTheme.mergeWithParent(parentTheme); } } } ThemeModule(File themeFile);  ThemeModule(File themeFile, ThemeInfo moduleInfo);  ThemeModule(ThemeInfo moduleInfo); }
ThemeModule extends BaseModule<ThemeModule, ThemeInfo> implements Validable { @Override public void resolve(ThemeModule parent, Map<String, StackModule> allStacks, Map<String, ServiceModule> commonServices, Map<String, ExtensionModule> extensions) throws AmbariException { ThemeInfo parentModuleInfo = parent.getModuleInfo(); if (parent.getModuleInfo() != null && !moduleInfo.isDeleted()) { if (moduleInfo.getThemeMap() == null || moduleInfo.getThemeMap().isEmpty()) { moduleInfo.setThemeMap(parentModuleInfo.getThemeMap()); } else if(parentModuleInfo.getThemeMap() != null && !parentModuleInfo.getThemeMap().isEmpty()) { Theme childTheme = moduleInfo.getThemeMap().get(THEME_KEY); Theme parentTheme = parentModuleInfo.getThemeMap().get(THEME_KEY); childTheme.mergeWithParent(parentTheme); } } } ThemeModule(File themeFile);  ThemeModule(File themeFile, ThemeInfo moduleInfo);  ThemeModule(ThemeInfo moduleInfo); @Override void resolve(ThemeModule parent, Map<String, StackModule> allStacks,
		  Map<String, ServiceModule> commonServices, Map<String, ExtensionModule> extensions); @Override ThemeInfo getModuleInfo(); @Override boolean isDeleted(); @Override String getId(); @Override boolean isValid(); @Override void setValid(boolean valid); @Override void addError(String error); @Override void addErrors(Collection<String> errors); @Override Collection<String> getErrors(); }
ThemeModule extends BaseModule<ThemeModule, ThemeInfo> implements Validable { @Override public void resolve(ThemeModule parent, Map<String, StackModule> allStacks, Map<String, ServiceModule> commonServices, Map<String, ExtensionModule> extensions) throws AmbariException { ThemeInfo parentModuleInfo = parent.getModuleInfo(); if (parent.getModuleInfo() != null && !moduleInfo.isDeleted()) { if (moduleInfo.getThemeMap() == null || moduleInfo.getThemeMap().isEmpty()) { moduleInfo.setThemeMap(parentModuleInfo.getThemeMap()); } else if(parentModuleInfo.getThemeMap() != null && !parentModuleInfo.getThemeMap().isEmpty()) { Theme childTheme = moduleInfo.getThemeMap().get(THEME_KEY); Theme parentTheme = parentModuleInfo.getThemeMap().get(THEME_KEY); childTheme.mergeWithParent(parentTheme); } } } ThemeModule(File themeFile);  ThemeModule(File themeFile, ThemeInfo moduleInfo);  ThemeModule(ThemeInfo moduleInfo); @Override void resolve(ThemeModule parent, Map<String, StackModule> allStacks,
		  Map<String, ServiceModule> commonServices, Map<String, ExtensionModule> extensions); @Override ThemeInfo getModuleInfo(); @Override boolean isDeleted(); @Override String getId(); @Override boolean isValid(); @Override void setValid(boolean valid); @Override void addError(String error); @Override void addErrors(Collection<String> errors); @Override Collection<String> getErrors(); static final String THEME_KEY; }