Verifies a specific \@Alerts definition.
(final List<String> alerts, final String relativePath, final int lineIndex)
| 711 | * Verifies a specific \@Alerts definition. |
| 712 | */ |
| 713 | private void alertVerify(final List<String> alerts, final String relativePath, final int lineIndex) { |
| 714 | if (alerts.size() == 1) { |
| 715 | if (alerts.get(0).contains("DEFAULT")) { |
| 716 | addFailure(relativePath, lineIndex + 1, "No need for \"DEFAULT\""); |
| 717 | } |
| 718 | } |
| 719 | else { |
| 720 | final List<String> names = new ArrayList<>(); |
| 721 | for (final String alert : alerts) { |
| 722 | String cleanedAlert = alert; |
| 723 | if (alert.charAt(0) == ',') { |
| 724 | if (alert.charAt(1) != '\n') { |
| 725 | addFailure(relativePath, lineIndex + 1, "Expectation must be in a separate line"); |
| 726 | } |
| 727 | cleanedAlert = alert.substring(1).trim(); |
| 728 | } |
| 729 | |
| 730 | final int quoteIndex = cleanedAlert.indexOf('"'); |
| 731 | final int equalsIndex = cleanedAlert.indexOf('='); |
| 732 | if (equalsIndex != -1 && equalsIndex < quoteIndex) { |
| 733 | final String name = cleanedAlert.substring(0, equalsIndex - 1); |
| 734 | alertVerifyOrder(name, names, relativePath, lineIndex); |
| 735 | names.add(name); |
| 736 | } |
| 737 | } |
| 738 | } |
| 739 | } |
| 740 | |
| 741 | /** |
| 742 | * Converts the given alerts definition to an array of expressions. |
no test coverage detected