@@ -0,0 +1,3234 @@
+/**%0A * Copyright %C2%A9 2010-2014 Nokia%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *      http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A%0Apackage org.jsonschema2pojo.rules;%0A%0Aimport com.fasterxml.jackson.databind.ObjectMapper;%0Aimport com.fasterxml.jackson.databind.node.ArrayNode;%0Aimport com.fasterxml.jackson.databind.node.ObjectNode;%0Aimport com.sun.codemodel.JCodeModel;%0Aimport com.sun.codemodel.JPackage;%0Aimport com.sun.codemodel.JType;%0Aimport org.jsonschema2pojo.Annotator;%0Aimport org.jsonschema2pojo.Schema;%0Aimport org.jsonschema2pojo.util.NameHelper;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.mockito.invocation.InvocationOnMock;%0Aimport org.mockito.stubbing.Answer;%0A%0Aimport static org.hamcrest.MatcherAssert.assertThat;%0Aimport static org.hamcrest.Matchers.is;%0Aimport static org.mockito.Matchers.anyString;%0Aimport static org.mockito.Mockito.mock;%0Aimport static org.mockito.Mockito.when;%0A%0Apublic class EnumRuleTest %7B%0A%0A    private Schema schema = mock(Schema.class);%0A    private NameHelper nameHelper = mock(NameHelper.class);%0A    private Annotator annotator = mock(Annotator.class);%0A    private RuleFactory ruleFactory = mock(RuleFactory.class);%0A%0A    private EnumRule rule = new EnumRule(ruleFactory);%0A%0A    @Before%0A    public void wireUpConfig() %7B%0A        when(ruleFactory.getNameHelper()).thenReturn(nameHelper);%0A        when(ruleFactory.getAnnotator()).thenReturn(annotator);%0A    %7D%0A%0A    @Test%0A    public void applyGeneratesUniqueEnumNamesForMultipleEnumNodesWithSameName() %7B%0A%0A        Answer%3CString%3E firstArgAnswer = new FirstArgAnswer%3CString%3E();%0A        when(nameHelper.replaceIllegalCharacters(anyString())).thenAnswer(firstArgAnswer);%0A        when(nameHelper.normalizeName(anyString())).thenAnswer(firstArgAnswer);%0A%0A        JPackage jpackage = new JCodeModel()._package(getClass().getPackage().getName());%0A%0A        ObjectMapper objectMapper = new ObjectMapper();%0A        ArrayNode arrayNode = objectMapper.createArrayNode();%0A        arrayNode.add(%22open%22);%0A        arrayNode.add(%22closed%22);%0A        ObjectNode enumNode = objectMapper.createObjectNode();%0A        enumNode.put(%22type%22, %22string%22);%0A        enumNode.put(%22enum%22, arrayNode);%0A%0A        JType result1 = rule.apply(%22status%22, enumNode, jpackage, schema);%0A        JType result2 = rule.apply(%22status%22, enumNode, jpackage, schema);%0A%0A        assertThat(result1.fullName(), is(%22org.jsonschema2pojo.rules.Status%22));%0A        assertThat(result2.fullName(), is(%22org.jsonschema2pojo.rules.Status_%22));%0A    %7D%0A%0A    private static class FirstArgAnswer%3CT%3E implements Answer%3CT%3E %7B%0A        @Override%0A        public T answer(InvocationOnMock invocation) throws Throwable %7B%0A            Object%5B%5D args = invocation.getArguments();%0A            //noinspection unchecked%0A            return (T) args%5B0%5D;%0A        %7D%0A    %7D%0A%7D%0A

Test added for verifying unique enum name generation on multiple enum nodes with same name.