I have the below method in the @Configuration
class and I need to write JUnit for this. Can anyone please guide me to achieve the JUnit test case?
@Bean
@Profile({"!test & !local"})
@Primary
public DiscoveryClient.DiscoveryClientOptionalArgs getClient() {
try {
DiscoveryClient.DiscoveryClientOptionalArgs args = new DiscoveryClient.DiscoveryClientOptionalArgs();
args.setAdditionalFilters(Collections.singletonList(new HTTPBasicAuthFilter(this.username, this.password)));
args.setSSLContext(sslContext());
System.setProperty("javax.net.ssl.trustStore", this.truststorePath);
System.setProperty("javax.net.ssl.trustStorePassword", this.trustStorePassword);
return args;
} catch (IOException | KeyManagementException | KeyStoreException | NoSuchAlgorithmException | CertificateException e) {
throw new IllegalStateException("Unable to instantiate ssl context or authentication", e);
}
}