MCPcopy Create free account
hub / github.com/HtmlUnit/htmlunit / alertVerify

Method alertVerify

src/test/java/org/htmlunit/CodeStyleTest.java:713–739  ·  view source on GitHub ↗

Verifies a specific \@Alerts definition.

(final List<String> alerts, final String relativePath, final int lineIndex)

Source from the content-addressed store, hash-verified

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.

Callers 1

alertsMethod · 0.95

Calls 9

addFailureMethod · 0.95
alertVerifyOrderMethod · 0.95
trimMethod · 0.80
substringMethod · 0.80
containsMethod · 0.65
sizeMethod · 0.45
getMethod · 0.45
indexOfMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected