Trying to test a gateway in spring integration using mockito but when autowiring the gateway its always null.
I am using annotations to create a context for writing the test case, but the mockito and annotations are all working weird. Getting no support or basic understanding that what is going wrong here.
Can anyone please suggest a simple way or how to test a spring integration flow, which starts with a gateway. As the value for the gateway is coming null for me in the test.
we are using java annotations to define the spring integration flow like below :
public class integrationFlow()
{
@MessagingGateway
public interface EnterHere{
@Gateway(requestChannel = "requestChannel")
void process(DtoObject dtoObject)
}
@Bean
public IntegrationFlow myFlow() {
return IntegrationFlows.from(requestChannel)
.filter()
//... its a big flow with lot of interactions
.get();
}
}
I have written a test case that will create an object with default values that will be passed to the dto and that will trigger the flow of spring integration. i want to use mockito here as there are lots of dependencies in the project.
i am using
@Autowired
private EnterHere enterhere
and in contextconfguration for the test case i am defining
@MessagingGateway
public interface EnterHere{
@Gateway(requestChannel = "requestChannel")
void process(DtoObject dtoObject)
}
But when in the test case
@Test
public void testGateway(){
enterHere.process(this.dtoObjectMock)
// i am always getting a null value at this enterhere.
}
We are not using Spring boot , we are using Mockito annotations, @Mock and @InjectMocks ,@Runwith(MockitoJunit4Runner.class) like these