--- /dev/null
+package jalview.ws2.actions.secstructpred;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import static jalview.testutils.Matchers.matchesSequenceString;
+import static jalview.testutils.ScopeFunctions.apply;
+import static jalview.testutils.ScopeFunctions.run;
+import org.hamcrest.Matcher;
+import org.hamcrest.Matchers;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyList;
+import static org.hamcrest.Matchers.contains;
+
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.inOrder;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import jalview.datamodel.Alignment;
+import jalview.datamodel.AlignmentI;
+import jalview.datamodel.HiddenColumns;
+import jalview.datamodel.Sequence;
+import jalview.datamodel.SequenceI;
+import jalview.gui.AlignViewport;
+import jalview.ws2.api.Credentials;
+import jalview.ws2.client.api.SecStructPredWebServiceClientI;
+
+import static java.lang.String.format;
+
+public class SecStructPredTaskTest
+{
+ protected SecStructPredWebServiceClientI mockClient;
+
+ @BeforeMethod(alwaysRun = true)
+ public void setupMockClient() throws IOException
+ {
+ mockClient = mock(SecStructPredWebServiceClientI.class);
+ when(mockClient.getUrl()).thenReturn("http://example.org");
+ when(mockClient.getClientName()).thenReturn("mock");
+ when(mockClient.getLog(any())).thenReturn("");
+ when(mockClient.getErrorLog(any())).thenReturn("");
+ }
+
+ @DataProvider
+ public Object[][] alignmentWithExpectedInput()
+ {
+ return new Object[][] {
+ {
+ new AlignViewport(createAlignment("AAAAAAAAAAAA", "AAAAAAAAAAAA",
+ "AAAAAAAAAAAA")),
+ List.of("AAAAAAAAAAAA", "AAAAAAAAAAAA", "AAAAAAAAAAAA") },
+ {
+ new AlignViewport(createAlignment("AAAA--NNNNAAAA",
+ "AA--AANNNNAAAA", "AA--AARRRRAAAA")),
+ List.of("AAAA--NNNNAAAA", "AA--AANNNNAAAA", "AA--AARRRRAAAA") },
+ {
+ new AlignViewport(createAlignment("AAAANNNNAAAA--",
+ "AAAARRRRAAAA--", "AAAARRRRAAAA--")),
+ List.of("AAAANNNNAAAA--", "AAAARRRRAAAA--", "AAAARRRRAAAA--") },
+ {
+ new AlignViewport(createAlignment("AAAA--NNNNAAAA",
+ "AAAA--NNNNAAAA", "AAAA--NNNNAAAA")),
+ List.of("AAAA--NNNNAAAA", "AAAA--NNNNAAAA", "AAAA--NNNNAAAA") },
+ {
+ new AlignViewport(createAlignment("AAAACCCCNNNN", "------------",
+ "AAAADDDDNNNN")),
+ List.of("AAAACCCCNNNN", "AAAADDDDNNNN") },
+ {
+ new AlignViewport(createAlignment("AAAACC--NNNN", "AAAACCDDNNNN"),
+ apply(new HiddenColumns(), it -> it.hideColumns(6, 7))),
+ List.of("AAAACCNNNN", "AAAACCNNNN") },
+ {
+ new AlignViewport(
+ createAlignment("CCAAAACC--MMMM", "--AAAAGGGGMMMM"),
+ apply(new HiddenColumns(), it -> {
+ it.hideColumns(0, 1);
+ it.hideColumns(8, 9);
+ })),
+ List.of("AAAACCMMMM", "AAAAGGMMMM") },
+ {
+ new AlignViewport(
+ createAlignment("CCAAAACC--MMMM", "CCAAAACC--MMMM"),
+ apply(new HiddenColumns(), it -> it.hideColumns(2, 5))),
+ List.of("CCCC--MMMM", "CCCC--MMMM") } };
+ }
+
+ public static AlignmentI createAlignment(String... sequences)
+ {
+ var seqArray = new Sequence[sequences.length];
+ for (int i = 0; i < sequences.length; i++)
+ seqArray[i] = new Sequence(format("Seq%d", i), sequences[i]);
+ return new Alignment(seqArray);
+ }
+
+ @Test(groups = { "functional" }, dataProvider = "alignmentWithExpectedInput")
+ public void testPrepareJobs_checkInputSequences(AlignViewport viewport,
+ List<String> expectedInput) throws Exception
+ {
+ var task = new SecStructPredTask(mockClient, List.of(), Credentials.empty(),
+ viewport);
+ var jobs = task.prepareJobs();
+ List<Matcher<? super SequenceI>> seqMatchers = new ArrayList<>(
+ expectedInput.size());
+ for (var seqStr : expectedInput)
+ seqMatchers.add(matchesSequenceString(seqStr));
+ assertThat(jobs.get(0).getInputSequences(),
+ Matchers.<SequenceI> contains(seqMatchers));
+ }
+}