Search in sources :

Example 1 with IdProviderDescriptorService

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);
}
Also used : IdProviderDescriptorService(com.enonic.xp.idprovider.IdProviderDescriptorService) PortalScriptService(com.enonic.xp.portal.script.PortalScriptService) SecurityService(com.enonic.xp.security.SecurityService) IdProvider(com.enonic.xp.security.IdProvider) IdProviderConfig(com.enonic.xp.security.IdProviderConfig) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

IdProviderDescriptorService (com.enonic.xp.idprovider.IdProviderDescriptorService)1 PortalScriptService (com.enonic.xp.portal.script.PortalScriptService)1 IdProvider (com.enonic.xp.security.IdProvider)1 IdProviderConfig (com.enonic.xp.security.IdProviderConfig)1 SecurityService (com.enonic.xp.security.SecurityService)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1