use of io.jans.as.client.uma.UmaClientFactory in project jans by JanssenProject.
the class OpClientFactoryMockImpl method createUmaClientFactory.
public synchronized UmaClientFactory createUmaClientFactory() {
Optional<UmaClientFactory> umaClientFactoryOpt = Optional.ofNullable((UmaClientFactory) opClientCache.getIfPresent("umaClientFactory"));
Optional<UmaMetadataService> umaMetadataServiceOpt = Optional.ofNullable((UmaMetadataService) opClientCache.getIfPresent("UmaMetadataService"));
UmaClientFactory umaClientFactory = null;
if (!umaClientFactoryOpt.isPresent() || !umaMetadataServiceOpt.isPresent()) {
umaClientFactory = mock(UmaClientFactory.class);
UmaMetadataService umaMetadataService = mock(UmaMetadataService.class);
UmaMetadata umaMetadata = new UmaMetadata();
when(umaClientFactory.createMetadataService(any(), any())).thenReturn(umaMetadataService);
when(umaMetadataService.getMetadata()).thenReturn(umaMetadata);
opClientCache.put("umaClientFactory", umaClientFactory);
opClientCache.put("UmaMetadataService", umaMetadataService);
} else {
umaClientFactory = (UmaClientFactory) opClientCache.getIfPresent("umaClientFactory");
}
return umaClientFactory;
}
Aggregations