+ typeCompatibleWith(AnnotationAction.class));
+ }
+
+ @DataProvider
+ public SlivkaService[] unrecognisedService()
+ {
+ return new SlivkaService[] {
+ new SlivkaService(URI.create("http://example.org/"), "example",
+ "Example name", "Example description", "John Smith",
+ "1.0.0", "Apache License, version 2.0",
+ List.of("This :: Classifier :: Does not exist"), List.of(),
+ List.of(), null) };
+ }
+
+ @Test(dataProvider = "unrecognisedService")
+ public void testFetchServices_unrecognisedService_noServiceDiscovered(
+ SlivkaService service) throws IOException
+ {
+ when(clientMock.getServices()).thenReturn(List.of(service));
+ when(clientMock.getUrl()).thenReturn(URI.create("http://example.org"));
+ var discoverer = new SlivkaWSDiscoverer(url -> clientMock);
+ var webServices = discoverer
+ .fetchServices(new URL("http://example.org"));
+ assertThat(webServices, hasSize(0));
+ }
+
+ @DataProvider
+ public Object[] serviceParameterAndMappedClass()
+ {
+ return new Object[][] {
+ {
+ new Parameter.IntegerParameter("param", "Parameter", "Description",
+ true, false, null, Map.of(), null, null),
+ IntegerParameter.class
+ },
+ {
+ new Parameter.DecimalParameter("param", "Parameter",
+ "Description", true, false, null, Map.of(), null, null,
+ false, false),
+ DoubleParameter.class
+ },
+ {
+ new Parameter.TextParameter("param", "Parameter", "Description",
+ true, false, null, Map.of(), 0, null),
+ StringParameter.class
+ },
+ {
+ new Parameter.FlagParameter("param", "Parameter", "Description",
+ true, false, null, Map.of()),
+ StringParameter.class
+ },
+ {
+ new Parameter.ChoiceParameter("param", "Parameter", "Description",
+ true, false, null, Map.of(), List.of()),
+ StringParameter.class
+ },
+ };
+ }
+
+ @Test(dataProvider = "serviceParameterAndMappedClass")
+ public void testServiceParameter_slivkaParameterMappedToJalviewParameter(
+ Parameter slivkaParameter, Class<?> expectedClass)
+ throws IOException
+ {
+ var service = new SlivkaService(URI.create("http://example.org"),
+ "example", "name", "description", "author", "1.0",
+ "MIT License",
+ List.of("Operation :: Analysis :: Multiple sequence alignment"),
+ List.of(slivkaParameter), List.of(), null);
+ when(clientMock.getServices()).thenReturn(List.of(service));
+ when(clientMock.getUrl()).thenReturn(URI.create("http://example.org"));
+ var discoverer = new SlivkaWSDiscoverer(url -> clientMock);
+ var webServices = discoverer
+ .fetchServices(new URL("http://example.org"));
+ var paramDatastore = webServices.get(0).getParamDatastore();
+ var arguments = paramDatastore.getServiceParameters();
+ assertThat(arguments.get(0), instanceOf(expectedClass));
+ }
+
+ @DataProvider
+ public Object[][] serviceParametersAndPropertyMatcher()
+ {
+ return new Object[][] {
+ {
+ new Parameter.IntegerParameter("param1", "Parameter 1",
+ "Description of parameter 1", true, false, null, Map.of(),
+ null, null),
+ allOf(
+ hasProperty("name", equalTo("param1")),
+ hasProperty("label", equalTo("Parameter 1")),
+ hasProperty("description", equalTo("Description of parameter 1")),
+ hasProperty("required", is(true)),
+ hasProperty("value", nullValue()))
+ },
+ {
+ new Parameter.IntegerParameter("param2", null, null, true, false,
+ null, Map.of(), null, null),
+ allOf(
+ hasProperty("name", equalTo("param2")),
+ hasProperty("label", equalTo("param2")),
+ hasProperty("description", nullValue()),
+ hasProperty("required", is(true)),
+ hasProperty("value", nullValue()))
+ },
+ {
+ new Parameter.IntegerParameter("param3", "Parameter 3", "", false,
+ false, 12, Map.of(), null, null),
+ allOf(
+ hasProperty("name", equalTo("param3")),
+ hasProperty("label", equalTo("Parameter 3")),
+ hasProperty("description", equalTo("")),
+ hasProperty("required", is(false)),
+ hasProperty("value", equalTo("12")))
+ },
+ };
+ }
+
+ @Test(dataProvider = "serviceParametersAndInfoMatcher")
+ public void testServiceParameters_testBasicParameterProperties(
+ Parameter parameter, Matcher<Object> matcher) throws IOException
+ {
+ var service = new SlivkaService(URI.create("http://example.org/"),
+ "example", "Example name", "Example description", "John Smith",
+ "1.0", "MIT",
+ List.of("Operation :: Analysis :: Multiple sequence alignment"),
+ List.of(parameter), List.of(), null);
+ when(clientMock.getServices()).thenReturn(List.of(service));
+ when(clientMock.getUrl()).thenReturn(URI.create("http://example.org/"));
+ var discoverer = new SlivkaWSDiscoverer(url -> clientMock);
+ var webServices = discoverer
+ .fetchServices(new URL("http://example.org/"));
+ var paramDatastore = webServices.get(0).getParamDatastore();
+ var arguments = paramDatastore.getServiceParameters();
+ assertThat(arguments.get(0), matcher);
+ }
+
+ @DataProvider
+ public Object[][] integerParametersAndPropertyMatcher()
+ {
+ return new Object[][] {
+ {
+ new Parameter.IntegerParameter("param", null, null, true, false,
+ null, Map.of(), null, null),
+ hasProperty("validValue", hasProperty("type", is(ValueType.Integer)))
+ },
+ {
+ new Parameter.IntegerParameter("param", null, null, true, false,
+ null, Map.of(), null, null),
+ hasProperty("validValue", allOf(
+ hasProperty("min", nullValue()),
+ hasProperty("max", nullValue()))),
+ },
+ {
+ new Parameter.IntegerParameter("param", null, null, true, false,
+ null, Map.of(), -12, 42),
+ hasProperty("validValue", allOf(
+ hasProperty("min", is(-12)),
+ hasProperty("max", is(42))))
+ },
+ };
+ }
+
+ @Test(dataProvider = "integerParametersAndPropertyMatcher")
+ public void testServiceParameters_testIntegerProperties(
+ Parameter parameter, Matcher<Object> matcher) throws IOException
+ {
+ var service = new SlivkaService(URI.create("http://example.org"),
+ "example", "Example name", "Example description", "John Smith",
+ "1.0", "MIT",
+ List.of("Operation :: Analysis :: Multiple Sequence Alignment"),
+ List.of(parameter), List.of(), null);
+ when(clientMock.getServices()).thenReturn(List.of(service));
+ when(clientMock.getUrl()).thenReturn(URI.create("http://example.org/"));
+ var discoverer = new SlivkaWSDiscoverer(url -> clientMock);
+ var webServices = discoverer
+ .fetchServices(new URL("http://example.org/"));
+ var paramDatastore = webServices.get(0).getParamDatastore();
+ var arguments = paramDatastore.getServiceParameters();
+ assertThat(arguments.get(0), matcher);