@Service
public class MyRegistry {
private final Map<String, CustomClass> services;
@Autowired
public MyRegistry(List<CustomClass> msgList) {
this.services = msgList.stream().collect(Collectors.tounmodifiableMap(CustomClass:: getId, s->s));
}
public CustomClass getIns(final String name){
final CustomClass customClass = services.get(name);
return customClass;
}
I have been asked to test this class by loading spring context, I have tried running the below test case with @ActiveProfiles("local") that works but that fails on dev environment, how to fix this issue.
Below is my test case:
@SpringBootTest
@ActiveProfiles("local")
class MyTestClass {
@Autowired
MyRegistry myRegistry;
@ParameterizedTest
@CsvSource( value={constant1, constant2} )
void getValue(String id){
# assertNotNull(myRegistry.getInstanceId());
}
}
Looking for solution.