@Test void taskShouldBeSerializable() throws Exception { MailQueueFactory<ManageableMailQueue> mailQueueFactory = mock(MailQueueFactory.class); ManageableMailQueue mockedQueue = mock(ManageableMailQueue.class); when(mockedQueue.getName()).thenReturn(QUEUE_NAME); when(mailQueueFactory.getQueue(any(MailQueueName.class))).thenAnswer(arg -> Optional.of(mockedQueue)); ClearMailQueueTask.MailQueueFactory factory = queueName -> mailQueueFactory.getQueue(queueName).orElseThrow(RuntimeException::new); ClearMailQueueTask task = new ClearMailQueueTask(QUEUE_NAME, factory); JsonSerializationVerifier.dtoModule(ClearMailQueueTaskDTO.module(mailQueueFactory)) .bean(task) .json(SERIALIZED) .equalityTester((a, b) -> assertThat(a.getQueueName()).isEqualTo(b.getQueueName())) .verify(); }
MailQueueName getQueueName() { return queueName; }
ClearMailQueueTask implements Task { MailQueueName getQueueName() { return queueName; } }
ClearMailQueueTask implements Task { MailQueueName getQueueName() { return queueName; } ClearMailQueueTask(MailQueueName queueName, ClearMailQueueTask.MailQueueFactory factory); }
ClearMailQueueTask implements Task { MailQueueName getQueueName() { return queueName; } ClearMailQueueTask(MailQueueName queueName, ClearMailQueueTask.MailQueueFactory factory); @Override Result run(); @Override TaskType type(); @Override Optional<TaskExecutionDetails.AdditionalInformation> details(); }
ClearMailQueueTask implements Task { MailQueueName getQueueName() { return queueName; } ClearMailQueueTask(MailQueueName queueName, ClearMailQueueTask.MailQueueFactory factory); @Override Result run(); @Override TaskType type(); @Override Optional<TaskExecutionDetails.AdditionalInformation> details(); static final TaskType TYPE; }