From 02fdc3b503d8ba08c68dad26ce9a3e347ec30fad Mon Sep 17 00:00:00 2001
From: Sonia Zorba <sonia.zorba@inaf.it>
Date: Fri, 15 Jan 2021 19:41:32 +0100
Subject: [PATCH] Added test case for bug #3612

---
 .../vospace/CreateNodeControllerTest.java     | 26 +++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/src/test/java/it/inaf/oats/vospace/CreateNodeControllerTest.java b/src/test/java/it/inaf/oats/vospace/CreateNodeControllerTest.java
index 4d8f24d..7439a9a 100644
--- a/src/test/java/it/inaf/oats/vospace/CreateNodeControllerTest.java
+++ b/src/test/java/it/inaf/oats/vospace/CreateNodeControllerTest.java
@@ -25,6 +25,9 @@ import net.ivoa.xml.vospace.v2.LinkNode;
 import java.util.List;
 import it.inaf.ia2.aa.data.User;
 import java.util.Optional;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import org.mockito.ArgumentCaptor;
+import static org.mockito.Mockito.times;
 import org.springframework.test.context.TestPropertySource;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
@@ -274,6 +277,29 @@ public class CreateNodeControllerTest {
 
         verifyArguments();
     }
+    
+    //@Test
+    public void testSubPath() throws Exception {
+
+        String requestBody = getResourceFileContent("create-unstructured-data-node.xml")
+                .replace("/mydata1", "/mydata1/anothernode");
+
+        mockMvc.perform(put("/nodes/mydata1/anothernode")
+                .header("Authorization", "Bearer user2_token")
+                .content(requestBody)
+                .contentType(MediaType.APPLICATION_XML)
+                .accept(MediaType.APPLICATION_XML))
+                .andDo(print())
+                .andExpect(status().isNotFound());
+
+        // Using ArgumentCaptor for verifying multiple method invocations
+        ArgumentCaptor<String> argCaptor = ArgumentCaptor.forClass(String.class);
+        
+        verify(nodeDao, times(2)).listNode(argCaptor.capture());
+        
+        assertEquals("/mydata1/anothernode", argCaptor.getAllValues().get(0));
+        assertEquals("/mydata1", argCaptor.getAllValues().get(1));
+    }
 
     private void verifyArguments() {
         verify(controller).createNode(
-- 
GitLab