@Test public void testValidateSourceLocation() { CompletionMetadata metadata = CompletionMetadata.builder() .setNodes(ImmutableSet.of(INTERNET_LOCATION.getNodeName(), "node")) .setSourceLocations( ImmutableSet.of(INTERNET_LOCATION, new InterfaceLocation("node", "iface"))) .build(); { InputValidationNotes notes = validateSourceLocation("internet", metadata); assertEquals(Validity.VALID, notes.getValidity()); } { InputValidationNotes notes = validateSourceLocation("@enter(internet[out])", metadata); assertEquals(Validity.INVALID, notes.getValidity()); } { InputValidationNotes notes = validateSourceLocation("node[iface]", metadata); assertEquals(Validity.VALID, notes.getValidity()); } { InputValidationNotes notes = validateSourceLocation("node", metadata); assertEquals(Validity.INVALID, notes.getValidity()); } }
@VisibleForTesting @Nonnull static InputValidationNotes validateSourceLocation( String query, CompletionMetadata completionMetadata) { Validity validity = autoCompleteSourceLocation(query, completionMetadata).stream() .anyMatch(suggestion -> suggestion.getText().equals(query)) ? Validity.VALID : Validity.INVALID; return new InputValidationNotes(validity, ImmutableList.of()); }
InputValidationUtils { @VisibleForTesting @Nonnull static InputValidationNotes validateSourceLocation( String query, CompletionMetadata completionMetadata) { Validity validity = autoCompleteSourceLocation(query, completionMetadata).stream() .anyMatch(suggestion -> suggestion.getText().equals(query)) ? Validity.VALID : Validity.INVALID; return new InputValidationNotes(validity, ImmutableList.of()); } }
InputValidationUtils { @VisibleForTesting @Nonnull static InputValidationNotes validateSourceLocation( String query, CompletionMetadata completionMetadata) { Validity validity = autoCompleteSourceLocation(query, completionMetadata).stream() .anyMatch(suggestion -> suggestion.getText().equals(query)) ? Validity.VALID : Validity.INVALID; return new InputValidationNotes(validity, ImmutableList.of()); }  }
InputValidationUtils { @VisibleForTesting @Nonnull static InputValidationNotes validateSourceLocation( String query, CompletionMetadata completionMetadata) { Validity validity = autoCompleteSourceLocation(query, completionMetadata).stream() .anyMatch(suggestion -> suggestion.getText().equals(query)) ? Validity.VALID : Validity.INVALID; return new InputValidationNotes(validity, ImmutableList.of()); }  @Nonnull static InputValidationNotes validate(
      Variable.Type varType,
      String query,
      CompletionMetadata completionMetadata,
      NodeRolesData nodeRolesData,
      ReferenceLibrary referenceLibrary); static String getErrorMessage(String grammarName, int startIndex); static String getErrorMessage(IllegalArgumentException exception); static String getErrorMessageEmptyNameRegex(String nameRegex, String nameType); static String getErrorMessageMissingName(String name, String nameType); static String getErrorMessageMissingGroup(
      String group, String groupType, String book, String bookType); static String getErrorMessageMissingBook(String book, String bookType); }
InputValidationUtils { @VisibleForTesting @Nonnull static InputValidationNotes validateSourceLocation( String query, CompletionMetadata completionMetadata) { Validity validity = autoCompleteSourceLocation(query, completionMetadata).stream() .anyMatch(suggestion -> suggestion.getText().equals(query)) ? Validity.VALID : Validity.INVALID; return new InputValidationNotes(validity, ImmutableList.of()); }  @Nonnull static InputValidationNotes validate(
      Variable.Type varType,
      String query,
      CompletionMetadata completionMetadata,
      NodeRolesData nodeRolesData,
      ReferenceLibrary referenceLibrary); static String getErrorMessage(String grammarName, int startIndex); static String getErrorMessage(IllegalArgumentException exception); static String getErrorMessageEmptyNameRegex(String nameRegex, String nameType); static String getErrorMessageMissingName(String name, String nameType); static String getErrorMessageMissingGroup(
      String group, String groupType, String book, String bookType); static String getErrorMessageMissingBook(String book, String bookType);  }