Search in sources :

Example 1 with TestDistributeOnceElasticJobListener

use of com.dangdang.ddframe.job.lite.api.listener.fixture.TestDistributeOnceElasticJobListener in project elastic-job by dangdangdotcom.

the class JobExecutorTest method assertNew.

@Test
public void assertNew() throws NoSuchFieldException {
    TestDistributeOnceElasticJobListener testDistributeOnceElasticJobListener = new TestDistributeOnceElasticJobListener(caller);
    assertNull(ReflectionUtils.getFieldValue(testDistributeOnceElasticJobListener, ReflectionUtils.getFieldWithName(AbstractDistributeOnceElasticJobListener.class, "guaranteeService", false)));
    new JobExecutor(null, liteJobConfig, new TestElasticJobListener(caller), testDistributeOnceElasticJobListener);
    assertNotNull(ReflectionUtils.getFieldValue(testDistributeOnceElasticJobListener, ReflectionUtils.getFieldWithName(AbstractDistributeOnceElasticJobListener.class, "guaranteeService", false)));
}
Also used : TestDistributeOnceElasticJobListener(com.dangdang.ddframe.job.lite.api.listener.fixture.TestDistributeOnceElasticJobListener) TestElasticJobListener(com.dangdang.ddframe.job.lite.api.listener.fixture.TestElasticJobListener) Test(org.junit.Test)

Example 2 with TestDistributeOnceElasticJobListener

use of com.dangdang.ddframe.job.lite.api.listener.fixture.TestDistributeOnceElasticJobListener in project elastic-job by dangdangdotcom.

the class DistributeOnceElasticJobListenerTest method setUp.

@Before
public void setUp() throws NoSuchFieldException {
    MockitoAnnotations.initMocks(this);
    distributeOnceElasticJobListener = new TestDistributeOnceElasticJobListener(elasticJobListenerCaller);
    ReflectionUtils.setFieldValue(distributeOnceElasticJobListener, ReflectionUtils.getFieldWithName(AbstractDistributeOnceElasticJobListener.class, "guaranteeService", false), guaranteeService);
    ReflectionUtils.setFieldValue(distributeOnceElasticJobListener, ReflectionUtils.getFieldWithName(AbstractDistributeOnceElasticJobListener.class, "timeService", false), timeService);
    Map<Integer, String> map = new HashMap<>(2, 1);
    map.put(0, "");
    map.put(1, "");
    shardingContexts = new ShardingContexts("fake_task_id", "test_job", 10, "", map);
}
Also used : TestDistributeOnceElasticJobListener(com.dangdang.ddframe.job.lite.api.listener.fixture.TestDistributeOnceElasticJobListener) HashMap(java.util.HashMap) ShardingContexts(com.dangdang.ddframe.job.executor.ShardingContexts) Before(org.junit.Before)

Aggregations

TestDistributeOnceElasticJobListener (com.dangdang.ddframe.job.lite.api.listener.fixture.TestDistributeOnceElasticJobListener)2 ShardingContexts (com.dangdang.ddframe.job.executor.ShardingContexts)1 TestElasticJobListener (com.dangdang.ddframe.job.lite.api.listener.fixture.TestElasticJobListener)1 HashMap (java.util.HashMap)1 Before (org.junit.Before)1 Test (org.junit.Test)1