ComponentModule extends BaseModule<ComponentModule, ComponentInfo> implements Validable { @Override public ComponentInfo getModuleInfo() { return componentInfo; } ComponentModule(ComponentInfo componentInfo); @Override void resolve(ComponentModule parent, Map<String, StackModule> allStacks,
	    Map<String, ServiceModule> commonServices, Map<String, ExtensionModule> extensions); @Override ComponentInfo getModuleInfo(); @Override boolean isDeleted(); @Override String getId(); @Override boolean isValid(); @Override void setValid(boolean valid); @Override void addError(String error); @Override Collection<String> getErrors(); @Override void addErrors(Collection<String> errors); @Override String toString();  }
@Test public void testResolve_CommandScript() { CommandScriptDefinition commandScript = new CommandScriptDefinition(); ComponentInfo info = new ComponentInfo(); ComponentInfo parentInfo = new ComponentInfo(); parentInfo.setCommandScript(commandScript); assertSame(commandScript, resolveComponent(info, parentInfo).getModuleInfo().getCommandScript()); info.setCommandScript(commandScript); parentInfo.setCommandScript(null); assertSame(commandScript, resolveComponent(info, parentInfo).getModuleInfo().getCommandScript()); CommandScriptDefinition commandScript2 = createNiceMock(CommandScriptDefinition.class); info.setCommandScript(commandScript); parentInfo.setCommandScript(commandScript2); assertSame(commandScript, resolveComponent(info, parentInfo).getModuleInfo().getCommandScript()); }
@Test public void testResolve_DisplayName() { String displayName = "foo"; ComponentInfo info = new ComponentInfo(); ComponentInfo parentInfo = new ComponentInfo(); parentInfo.setDisplayName(displayName); assertEquals(displayName, resolveComponent(info, parentInfo).getModuleInfo().getDisplayName()); info.setDisplayName(displayName); parentInfo.setDisplayName(null); assertEquals(displayName, resolveComponent(info, parentInfo).getModuleInfo().getDisplayName()); String displayName2 = "foo2"; info.setDisplayName(displayName2); parentInfo.setDisplayName(displayName); assertEquals(displayName2, resolveComponent(info, parentInfo).getModuleInfo().getDisplayName()); }
@Test public void testResolve_ClientConfigFiles() { List<ClientConfigFileDefinition> clientConfigs = new ArrayList<ClientConfigFileDefinition>(); ClientConfigFileDefinition clientConfig1 = new ClientConfigFileDefinition(); clientConfig1.setType("type1"); clientConfig1.setDictionaryName("dictName1"); clientConfig1.setFileName("filename1"); ClientConfigFileDefinition clientConfig2 = new ClientConfigFileDefinition(); clientConfig1.setType("type1"); clientConfig1.setDictionaryName("dictName1"); clientConfig1.setFileName("filename1"); clientConfigs.add(clientConfig1); clientConfigs.add(clientConfig2); ComponentInfo info = new ComponentInfo(); ComponentInfo parentInfo = new ComponentInfo(); parentInfo.setClientConfigFiles(clientConfigs); assertEquals(clientConfigs, resolveComponent(info, parentInfo).getModuleInfo().getClientConfigFiles()); info.setClientConfigFiles(clientConfigs); parentInfo.setClientConfigFiles(null); assertEquals(clientConfigs, resolveComponent(info, parentInfo).getModuleInfo().getClientConfigFiles()); List<ClientConfigFileDefinition> clientConfigs2 = new ArrayList<ClientConfigFileDefinition>(); ClientConfigFileDefinition clientConfig3 = new ClientConfigFileDefinition(); clientConfig3.setType("type1"); clientConfig3.setDictionaryName("dictName1"); clientConfig3.setFileName("DIFFERENT filename"); clientConfigs2.add(clientConfig3); info.setClientConfigFiles(clientConfigs2); parentInfo.setClientConfigFiles(clientConfigs); assertEquals(clientConfigs2, resolveComponent(info, parentInfo).getModuleInfo().getClientConfigFiles()); }
@Test public void testResolve_Category() { String category = "foo"; ComponentInfo info = new ComponentInfo(); ComponentInfo parentInfo = new ComponentInfo(); parentInfo.setCategory(category); assertEquals(category, resolveComponent(info, parentInfo).getModuleInfo().getCategory()); info.setCategory(category); parentInfo.setCategory(null); assertEquals(category, resolveComponent(info, parentInfo).getModuleInfo().getCategory()); String category2 = "foo2"; info.setCategory(category2); parentInfo.setCategory(category); assertEquals(category2, resolveComponent(info, parentInfo).getModuleInfo().getCategory()); }
@Test public void testResolve_Cardinality() { String cardinality = "foo"; ComponentInfo info = new ComponentInfo(); assertEquals("0+", resolveComponent(info, null).getModuleInfo().getCardinality()); ComponentInfo parentInfo = new ComponentInfo(); info = new ComponentInfo(); parentInfo.setCardinality(cardinality); assertEquals("foo", resolveComponent(info, parentInfo).getModuleInfo().getCardinality()); info.setCardinality(cardinality); parentInfo.setCardinality(null); assertEquals(cardinality, resolveComponent(info, parentInfo).getModuleInfo().getCardinality()); String cardinality2 = "foo2"; info.setCardinality(cardinality2); parentInfo.setCardinality(cardinality); assertEquals(cardinality2, resolveComponent(info, parentInfo).getModuleInfo().getCardinality()); }
@Test public void testResolve_AutoDeploy() { AutoDeployInfo autoDeployInfo = new AutoDeployInfo(); autoDeployInfo.setEnabled(true); autoDeployInfo.setCoLocate("foo/bar"); ComponentInfo info = new ComponentInfo(); ComponentInfo parentInfo = new ComponentInfo(); parentInfo.setAutoDeploy(autoDeployInfo); assertEquals(autoDeployInfo, resolveComponent(info, parentInfo).getModuleInfo().getAutoDeploy()); info.setAutoDeploy(autoDeployInfo); parentInfo.setAutoDeploy(null); assertEquals(autoDeployInfo, resolveComponent(info, parentInfo).getModuleInfo().getAutoDeploy()); AutoDeployInfo autoDeployInfo2 = new AutoDeployInfo(); info.setAutoDeploy(autoDeployInfo); parentInfo.setAutoDeploy(autoDeployInfo2); assertEquals(autoDeployInfo, resolveComponent(info, parentInfo).getModuleInfo().getAutoDeploy()); }
@Test public void testResolve_Dependencies() { List<DependencyInfo> dependencies = new ArrayList<DependencyInfo>(); DependencyInfo dependency1 = new DependencyInfo(); dependency1.setName("service/one"); DependencyInfo dependency2 = new DependencyInfo(); dependency2.setName("service/two"); dependencies.add(dependency1); dependencies.add(dependency2); ComponentInfo info = new ComponentInfo(); ComponentInfo parentInfo = new ComponentInfo(); parentInfo.setDependencies(dependencies); assertEquals(dependencies, resolveComponent(info, parentInfo).getModuleInfo().getDependencies()); info.setDependencies(dependencies); parentInfo.setDependencies(null); assertEquals(dependencies, resolveComponent(info, parentInfo).getModuleInfo().getDependencies()); List<DependencyInfo> dependencies2 = new ArrayList<DependencyInfo>(); DependencyInfo dependency3 = new DependencyInfo(); dependency3.setName("service/two"); DependencyInfo dependency4 = new DependencyInfo(); dependency4.setName("service/four"); dependencies2.add(dependency3); dependencies2.add(dependency4); info.setDependencies(dependencies2); parentInfo.setDependencies(dependencies); List<DependencyInfo> resolvedDependencies = resolveComponent(info, parentInfo).getModuleInfo().getDependencies(); assertEquals(3, resolvedDependencies.size()); assertTrue(resolvedDependencies.contains(dependency1)); assertTrue(resolvedDependencies.contains(dependency3)); assertTrue(resolvedDependencies.contains(dependency4)); }
@Test public void testResolve_CustomCommands() throws Exception { List<CustomCommandDefinition> commands = new ArrayList<CustomCommandDefinition>(); CustomCommandDefinition command1 = new CustomCommandDefinition(); setPrivateField(command1, "name", "one"); CustomCommandDefinition command2 = new CustomCommandDefinition(); setPrivateField(command2, "name", "two"); commands.add(command1); commands.add(command2); ComponentInfo info = new ComponentInfo(); ComponentInfo parentInfo = new ComponentInfo(); parentInfo.setCustomCommands(commands); assertEquals(commands, resolveComponent(info, parentInfo).getModuleInfo().getCustomCommands()); info.setCustomCommands(commands); parentInfo.setCustomCommands(null); assertEquals(commands, resolveComponent(info, parentInfo).getModuleInfo().getCustomCommands()); List<CustomCommandDefinition> commands2 = new ArrayList<CustomCommandDefinition>(); CustomCommandDefinition command3 = new CustomCommandDefinition(); setPrivateField(command3, "name", "two"); CustomCommandDefinition command4 = new CustomCommandDefinition(); setPrivateField(command4, "name", "four"); commands2.add(command3); commands2.add(command4); info.setCustomCommands(commands2); parentInfo.setCustomCommands(commands); List<CustomCommandDefinition> resolvedCommands = resolveComponent(info, parentInfo).getModuleInfo().getCustomCommands(); assertEquals(3, resolvedCommands.size()); assertTrue(resolvedCommands.contains(command1)); assertTrue(resolvedCommands.contains(command3)); assertTrue(resolvedCommands.contains(command4)); }
@Test public void testResolve_ConfigDependencies() { List<String> dependencies = new ArrayList<String>(); String dependency1 = "one"; String dependency2 = "two"; dependencies.add(dependency1); dependencies.add(dependency2); ComponentInfo info = new ComponentInfo(); ComponentInfo parentInfo = new ComponentInfo(); parentInfo.setConfigDependencies(dependencies); assertEquals(dependencies, resolveComponent(info, parentInfo).getModuleInfo().getConfigDependencies()); info.setConfigDependencies(dependencies); parentInfo.setConfigDependencies(null); assertEquals(dependencies, resolveComponent(info, parentInfo).getModuleInfo().getConfigDependencies()); List<String> dependencies2 = new ArrayList<String>(); String dependency3 = "two"; String dependency4 = "four"; dependencies2.add(dependency3); dependencies2.add(dependency4); info.setConfigDependencies(dependencies2); parentInfo.setConfigDependencies(dependencies); List<String> resolvedDependencies = resolveComponent(info, parentInfo).getModuleInfo().getConfigDependencies(); assertEquals(2, resolvedDependencies.size()); assertTrue(resolvedDependencies.contains(dependency3)); assertTrue(resolvedDependencies.contains(dependency4)); }
@Test public void testResolve_ClientToUpdateConfigs() { List<String> clientsToUpdate = new ArrayList<String>(); String client1 = "one"; String client2 = "two"; clientsToUpdate.add(client1); clientsToUpdate.add(client2); ComponentInfo info = new ComponentInfo(); ComponentInfo parentInfo = new ComponentInfo(); parentInfo.setClientsToUpdateConfigs(clientsToUpdate); assertEquals(clientsToUpdate, resolveComponent(info, parentInfo).getModuleInfo().getClientsToUpdateConfigs()); info.setClientsToUpdateConfigs(clientsToUpdate); parentInfo.setClientsToUpdateConfigs(null); assertEquals(clientsToUpdate, resolveComponent(info, parentInfo).getModuleInfo().getClientsToUpdateConfigs()); List<String> clientsToUpdate2 = new ArrayList<String>(); String client3 = "two"; String client4 = "four"; clientsToUpdate2.add(client3); clientsToUpdate2.add(client4); info.setClientsToUpdateConfigs(clientsToUpdate2); parentInfo.setClientsToUpdateConfigs(clientsToUpdate); List<String> resolvedClientsToUpdate = resolveComponent(info, parentInfo).getModuleInfo().getClientsToUpdateConfigs(); assertEquals(2, resolvedClientsToUpdate.size()); assertTrue(resolvedClientsToUpdate.contains(client3)); assertTrue(resolvedClientsToUpdate.contains(client4)); }
@Test public void testResolve_BulkCommandsDefinition(){ BulkCommandDefinition bulkCommandsDefinition = new BulkCommandDefinition(); ComponentInfo info = new ComponentInfo(); ComponentInfo parentInfo = new ComponentInfo(); parentInfo.setBulkCommands(bulkCommandsDefinition); assertSame(bulkCommandsDefinition, resolveComponent(info, parentInfo).getModuleInfo().getBulkCommandDefinition()); info.setBulkCommands(bulkCommandsDefinition); parentInfo.setBulkCommands(null); assertSame(bulkCommandsDefinition, resolveComponent(info, parentInfo).getModuleInfo().getBulkCommandDefinition()); BulkCommandDefinition bulkCommandsDefinition2 = createNiceMock(BulkCommandDefinition.class); info.setBulkCommands(bulkCommandsDefinition); parentInfo.setBulkCommands(bulkCommandsDefinition2); assertSame(bulkCommandsDefinition, resolveComponent(info, parentInfo).getModuleInfo().getBulkCommandDefinition()); }
@Test public void testResolve_DecommissionAllowedInheritance(){ List<ComponentInfo> components = createComponentInfo(2); ComponentInfo info = components.get(0); ComponentInfo parentInfo = components.get(1); parentInfo.setDecommissionAllowed("true"); assertSame("true", resolveComponent(info, parentInfo).getModuleInfo().getDecommissionAllowed()); }
@Test public void testResolve_DecommissionAllowed(){ List<ComponentInfo> components = createComponentInfo(2); ComponentInfo info = components.get(0); ComponentInfo parentInfo = components.get(1); info.setDecommissionAllowed("false"); assertSame("false", resolveComponent(info, parentInfo).getModuleInfo().getDecommissionAllowed()); }
@Test public void testResolve_DecommissionAllowedOverwrite(){ List<ComponentInfo> components = createComponentInfo(2); ComponentInfo info = components.get(0); ComponentInfo parentInfo = components.get(1); parentInfo.setDecommissionAllowed("false"); info.setDecommissionAllowed("true"); assertSame("true", resolveComponent(info, parentInfo).getModuleInfo().getDecommissionAllowed()); }
@Test public void testResolve_UnlimitedKeyJCERequiredInheritance(){ List<ComponentInfo> components = createComponentInfo(2); ComponentInfo info = components.get(0); ComponentInfo parentInfo = components.get(1); parentInfo.setUnlimitedKeyJCERequired(UnlimitedKeyJCERequirement.ALWAYS); assertSame(UnlimitedKeyJCERequirement.ALWAYS, resolveComponent(info, parentInfo).getModuleInfo().getUnlimitedKeyJCERequired()); }
@Test public void testResolve_UnlimitedKeyJCERequired(){ List<ComponentInfo> components = createComponentInfo(2); ComponentInfo info = components.get(0); ComponentInfo parentInfo = components.get(1); info.setUnlimitedKeyJCERequired(UnlimitedKeyJCERequirement.NEVER); assertSame(UnlimitedKeyJCERequirement.NEVER, resolveComponent(info, parentInfo).getModuleInfo().getUnlimitedKeyJCERequired()); }
@Test public void testResolve_UnlimitedKeyJCERequiredOverwrite(){ List<ComponentInfo> components = createComponentInfo(2); ComponentInfo info = components.get(0); ComponentInfo parentInfo = components.get(1); parentInfo.setUnlimitedKeyJCERequired(UnlimitedKeyJCERequirement.KERBEROS_ENABLED); info.setUnlimitedKeyJCERequired(UnlimitedKeyJCERequirement.ALWAYS); assertSame(UnlimitedKeyJCERequirement.ALWAYS, resolveComponent(info, parentInfo).getModuleInfo().getUnlimitedKeyJCERequired()); }
@Test public void testResolve_Reassignable(){ List<ComponentInfo> components = createComponentInfo(2); ComponentInfo info = components.get(0); ComponentInfo parentInfo = components.get(1); info.setReassignAllowed("false"); assertSame("false", resolveComponent(info, parentInfo).getModuleInfo().getReassignAllowed()); }
@Test public void testResolve_ReassignableInheritance(){ List<ComponentInfo> components = createComponentInfo(2); ComponentInfo info = components.get(0); ComponentInfo parentInfo = components.get(1); parentInfo.setReassignAllowed("true"); assertSame("true", resolveComponent(info, parentInfo).getModuleInfo().getReassignAllowed()); }
@Test public void testResolve_ReassignableOverwrite(){ List<ComponentInfo> components = createComponentInfo(2); ComponentInfo info = components.get(0); ComponentInfo parentInfo = components.get(1); parentInfo.setReassignAllowed("false"); info.setReassignAllowed("true"); assertSame("true", resolveComponent(info, parentInfo).getModuleInfo().getReassignAllowed()); }
@Test public void testResolve_VersionAdvertised() { List<ComponentInfo> components = createComponentInfo(2); ComponentInfo info = components.get(0); ComponentInfo parentInfo = components.get(1); parentInfo.setVersionAdvertisedField(new Boolean(true)); parentInfo.setVersionAdvertised(true); info.setVersionAdvertisedField(new Boolean(true)); assertEquals(true, resolveComponent(info, parentInfo).getModuleInfo().isVersionAdvertised()); parentInfo.setVersionAdvertisedField(new Boolean(true)); parentInfo.setVersionAdvertised(true); info.setVersionAdvertisedField(new Boolean(false)); assertEquals(false, resolveComponent(info, parentInfo).getModuleInfo().isVersionAdvertised()); parentInfo.setVersionAdvertisedField(new Boolean(false)); parentInfo.setVersionAdvertised(false); info.setVersionAdvertisedField(new Boolean(true)); assertEquals(true, resolveComponent(info, parentInfo).getModuleInfo().isVersionAdvertised()); parentInfo.setVersionAdvertisedField(null); parentInfo.setVersionAdvertised(false); info.setVersionAdvertisedField(new Boolean(true)); assertEquals(true, resolveComponent(info, parentInfo).getModuleInfo().isVersionAdvertised()); parentInfo.setVersionAdvertisedField(new Boolean(true)); parentInfo.setVersionAdvertised(true); info.setVersionAdvertisedField(null); assertEquals(true, resolveComponent(info, parentInfo).getModuleInfo().isVersionAdvertised()); parentInfo.setVersionAdvertisedField(new Boolean(true)); parentInfo.setVersionAdvertised(true); info.setVersionAdvertisedField(null); assertEquals(true, resolveComponent(info, parentInfo).getModuleInfo().isVersionAdvertised()); parentInfo.setVersionAdvertisedField(new Boolean(false)); parentInfo.setVersionAdvertised(false); info.setVersionAdvertisedField(null); assertEquals(false, resolveComponent(info, parentInfo).getModuleInfo().isVersionAdvertised()); parentInfo.setVersionAdvertisedField(new Boolean(false)); parentInfo.setVersionAdvertised(false); info.setVersionAdvertisedField(null); assertEquals(false, resolveComponent(info, parentInfo).getModuleInfo().isVersionAdvertised()); }