Skip to content
Snippets Groups Projects
Commit 02fdc3b5 authored by Sonia Zorba's avatar Sonia Zorba
Browse files

Added test case for bug #3612

parent a54dd9de
No related branches found
No related tags found
No related merge requests found
Pipeline #872 passed
...@@ -25,6 +25,9 @@ import net.ivoa.xml.vospace.v2.LinkNode; ...@@ -25,6 +25,9 @@ import net.ivoa.xml.vospace.v2.LinkNode;
import java.util.List; import java.util.List;
import it.inaf.ia2.aa.data.User; import it.inaf.ia2.aa.data.User;
import java.util.Optional; 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.TestPropertySource;
import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextConfiguration;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
...@@ -275,6 +278,29 @@ public class CreateNodeControllerTest { ...@@ -275,6 +278,29 @@ public class CreateNodeControllerTest {
verifyArguments(); 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() { private void verifyArguments() {
verify(controller).createNode( verify(controller).createNode(
argThat(node -> { argThat(node -> {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment