-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
better test for checking that spring workflows are detected
- Loading branch information
Edvard Fonsell
committed
Dec 12, 2014
1 parent
2d8541d
commit 86456e8
Showing
3 changed files
with
70 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
...java/com/nitorcreations/nflow/engine/service/WorkflowDefinitionServiceWithSpringTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package com.nitorcreations.nflow.engine.service; | ||
|
||
import static org.hamcrest.Matchers.equalTo; | ||
import static org.hamcrest.Matchers.is; | ||
import static org.junit.Assert.assertThat; | ||
import static org.mockito.Mockito.mock; | ||
|
||
import java.util.List; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.ComponentScan; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.core.io.AbstractResource; | ||
import org.springframework.test.context.ContextConfiguration; | ||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; | ||
import org.springframework.test.context.support.AnnotationConfigContextLoader; | ||
|
||
import com.nitorcreations.nflow.engine.internal.config.NFlow; | ||
import com.nitorcreations.nflow.engine.internal.dao.ExecutorDao; | ||
import com.nitorcreations.nflow.engine.internal.dao.StatisticsDao; | ||
import com.nitorcreations.nflow.engine.internal.dao.WorkflowInstanceDao; | ||
import com.nitorcreations.nflow.engine.workflow.definition.WorkflowDefinition; | ||
import com.nitorcreations.nflow.engine.workflow.definition.WorkflowState; | ||
|
||
@RunWith(SpringJUnit4ClassRunner.class) | ||
@ContextConfiguration(loader = AnnotationConfigContextLoader.class) | ||
public class WorkflowDefinitionServiceWithSpringTest { | ||
|
||
@Configuration | ||
@ComponentScan(basePackageClasses = SpringDummyTestWorkflow.class) | ||
static class ContextConfiguration { | ||
|
||
@Bean | ||
@NFlow | ||
public AbstractResource nflowNonSpringWorkflowsListing() { | ||
return null; | ||
} | ||
|
||
@Bean | ||
public WorkflowInstanceDao workflowInstanceDao() { | ||
return mock(WorkflowInstanceDao.class); | ||
} | ||
|
||
@Bean | ||
public ExecutorDao executorDao() { | ||
return mock(ExecutorDao.class); | ||
} | ||
|
||
@Bean | ||
public StatisticsDao statisticsDao() { | ||
return mock(StatisticsDao.class); | ||
} | ||
} | ||
|
||
@Autowired | ||
private WorkflowDefinitionService service; | ||
|
||
@Test | ||
public void springWorkflowDefinitionsAreDetected() { | ||
List<WorkflowDefinition<? extends WorkflowState>> definitions = service.getWorkflowDefinitions(); | ||
assertThat(definitions.size(), is(equalTo(1))); | ||
assertThat(definitions.get(0).getType(), is(new SpringDummyTestWorkflow().getType())); | ||
} | ||
} |