Java Optional List and Cassandra - Passing Array to Optional List

by ananth reddy   Last Updated March 14, 2019 20:26 PM

I have a Java Repository class with a method to get the values from DB.

@Query("Select * from r_t_status where status IN (:status) ALLOW FILTERING")
public Optional<List<RTStatusEntity>> findAllByStatus(@Param("status") List<String> status);

I have written the following JUnit test case for the above method.

    public void testfindAllByStatus() {
        saveEntity();//mocking db entity
        Optional<List<RTEntity>> entity = rTStatusRepository
        assertEquals(1, entity.get().size());

private void saveEntity() {, TEST_TIME1, TEST_REQUESTID1,

Expected Behavior: Test case should return success. Actual Behavior: Test case fails and throws an assertion error.expected:<1> but was:<0> not sure why.

Is there anything wrong that I'm doing here for the test to fail?

Related Questions

JUnit test always fails when comparing two objects

Updated August 17, 2016 08:11 AM

Java8 : stream findFirst result

Updated June 09, 2017 15:26 PM