I am trying to mock a generic interface resource that has multiple options in one class. I found something that gets passed the named resources, that being to name the variable the same as the name parameter on the Resource. But if I have two @Injectable fields that have the same name (but different generic types) I cannot do this for both. Is there a way around this?
@Service("SourceDescriptionService")
public class SourceDescriptionServiceImpl implements CrudService<LnssDescription> {
@Resource(name = "LnssCrudRepository")
private LnssCrudRepository<LnssDescription> descriptionRepository;
@Resource(name = "SourceRepository")
private SourceRepository sourceRepository;
@Resource(name = "LnssCruRepository")
private LnssCruRepository<LnssState> stateRepository;
@Resource(name = "LnssCruRepository")
private LnssCruRepository<LnssVariant> variantRepository;
And my attempt at testing:
@Tested
private SourceDescriptionServiceImpl sut;
@Injectable
private SourceRepository SourceRepository;
@Injectable
private LnssCrudRepository<LnssDescription> LnssCrudRepository;
@Injectable
private LnssCruRepository<?> LnssCruRepository;
I've tried other variations on the CruRepository interface like parameterizing the LnssState, which then gives LnssVariant as the error or removing the parameterization which just goes back to the state being the error.
This is the error:
java.lang.IllegalStateException: Missing @Injectable for field "com.ln.sourceset.model.repository.LnssCruRepository<com.ln.sourceset.model.data.LnssState> stateRepository" in SourceDescriptionServiceImpl
Any help would be greatly appreciated! Thanks.