Loading src/test/java/it/inaf/oats/vospace/CreateNodeControllerTest.java +26 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -275,6 +278,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( argThat(node -> { Loading Loading
src/test/java/it/inaf/oats/vospace/CreateNodeControllerTest.java +26 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -275,6 +278,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( argThat(node -> { Loading