### Question:
EnumRule implements Rule<JClassContainer, JType> { @Override public JType apply(String nodeName, JsonNode node, JsonNode parent, JClassContainer container, Schema schema) { JDefinedClass _enum; try { _enum = createEnum(node, nodeName, container); } catch (ClassAlreadyExistsException e) { ruleFactory.getLogger().error("Could not create enum.", e); return e.getExistingClass(); } schema.setJavaTypeIfEmpty(_enum); if (node.has("title")) { ruleFactory.getTitleRule().apply(nodeName, node.get("title"), node, _enum, schema); } if (node.has("description")) { ruleFactory.getDescriptionRule().apply(nodeName, node.get("description"), node, _enum, schema); } if (node.has("javaInterfaces")) { addInterfaces(_enum, node.get("javaInterfaces")); } ObjectNode typeNode = (ObjectNode)node.deepCopy(); typeNode.remove("javaType"); JType backingType = node.has("type") ? ruleFactory.getTypeRule().apply(nodeName, typeNode, parent, container, schema) : container.owner().ref(String.class); EnumDefinition enumDefinition = buildEnumDefinition(nodeName, node, backingType); JFieldVar valueField = addConstructorAndFields(enumDefinition, _enum); if(isString(backingType)){ addToString(_enum, valueField); } addFieldAccessors(_enum, valueField); addEnumConstants(enumDefinition, _enum, schema); addFactoryMethod(enumDefinition, _enum); applyCustomizations(enumDefinition, _enum); return _enum; } protected  EnumRule(RuleFactory ruleFactory); @Override JType apply(String nodeName, JsonNode node, JsonNode parent, JClassContainer container, Schema schema);  }### Answer:
@Test public void applyGeneratesUniqueEnumNamesForMultipleEnumNodesWithSameName() { Answer<String> firstArgAnswer = new FirstArgAnswer<>(); when(nameHelper.getClassName(anyString(), Matchers.any(JsonNode.class))).thenAnswer(firstArgAnswer); when(nameHelper.replaceIllegalCharacters(anyString())).thenAnswer(firstArgAnswer); when(nameHelper.normalizeName(anyString())).thenAnswer(firstArgAnswer); JPackage jpackage = new JCodeModel()._package(getClass().getPackage().getName()); ObjectMapper objectMapper = new ObjectMapper(); ArrayNode arrayNode = objectMapper.createArrayNode(); arrayNode.add("open"); arrayNode.add("closed"); ObjectNode enumNode = objectMapper.createObjectNode(); enumNode.put("type", "string"); enumNode.set("enum", arrayNode); when(typeRule.apply("status", enumNode, null, jpackage, schema)) .thenReturn(jpackage.owner()._ref(String.class)); JType result1 = rule.apply("status", enumNode, null, jpackage, schema); JType result2 = rule.apply("status", enumNode, null, jpackage, schema); assertThat(result1.fullName(), is("org.jsonschema2pojo.rules.Status")); assertThat(result2.fullName(), is("org.jsonschema2pojo.rules.Status_")); }