### Question:
TaichiMessageFactory extends AbstractMessageFactory { @Override protected Message.SOURCE getSource() { return Message.SOURCE.TAICHI; }  @Override List<Message2Send> getMessage( MessageProcessUnit inUnit);  }### Answer:
@Test public void getSourceMessageNoLastTimeTest() { final Source sourceF = new SourceMock(8205, "taichi.fast", 255, System.currentTimeMillis()); final Subscription theSubscription = new SubscriptionMock(1, Factories.APPLICATION.findByName("net.violet.taichi"), getKowalskyObject()); theSubscription.setSettings(Collections.singletonMap(TaichiHandler.SOURCE, sourceF.getSource_path())); final SubscriptionData theSubscriptionData = SubscriptionData.getData(theSubscription); final SubscriptionSchedulingData theScheduling = SubscriptionSchedulingData.create(theSubscriptionData, SchedulingType.SCHEDULING_TYPE.Ambiant); final TaichiMessageFactory factory = (TaichiMessageFactory) AbstractMessageFactory.getFactoryByApplication(theSubscription.getApplication()); final long theLastTime = System.currentTimeMillis(); final MessageDraft theMessage = factory.getSourceMessage(theScheduling, theLastTime); Assert.assertNotNull(theMessage); Assert.assertTrue(theMessage.isSourceModeUpdate()); Assert.assertEquals(new Integer((int) sourceF.getSource_val()), theMessage.getSources().get(Integer.toString(factory.getSource().getId()))); Assert.assertEquals(Constantes.QUEUE_TTL_SOURCES, theMessage.getTTLInSecond()); final SubscriptionSchedulingSettingsData theLastTimeSetting = SubscriptionSchedulingSettingsData.findBySubscriptionSchedulingAndKey(theScheduling, AmbiantHandler.LAST_TIME); Assert.assertNotNull(theLastTimeSetting); Assert.assertEquals(theLastTime, Long.parseLong(theLastTimeSetting.getValue())); sourceF.delete(); }
@Test public void getSourceMessageWithLastTimeUTest() { final long sourceUpdateTime = System.currentTimeMillis() / 1000; final Source sourceS = new SourceMock(8206, "taichi.slow", 40, System.currentTimeMillis()); final long theLastTime = sourceUpdateTime * 1000; final Subscription theSubscription = new SubscriptionMock(1, Factories.APPLICATION.findByName("net.violet.taichi"), getKowalskyObject()); theSubscription.setSettings(Collections.singletonMap(TaichiHandler.SOURCE, sourceS.getSource_path())); final SubscriptionData theSubscriptionData = SubscriptionData.getData(theSubscription); final SubscriptionSchedulingData theScheduling = SubscriptionSchedulingData.create(theSubscriptionData, SchedulingType.SCHEDULING_TYPE.Ambiant); theScheduling.createSetting(AmbiantHandler.LAST_TIME, "0"); final TaichiMessageFactory factory = (TaichiMessageFactory) AbstractMessageFactory.getFactoryByApplication(theSubscription.getApplication()); final MessageDraft theMessage = factory.getSourceMessage(theScheduling, theLastTime); Assert.assertNotNull(theMessage); Assert.assertTrue(theMessage.isSourceModeUpdate()); Assert.assertEquals(new Integer((int) sourceS.getSource_val()), theMessage.getSources().get(Integer.toString(factory.getSource().getId()))); Assert.assertEquals(Constantes.QUEUE_TTL_SOURCES, theMessage.getTTLInSecond()); final SubscriptionSchedulingSettingsData theLastTimeSetting = SubscriptionSchedulingSettingsData.findBySubscriptionSchedulingAndKey(theScheduling, AmbiantHandler.LAST_TIME); Assert.assertNotNull(theLastTimeSetting); Assert.assertEquals(theLastTime, Long.parseLong(theLastTimeSetting.getValue())); sourceS.delete(); }