GlobalAttributeDefinitionHelper { public void validateGlobalAttributeDefinitionKey(GlobalAttributeDefinitionKey globalAttributeDefinitionKey) throws IllegalArgumentException { Assert.notNull(globalAttributeDefinitionKey, "A global attribute definition key must be specified."); globalAttributeDefinitionKey.setGlobalAttributeDefinitionLevel( alternateKeyHelper.validateStringParameter("global attribute definition level", globalAttributeDefinitionKey.getGlobalAttributeDefinitionLevel())); globalAttributeDefinitionKey.setGlobalAttributeDefinitionName( alternateKeyHelper.validateStringParameter("global attribute definition name", globalAttributeDefinitionKey.getGlobalAttributeDefinitionName())); }  void validateGlobalAttributeDefinitionKey(GlobalAttributeDefinitionKey globalAttributeDefinitionKey);  }
@Test public void testValidateGlobalAttributeDefinitionKey() { GlobalAttributeDefinitionKey globalAttributeDefinitionKey = new GlobalAttributeDefinitionKey(GLOBAL_ATTRIBUTE_DEFINITON_LEVEL, GLOBAL_ATTRIBUTE_DEFINITON_NAME); when(alternateKeyHelper.validateStringParameter("global attribute definition level", GLOBAL_ATTRIBUTE_DEFINITON_LEVEL)) .thenReturn(GLOBAL_ATTRIBUTE_DEFINITON_LEVEL); when(alternateKeyHelper.validateStringParameter("global attribute definition name", GLOBAL_ATTRIBUTE_DEFINITON_NAME)) .thenReturn(GLOBAL_ATTRIBUTE_DEFINITON_NAME); globalAttributeDefinitionHelper.validateGlobalAttributeDefinitionKey(globalAttributeDefinitionKey); verify(alternateKeyHelper).validateStringParameter("global attribute definition level", GLOBAL_ATTRIBUTE_DEFINITON_LEVEL); verify(alternateKeyHelper).validateStringParameter("global attribute definition name", GLOBAL_ATTRIBUTE_DEFINITON_NAME); verifyNoMoreInteractions(alternateKeyHelper); assertEquals(new GlobalAttributeDefinitionKey(GLOBAL_ATTRIBUTE_DEFINITON_LEVEL, GLOBAL_ATTRIBUTE_DEFINITON_NAME), globalAttributeDefinitionKey); }
@Test public void testValidateGlobalAttributeDefinitionKeyMissingRequiredParameters() { try { globalAttributeDefinitionHelper.validateGlobalAttributeDefinitionKey(null); fail(); } catch (IllegalArgumentException e) { assertEquals("A global attribute definition key must be specified.", e.getMessage()); } verifyNoMoreInteractions(alternateKeyHelper); }