import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
+import static org.hamcrest.Matchers.equalTo;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.List;
import static org.mockito.Mockito.mock;
import jalview.io.DataSourceType;
import jalview.io.FastaFile;
import jalview.io.JPredFile;
+
+import org.hamcrest.Matcher;
+import org.hamcrest.Matchers;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.HiddenColumns;
import jalview.datamodel.Sequence;
+import jalview.datamodel.SequenceI;
import jalview.gui.AlignViewport;
import jalview.ws2.actions.ServiceInputInvalidException;
import jalview.ws2.api.Credentials;
+import jalview.ws2.api.JobStatus;
+import jalview.ws2.api.WebServiceJobHandle;
import jalview.ws2.client.api.SecStructPredWebServiceClientI;
import static java.lang.String.format;
@DataProvider
public Object[][] viewportWithTooShortSequence()
{
- return new Object[][] { { new AlignViewport(createAlignment("")) },
+ return new Object[][] {
+ { new AlignViewport(createAlignment("")) },
{ new AlignViewport(createAlignment("A")) },
{ new AlignViewport(createAlignment("AAAAAAAAAAAAAAAAAAA")) },
{ new AlignViewport(createAlignment("AAAAACCCCCAAAAA-----CC")) },
};
}
- @Test(
- groups = { "Functional" }
- )
- public void testCollectResult(AlignViewport viewport, String alnFileName, String predFileName) throws Exception
+ @Test(groups = { "Functional" }, dataProvider = "collectResultDataset")
+ public void testCollectResult(AlignViewport viewport, String alnFileName,
+ String predFileName) throws Exception
{
var alnFile = new FastaFile(alnFileName, DataSourceType.FILE);
var predFile = new JPredFile(predFileName, DataSourceType.FILE);
+ when(mockClient.getPredictionFile(any())).thenReturn(predFile);
+ when(mockClient.getAlignmentFile(any())).thenReturn(alnFile);
+ when(mockClient.getStatus(any())).thenReturn(JobStatus.COMPLETED);
+ when(mockClient.submit(any(), any(), any()))
+ .thenReturn(new WebServiceJobHandle("mock", "mock",
+ "http://example.org", "0"));
+
+ var task = new SecStructPredPDBSearchTask(mockClient, List.of(),
+ Credentials.empty(), viewport);
+ task.init();
+ task.poll();
+ task.complete();
+ var resultAlignment = task.getResult();
+ var sequences = resultAlignment.getSequences();
+
+ {
+ List<Matcher<? super SequenceI>> matchers = new ArrayList<>();
+ for (var seq : alnFile.getSeqs())
+ matchers.add(matchesSequenceString(seq));
+ assertThat(sequences, Matchers.contains(matchers));
+ }
+
+ {
+ var originalHidden = viewport.getAlignment().getHiddenColumns();
+ var resultHidden = resultAlignment.getHiddenColumns();
+ assertThat(resultHidden, equalTo(originalHidden));
+ }
}
}