package jnpf.controller; import jnpf.dmsEntity.storage.form.DmsApprovedRegistrationForm; import jnpf.dmsEntity.download.form.DmsWorkflowDownloadAuthorizeForm; import jnpf.dmsEntity.print.form.DmsWorkflowPrintAuthorizeForm; import jnpf.dmsEntity.storage.form.DmsWorkflowFileActivateForm; import org.junit.Test; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import java.lang.reflect.Method; import java.util.List; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; public class DmsFileUploadControllerTest { @Test public void exposesWorkflowFileRegisterAsJsonDmsRoute() throws Exception { assertArrayEquals(new String[]{"/Dms"}, DmsFileUploadController.class.getAnnotation(RequestMapping.class).value()); Method method = DmsFileUploadController.class.getDeclaredMethod("workflowFileRegister", String.class, String.class, DmsApprovedRegistrationForm.class); PostMapping mapping = method.getAnnotation(PostMapping.class); assertArrayEquals(new String[]{"/workflowFileRegister"}, mapping.value()); assertArrayEquals(new String[]{MediaType.APPLICATION_JSON_VALUE}, mapping.consumes()); assertEquals(RequestBody.class, method.getParameters()[2].getAnnotation(RequestBody.class).annotationType()); assertTrue(method.getGenericReturnType().getTypeName().contains( "ActionResult")); } @Test public void exposesWorkflowFileActivateAsJsonDmsRoute() throws Exception { Method method = DmsFileUploadController.class.getDeclaredMethod("workflowFileActivate", DmsWorkflowFileActivateForm.class); PostMapping mapping = method.getAnnotation(PostMapping.class); assertArrayEquals(new String[]{"/workflowFileActivate"}, mapping.value()); assertArrayEquals(new String[]{MediaType.APPLICATION_JSON_VALUE}, mapping.consumes()); assertEquals(RequestBody.class, method.getParameters()[0].getAnnotation(RequestBody.class).annotationType()); } @Test public void exposesWorkflowDownloadAuthorizeAsJsonDmsRoute() throws Exception { Method method = DmsFileUploadController.class.getDeclaredMethod( "workflowFileDownloadAuthorize", String.class, DmsWorkflowDownloadAuthorizeForm.class); PostMapping mapping = method.getAnnotation(PostMapping.class); assertArrayEquals(new String[]{"/workflowFileDownloadAuthorize"}, mapping.value()); assertArrayEquals(new String[]{MediaType.APPLICATION_JSON_VALUE}, mapping.consumes()); assertEquals(RequestBody.class, method.getParameters()[1].getAnnotation(RequestBody.class).annotationType()); } @Test public void exposesWorkflowPrintAuthorizeAsJsonDmsRoute() throws Exception { Method method = DmsFileUploadController.class.getDeclaredMethod( "workflowFilePrintAuthorize", String.class, DmsWorkflowPrintAuthorizeForm.class); PostMapping mapping = method.getAnnotation(PostMapping.class); assertArrayEquals(new String[]{"/workflowFilePrintAuthorize"}, mapping.value()); assertArrayEquals(new String[]{MediaType.APPLICATION_JSON_VALUE}, mapping.consumes()); assertEquals(RequestBody.class, method.getParameters()[1].getAnnotation(RequestBody.class).annotationType()); } }