FormEventListener { @MotechListener(subjects = FormSubmissionEvent.SUBJECT) public void submitForms(MotechEvent event) { List<FormSubmissionDTO> formSubmissions = new Gson().fromJson((String) event.getParameters().get("data"), new TypeToken<List<FormSubmissionDTO>>() { }.getType()); logger.info("Submitting Forms"); formSubmissionService.submit(formSubmissions); } @Autowired  FormEventListener(FormSubmissionService formSubmissionService, FormEntityService formEntityService, AllFormExportTokens allFormExportTokens); @MotechListener(subjects = FormSubmissionEvent.SUBJECT) void submitForms(MotechEvent event); @MotechListener(subjects = DrishtiFormScheduler.SUBJECT) void fetchForms(MotechEvent event);  }
@Test public void shouldDelegateFormSubmissionToSubmissionService() throws Exception { List<FormSubmissionDTO> formSubmissions = asList(new FormSubmissionDTO("anm id 1", "instance id 1", "entity id 1", "form name", null, "0", "1"), new FormSubmissionDTO("anm id 2", "instance id 2", "entity id 2", "form name", null, "0", "1")); listener.submitForms(new MotechEvent(FormSubmissionEvent.SUBJECT, mapOf("data", (Object) new Gson().toJson(formSubmissions)))); verify(formSubmissionService).submit(formSubmissions); }