I am trying to write the Junit test cases for the below hazelcast Jet Pipeline.
My component:
@Component
public class UserJetJob extends AbstarctJetJob {
private static final String TABLE_NAME = "User";
@Autowired
private ClientConfig clientConfig;
@Value("${jdbc.connection_url}")
private String connectionUrl;
@Override
public Pipeline buildPipeline() {
Pipeline p = Pipeline.create();
p.readFrom(Sources.jdbc(connectionUrl,
"SELECT * FROM " + TABLE_NAME,
UserJetJob::buildUser))
.map(a -> Util.entry(a.getId(), a))
.writeTo(Sinks.remoteMap("userMap", clientConfig));
return p;
}
}
I am writing a JUnit
test case for the method public Pipeline buildPipeline()
but it's failing due to the resultset.
@ExtendWith(MockitoExtension.class)
public class UserJetJobTest extends JetTestSupport {
@InjectMocks
UserJetJob userJetJob;
@Mock
private JetInstance jet;
@Mock
private ClientConfig clientConfig;
@Test
public void buildPipelineUser() {
Pipeline p = Mockito.mock(Pipeline.class);
// Mockito.when(p.readFrom(Sources.jdbc(Mockito.anyString(), Mockito.anyString(), Mockito.eq(ResultSet.class))).then
userJetJob.buildPipeline();
}
}
Could you please help me with how to write JUnit test cases?