Commit 36c10c59 authored by Nicola Fulvio Calabria's avatar Nicola Fulvio Calabria
Browse files

Fixed tests

parent 021514f9
...@@ -10,10 +10,12 @@ import it.inaf.ia2.aa.data.User; ...@@ -10,10 +10,12 @@ import it.inaf.ia2.aa.data.User;
import it.inaf.oats.vospace.FileServiceClient.ArchiveRequest; import it.inaf.oats.vospace.FileServiceClient.ArchiveRequest;
import it.inaf.oats.vospace.datamodel.Views; import it.inaf.oats.vospace.datamodel.Views;
import it.inaf.oats.vospace.exception.InvalidArgumentException; import it.inaf.oats.vospace.exception.InvalidArgumentException;
import it.inaf.oats.vospace.parent.exchange.ArchiveEntryDescriptor;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.UncheckedIOException; import java.io.UncheckedIOException;
import java.net.URI; import java.net.URI;
import java.util.List;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import net.ivoa.xml.vospace.v2.Param; import net.ivoa.xml.vospace.v2.Param;
import net.ivoa.xml.vospace.v2.Transfer; import net.ivoa.xml.vospace.v2.Transfer;
...@@ -54,6 +56,9 @@ public class FileServiceClientTest { ...@@ -54,6 +56,9 @@ public class FileServiceClientTest {
@Mock @Mock
private HttpServletRequest request; private HttpServletRequest request;
@Mock
private LinkService linkService;
@InjectMocks @InjectMocks
private FileServiceClient fileServiceClient; private FileServiceClient fileServiceClient;
...@@ -63,9 +68,7 @@ public class FileServiceClientTest { ...@@ -63,9 +68,7 @@ public class FileServiceClientTest {
ReflectionTestUtils.setField(fileServiceClient, "authority", "example.com!vospace"); ReflectionTestUtils.setField(fileServiceClient, "authority", "example.com!vospace");
ReflectionTestUtils.setField(fileServiceClient, "fileServiceUrl", "http://file-service"); ReflectionTestUtils.setField(fileServiceClient, "fileServiceUrl", "http://file-service");
} }
// TODO: fix tests
@Test @Test
public void testTarArchiveJob() { public void testTarArchiveJob() {
testStartArchiveJob(Views.TAR_VIEW_URI); testStartArchiveJob(Views.TAR_VIEW_URI);
...@@ -94,11 +97,14 @@ public class FileServiceClientTest { ...@@ -94,11 +97,14 @@ public class FileServiceClientTest {
View view = new View(); View view = new View();
view.setUri(Views.ZIP_VIEW_URI); view.setUri(Views.ZIP_VIEW_URI);
transfer.setView(view); transfer.setView(view);
when(linkService.followLinksForArchiveService(any()))
.thenReturn(List.of(new ArchiveEntryDescriptor("/mydir")));
ArchiveRequest archiveRequest = testStartArchiveJob(transfer); ArchiveRequest archiveRequest = testStartArchiveJob(transfer);
//assertEquals(1, archiveRequest.getPaths().size()); assertEquals(1, archiveRequest.getEntryDescriptors().size());
//assertEquals("/mydir", archiveRequest.getPaths().get(0)); assertEquals("/mydir", archiveRequest.getEntryDescriptors().get(0).getTargetNodeVosPath());
} }
@Test @Test
...@@ -155,12 +161,19 @@ public class FileServiceClientTest { ...@@ -155,12 +161,19 @@ public class FileServiceClientTest {
param2.setUri(viewUri + "/include"); param2.setUri(viewUri + "/include");
param2.setValue("file2"); param2.setValue("file2");
view.getParam().add(param2); 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); ArchiveRequest archiveRequest = testStartArchiveJob(transfer);
//assertEquals(2, archiveRequest.getPaths().size()); assertEquals(2, archiveRequest.getEntryDescriptors().size());
//assertEquals("/parent_dir/file1", archiveRequest.getPaths().get(0)); assertEquals("/parent_dir/file1",
//assertEquals("/parent_dir/file2", archiveRequest.getPaths().get(1)); archiveRequest.getEntryDescriptors().get(0).getTargetNodeVosPath());
assertEquals("/parent_dir/file2",
archiveRequest.getEntryDescriptors().get(1).getTargetNodeVosPath());
} }
private ArchiveRequest testStartArchiveJob(Transfer transfer) { 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