use of com.enonic.xp.idprovider.IdProviderDescriptorService in project xp by enonic.
the class IdProviderControllerServiceImplTest method setup.
@BeforeEach
public void setup() throws Exception {
// Mocks the IdProviderDescriptorService
final IdProviderDescriptorService idProviderDescriptorService = Mockito.mock(IdProviderDescriptorService.class);
Mockito.when(idProviderDescriptorService.getDescriptor(ApplicationKey.from("myapplication"))).thenReturn(IdProviderDescriptor.create().key(ApplicationKey.from("myapplication")).build());
// Mocks the SecurityService
final SecurityService securityService = Mockito.mock(SecurityService.class);
final IdProvider emptyIdProvider = IdProvider.create().build();
final IdProviderConfig idProviderConfig = IdProviderConfig.create().applicationKey(ApplicationKey.from("myapplication")).build();
final IdProvider idProvider = IdProvider.create().idProviderConfig(idProviderConfig).build();
Mockito.when(securityService.getIdProvider(IdProviderKey.from("myemptyidprovider"))).thenReturn(emptyIdProvider);
Mockito.when(securityService.getIdProvider(IdProviderKey.from("myidprovider"))).thenReturn(idProvider);
Mockito.when(securityService.getIdProvider(IdProviderKey.from("myemptyuserstore"))).thenReturn(emptyIdProvider);
Mockito.when(securityService.getIdProvider(IdProviderKey.from("myuserstore"))).thenReturn(idProvider);
// Mocks the PortalScriptService
final PortalScriptService portalScriptService = setupPortalScriptService();
// Creates IdProviderControllerScriptFactoryImpl
final IdProviderControllerScriptFactoryImpl idProviderControllerScriptFactory = new IdProviderControllerScriptFactoryImpl();
idProviderControllerScriptFactory.setScriptService(portalScriptService);
// Creates IdProviderControllerServiceImpl
idProviderControllerService = new IdProviderControllerServiceImpl();
idProviderControllerService.setIdProviderControllerScriptFactory(idProviderControllerScriptFactory);
idProviderControllerService.setIdProviderDescriptorService(idProviderDescriptorService);
idProviderControllerService.setSecurityService(securityService);
}
Aggregations