In my java spring mvc application, i am using the below code:
The repository:
@Repository
public interface TransactionRepository extends JpaRepository<Transactions ,Long >{
@Query(value = "SELECT sum( value) FROM Transactions inner join Customer on Transactions.customer_id=Customer.id where merchant_id= ?1 and age_class= ?2 ", nativeQuery=true)
public double getOverAllValue(String merchantID,String ageGroup);
}
and then i made a serivce which works based on this @Repository
:
@Service
public class IncomeDataService {
@Autowired
TransactionRepository transactionRepo;
public ArrayList<Double> dataCollector(int merchantID){
ArrayList<Double> data= new ArrayList<Double>();
for(int i=0;i<10;i++)
data.add( transactionRepo.getOverAllValue(Integer.toString(merchantID),Integer.toString(i)));
return data;
}
and then i am trying to test the written service using the junit
:
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = SEBApplication.class)
public class IncomeDataServiceTest {
@Autowired
IncomeDataService incomeDataService;
@Test
public void testDataCollector() {
System.out.println(incomeDataService.dataCollector(1));
}
}
But, when i run my test it complains with:
org.springframework.aop.AopInvocationException: Null return value from advice does not match primitive return type for: public abstract double ee.seb.domain.repository.TransactionRepository.getOverAllValue(java.lang.String,java.lang.String)