Commit 0a0539e3 authored by Nicola Fulvio Calabria's avatar Nicola Fulvio Calabria
Browse files

Fixed tests

parent 8cac32ac
......@@ -10,10 +10,12 @@ import it.inaf.ia2.aa.data.User;
import it.inaf.oats.vospace.FileServiceClient.ArchiveRequest;
import it.inaf.oats.vospace.datamodel.Views;
import it.inaf.oats.vospace.exception.InvalidArgumentException;
import it.inaf.oats.vospace.parent.exchange.ArchiveEntryDescriptor;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.net.URI;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import net.ivoa.xml.vospace.v2.Param;
import net.ivoa.xml.vospace.v2.Transfer;
......@@ -54,6 +56,9 @@ public class FileServiceClientTest {
@Mock
private HttpServletRequest request;
@Mock
private LinkService linkService;
@InjectMocks
private FileServiceClient fileServiceClient;
......@@ -63,9 +68,7 @@ public class FileServiceClientTest {
ReflectionTestUtils.setField(fileServiceClient, "authority", "example.com!vospace");
ReflectionTestUtils.setField(fileServiceClient, "fileServiceUrl", "http://file-service");
}
// TODO: fix tests
@Test
public void testTarArchiveJob() {
testStartArchiveJob(Views.TAR_VIEW_URI);
......@@ -94,11 +97,14 @@ public class FileServiceClientTest {
View view = new View();
view.setUri(Views.ZIP_VIEW_URI);
transfer.setView(view);
when(linkService.followLinksForArchiveService(any()))
.thenReturn(List.of(new ArchiveEntryDescriptor("/mydir")));
ArchiveRequest archiveRequest = testStartArchiveJob(transfer);
//assertEquals(1, archiveRequest.getPaths().size());
//assertEquals("/mydir", archiveRequest.getPaths().get(0));
assertEquals(1, archiveRequest.getEntryDescriptors().size());
assertEquals("/mydir", archiveRequest.getEntryDescriptors().get(0).getTargetNodeVosPath());
}
@Test
......@@ -155,12 +161,19 @@ public class FileServiceClientTest {
param2.setUri(viewUri + "/include");
param2.setValue("file2");
view.getParam().add(param2);
when(linkService.followLinksForArchiveService(any())).thenReturn(
List.of(new ArchiveEntryDescriptor("/parent_dir/file1"),
new ArchiveEntryDescriptor("/parent_dir/file2")
));
ArchiveRequest archiveRequest = testStartArchiveJob(transfer);
//assertEquals(2, archiveRequest.getPaths().size());
//assertEquals("/parent_dir/file1", archiveRequest.getPaths().get(0));
//assertEquals("/parent_dir/file2", archiveRequest.getPaths().get(1));
assertEquals(2, archiveRequest.getEntryDescriptors().size());
assertEquals("/parent_dir/file1",
archiveRequest.getEntryDescriptors().get(0).getTargetNodeVosPath());
assertEquals("/parent_dir/file2",
archiveRequest.getEntryDescriptors().get(1).getTargetNodeVosPath());
}
private ArchiveRequest testStartArchiveJob(Transfer transfer) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment