@Test public void testNoReferenceToConditionals() throws Exception { final Set<Violation> violations = new I18nRules(toDocument("duplicate-keys.xml")).doMeasuredAnalysis(); assertThat(violations).hasSize(1); assertThat(violations).contains(new DuplicateI18nKeyViolation(15, "Val1")); }
@Override protected Set<Violation> doMeasuredAnalysis() throws JDOMException { final Set<Violation> violations = new HashSet<Violation>(); final Map<String, Element> i18nKeys = new HashMap<String, Element>(); final List<Element> uarGetMessages = selectNodesByName("CALL.", "[NAME[1]/@text = 'UAR_I18NGETMESSAGE']"); for (final Element uarGetMessage : uarGetMessages) { String i18nKey = uarGetMessage.getChildren().get(2).getAttributeValue("text"); String i18nText = uarGetMessage.getChildren().get(3).getAttributeValue("text"); if (i18nKey != null && i18nText != null) { if (i18nKeys.get(i18nKey) == null) { i18nKeys.put(i18nKey, uarGetMessage.getChildren().get(3)); continue; } String existingI18nText = i18nKeys.get(i18nKey).getAttributeValue("text"); if (!existingI18nText.equalsIgnoreCase(i18nText)) { violations.add(new DuplicateI18nKeyViolation(getLineNumber(uarGetMessage), i18nKey)); } } } return violations; }
I18nRules extends TimedDelegate { @Override protected Set<Violation> doMeasuredAnalysis() throws JDOMException { final Set<Violation> violations = new HashSet<Violation>(); final Map<String, Element> i18nKeys = new HashMap<String, Element>(); final List<Element> uarGetMessages = selectNodesByName("CALL.", "[NAME[1]/@text = 'UAR_I18NGETMESSAGE']"); for (final Element uarGetMessage : uarGetMessages) { String i18nKey = uarGetMessage.getChildren().get(2).getAttributeValue("text"); String i18nText = uarGetMessage.getChildren().get(3).getAttributeValue("text"); if (i18nKey != null && i18nText != null) { if (i18nKeys.get(i18nKey) == null) { i18nKeys.put(i18nKey, uarGetMessage.getChildren().get(3)); continue; } String existingI18nText = i18nKeys.get(i18nKey).getAttributeValue("text"); if (!existingI18nText.equalsIgnoreCase(i18nText)) { violations.add(new DuplicateI18nKeyViolation(getLineNumber(uarGetMessage), i18nKey)); } } } return violations; } }
I18nRules extends TimedDelegate { @Override protected Set<Violation> doMeasuredAnalysis() throws JDOMException { final Set<Violation> violations = new HashSet<Violation>(); final Map<String, Element> i18nKeys = new HashMap<String, Element>(); final List<Element> uarGetMessages = selectNodesByName("CALL.", "[NAME[1]/@text = 'UAR_I18NGETMESSAGE']"); for (final Element uarGetMessage : uarGetMessages) { String i18nKey = uarGetMessage.getChildren().get(2).getAttributeValue("text"); String i18nText = uarGetMessage.getChildren().get(3).getAttributeValue("text"); if (i18nKey != null && i18nText != null) { if (i18nKeys.get(i18nKey) == null) { i18nKeys.put(i18nKey, uarGetMessage.getChildren().get(3)); continue; } String existingI18nText = i18nKeys.get(i18nKey).getAttributeValue("text"); if (!existingI18nText.equalsIgnoreCase(i18nText)) { violations.add(new DuplicateI18nKeyViolation(getLineNumber(uarGetMessage), i18nKey)); } } } return violations; } I18nRules(final Document document); }
I18nRules extends TimedDelegate { @Override protected Set<Violation> doMeasuredAnalysis() throws JDOMException { final Set<Violation> violations = new HashSet<Violation>(); final Map<String, Element> i18nKeys = new HashMap<String, Element>(); final List<Element> uarGetMessages = selectNodesByName("CALL.", "[NAME[1]/@text = 'UAR_I18NGETMESSAGE']"); for (final Element uarGetMessage : uarGetMessages) { String i18nKey = uarGetMessage.getChildren().get(2).getAttributeValue("text"); String i18nText = uarGetMessage.getChildren().get(3).getAttributeValue("text"); if (i18nKey != null && i18nText != null) { if (i18nKeys.get(i18nKey) == null) { i18nKeys.put(i18nKey, uarGetMessage.getChildren().get(3)); continue; } String existingI18nText = i18nKeys.get(i18nKey).getAttributeValue("text"); if (!existingI18nText.equalsIgnoreCase(i18nText)) { violations.add(new DuplicateI18nKeyViolation(getLineNumber(uarGetMessage), i18nKey)); } } } return violations; } I18nRules(final Document document); @Override Set<Violation> getCheckedViolations(); }
I18nRules extends TimedDelegate { @Override protected Set<Violation> doMeasuredAnalysis() throws JDOMException { final Set<Violation> violations = new HashSet<Violation>(); final Map<String, Element> i18nKeys = new HashMap<String, Element>(); final List<Element> uarGetMessages = selectNodesByName("CALL.", "[NAME[1]/@text = 'UAR_I18NGETMESSAGE']"); for (final Element uarGetMessage : uarGetMessages) { String i18nKey = uarGetMessage.getChildren().get(2).getAttributeValue("text"); String i18nText = uarGetMessage.getChildren().get(3).getAttributeValue("text"); if (i18nKey != null && i18nText != null) { if (i18nKeys.get(i18nKey) == null) { i18nKeys.put(i18nKey, uarGetMessage.getChildren().get(3)); continue; } String existingI18nText = i18nKeys.get(i18nKey).getAttributeValue("text"); if (!existingI18nText.equalsIgnoreCase(i18nText)) { violations.add(new DuplicateI18nKeyViolation(getLineNumber(uarGetMessage), i18nKey)); } } } return violations; } I18nRules(final Document document); @Override Set<Violation> getCheckedViolations();  }