Commit 1907e7fb authored by Nicola Fulvio Calabria's avatar Nicola Fulvio Calabria
Browse files

Minor fixes

parent 023b82fb
Loading
Loading
Loading
Loading
+3 −3
Original line number Original line Diff line number Diff line
@@ -329,8 +329,6 @@ public class UriService {
        String linkTarget = linkNode.getTarget();
        String linkTarget = linkNode.getTarget();


        if (URIUtils.isURIInternal(linkTarget)) {
        if (URIUtils.isURIInternal(linkTarget)) {
            return linkNode;
        } else {
            String targetPath = URIUtils.returnVosPathFromNodeURI(linkTarget, authority);
            String targetPath = URIUtils.returnVosPathFromNodeURI(linkTarget, authority);


            Optional<Node> targetNodeOpt = nodeDao.listNode(targetPath);
            Optional<Node> targetNodeOpt = nodeDao.listNode(targetPath);
@@ -341,6 +339,8 @@ public class UriService {
            } else {
            } else {
                return targetNode;
                return targetNode;
            }
            }
        } else {
            return linkNode;
        }
        }
    }
    }


+14 −10
Original line number Original line Diff line number Diff line
@@ -15,6 +15,7 @@ import it.inaf.oats.vospace.exception.InvalidArgumentException;
import it.inaf.oats.vospace.exception.NodeBusyException;
import it.inaf.oats.vospace.exception.NodeBusyException;
import it.inaf.oats.vospace.exception.PermissionDeniedException;
import it.inaf.oats.vospace.exception.PermissionDeniedException;
import it.inaf.oats.vospace.exception.ProtocolNotSupportedException;
import it.inaf.oats.vospace.exception.ProtocolNotSupportedException;
import it.inaf.oats.vospace.persistence.LinkedServiceDAO;
import it.inaf.oats.vospace.persistence.LocationDAO;
import it.inaf.oats.vospace.persistence.LocationDAO;
import it.inaf.oats.vospace.persistence.NodeDAO;
import it.inaf.oats.vospace.persistence.NodeDAO;
import it.inaf.oats.vospace.persistence.model.Location;
import it.inaf.oats.vospace.persistence.model.Location;
@@ -70,6 +71,9 @@ public class UriServiceTest {
    @MockBean
    @MockBean
    private CreateNodeService createNodeService;
    private CreateNodeService createNodeService;
    
    
    @MockBean
    private LinkedServiceDAO linkedServiceDAO;

    @MockBean
    @MockBean
    private FileServiceClient fileServiceClient;
    private FileServiceClient fileServiceClient;


@@ -95,11 +99,14 @@ public class UriServiceTest {
        }
        }
    }
    }
    
    
    public final static String PORTAL_URL = "http://portalurl.ia2.inaf.it/portal/files";
    
    @BeforeEach
    @BeforeEach
    public void init() {
    public void init() {
        Location location = new Location();
        Location location = new Location();
        location.setType(LocationType.ASYNC);
        location.setType(LocationType.ASYNC);
        when(locationDAO.getNodeLocation(any())).thenReturn(Optional.of(location));
        when(locationDAO.getNodeLocation(any())).thenReturn(Optional.of(location));
        when(linkedServiceDAO.isLinkedServiceUrl(eq(PORTAL_URL))).thenReturn(Boolean.TRUE);       
    }
    }


    @Test
    @Test
@@ -382,13 +389,6 @@ public class UriServiceTest {
        
        
        when(servletRequest.getUserPrincipal()).thenReturn(user);
        when(servletRequest.getUserPrincipal()).thenReturn(user);
       
       
        
        when(rapClient.exchangeToken(argThat(req -> {
            assertEquals("<token>", req.getSubjectToken());
            assertEquals("http://file-service/mydummydata1", req.getResource());
            return true;
        }), any())).thenReturn("<new-token>");
        
        JobSummary job = getPullFromVoSpaceJob(targetOfPull);
        JobSummary job = getPullFromVoSpaceJob(targetOfPull);
        Transfer tr = uriService.getTransfer(job);
        Transfer tr = uriService.getTransfer(job);
        
        
@@ -590,8 +590,12 @@ public class UriServiceTest {
        mockPublicNode("parent_dir/file1");
        mockPublicNode("parent_dir/file1");
        mockPublicNode("parent_dir/file2");
        mockPublicNode("parent_dir/file2");
        
        
        when(fileServiceClient.startArchiveJob(any(), any()))
                .thenReturn("http://file-service/mockarchive");

        uriService.getNegotiatedTransfer(job, transfer);
        uriService.getNegotiatedTransfer(job, transfer);
        
        
        
        verify(fileServiceClient, times(1)).startArchiveJob(transfer, "archive-job-id");
        verify(fileServiceClient, times(1)).startArchiveJob(transfer, "archive-job-id");
    }
    }