diff --git a/src/test/java/it/inaf/oats/vospace/CreateNodeControllerTest.java b/src/test/java/it/inaf/oats/vospace/CreateNodeControllerTest.java index 4d8f24daf920e20695e40858ced55cb9fbcf4018..7439a9a3c20caf60adeb2c076e57030e1100cead 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(