Skip to content

Commit

Permalink
JavaDoc and unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sjoerdtalsma committed Aug 16, 2018
1 parent 053e091 commit e1785a2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
Expand Up @@ -22,6 +22,7 @@
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.HashSet;
import java.util.Optional;
import java.util.Set;
Expand All @@ -33,6 +34,15 @@
import static nl.talsmasoftware.umldoclet.util.UriUtils.addHttpParam;
import static nl.talsmasoftware.umldoclet.util.UriUtils.addPathComponent;

/**
* Processes {@code -link} and {@code -linkoffline} javadoc options
* and contains functionality to read a set of externally documented packages.
* <p>
* Since the {@code -link} option only has a single URI parameter,
* this uri must be used as both {@code docUri} and {@code packageListUri}.
*
* @author Sjoerd Talsma
*/
final class ExternalLink {

private final Configuration config;
Expand Down Expand Up @@ -83,10 +93,10 @@ private URI makeAbsolute(URI uri) {

private static URI createUri(String uri) {
try {
return URI.create(uri);
} catch (IllegalArgumentException iae) {
return new URI(uri);
} catch (URISyntaxException use) {
if (new File(uri).exists()) return new File(uri).toURI();
throw iae;
throw new IllegalArgumentException(use.getMessage(), use);
}
}

Expand Down
Expand Up @@ -77,4 +77,9 @@ public void testNonExistingUrls() {
assertThat(logger.countMessages(Message.WARNING_CANNOT_READ_PACKAGE_LIST::equals), is(1));
verify(config, times(1)).destinationDirectory();
}

@Test(expected = IllegalArgumentException.class)
public void testIllegalUrls() {
new ExternalLink(config, "https://www.google.com?\nq=query", "");
}
}

0 comments on commit e1785a2

Please sign in to comment.