Search in sources :

Example 6 with ConfigurationKeyValuePathLevel

use of alfio.model.system.ConfigurationKeyValuePathLevel in project alf.io by alfio-event.

the class FeeCalculatorTest method setUp.

@BeforeEach
void setUp() {
    event = mock(EventAndOrganizationId.class);
    configurationManager = mock(ConfigurationManager.class);
    when(configurationManager.getFor(eq(PLATFORM_MODE_ENABLED), any())).thenReturn(new MaybeConfiguration(PLATFORM_MODE_ENABLED, new ConfigurationKeyValuePathLevel(PLATFORM_MODE_ENABLED.name(), "true", null)));
}
Also used : EventAndOrganizationId(alfio.model.EventAndOrganizationId) ConfigurationManager(alfio.manager.system.ConfigurationManager) ConfigurationKeyValuePathLevel(alfio.model.system.ConfigurationKeyValuePathLevel) MaybeConfiguration(alfio.manager.system.ConfigurationManager.MaybeConfiguration) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 7 with ConfigurationKeyValuePathLevel

use of alfio.model.system.ConfigurationKeyValuePathLevel in project alf.io by alfio-event.

the class AdminOpenIdAuthenticationManagerTest method setUp.

@BeforeEach
void setUp() {
    environment = mock(Environment.class);
    when(environment.getProperty(eq("openid.domain"))).thenReturn(DOMAIN);
    when(environment.getProperty(eq("openid.clientId"))).thenReturn(CLIENT_ID);
    when(environment.getProperty(eq("openid.clientSecret"))).thenReturn(CLIENT_SECRET);
    when(environment.getProperty(eq("openid.callbackURI"), anyString())).thenReturn(CALLBACK_URI);
    when(environment.getProperty(eq("openid.authenticationUrl"))).thenReturn(AUTHENTICATION_URL);
    when(environment.getProperty(eq("openid.tokenEndpoint"), anyString())).thenReturn(CLAIMS_URI);
    when(environment.getProperty(eq("openid.contentType"), anyString())).thenReturn(CONTENT_TYPE);
    when(environment.getProperty(eq("openid.rolesParameter"))).thenReturn(GROUPS_NAME);
    when(environment.getProperty(eq("openid.alfioGroupsParameter"))).thenReturn(ALFIO_GROUPS_NAME);
    when(environment.getProperty(eq("openid.logoutUrl"))).thenReturn(LOGOUT_URL);
    when(environment.getProperty(eq("openid.logoutRedirectUrl"), anyString())).thenReturn(LOGOUT_REDIRECT_URL);
    var configurationManager = mock(ConfigurationManager.class);
    when(configurationManager.getFor(eq(ConfigurationKeys.BASE_URL), any())).thenReturn(new ConfigurationManager.MaybeConfiguration(ConfigurationKeys.BASE_URL, new ConfigurationKeyValuePathLevel("", "blabla", ConfigurationPathLevel.SYSTEM)));
    authenticationManager = new AdminOpenIdAuthenticationManager(environment, null, configurationManager, null, null, null, null, null, null, null, new Json());
}
Also used : AdminOpenIdAuthenticationManager(alfio.manager.openid.AdminOpenIdAuthenticationManager) Environment(org.springframework.core.env.Environment) Json(alfio.util.Json) ConfigurationManager(alfio.manager.system.ConfigurationManager) ConfigurationKeyValuePathLevel(alfio.model.system.ConfigurationKeyValuePathLevel) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 8 with ConfigurationKeyValuePathLevel

use of alfio.model.system.ConfigurationKeyValuePathLevel in project alf.io by alfio-event.

the class WaitingQueueSubscriptionProcessorTest method filterWaitingQueueFlagIsNotActive.

@Test
void filterWaitingQueueFlagIsNotActive() {
    when(configurationManager.getFor(eq(Set.of(ENABLE_WAITING_QUEUE, ENABLE_PRE_REGISTRATION)), any())).thenReturn(Map.of(ENABLE_WAITING_QUEUE, new ConfigurationManager.MaybeConfiguration(ENABLE_WAITING_QUEUE, new ConfigurationKeyValuePathLevel("", "false", null)), ENABLE_PRE_REGISTRATION, new ConfigurationManager.MaybeConfiguration(ENABLE_PRE_REGISTRATION)));
    processor.handleWaitingTickets();
    verify(waitingQueueManager, never()).distributeSeats(eq(event));
}
Also used : ConfigurationKeyValuePathLevel(alfio.model.system.ConfigurationKeyValuePathLevel) Test(org.junit.jupiter.api.Test)

Example 9 with ConfigurationKeyValuePathLevel

use of alfio.model.system.ConfigurationKeyValuePathLevel in project alf.io by alfio-event.

the class TicketReservationManagerTest method initOfflinePaymentTest.

private void initOfflinePaymentTest() {
    when(configurationManager.getFor(eq(OFFLINE_PAYMENT_DAYS), any())).thenReturn(new MaybeConfiguration(OFFLINE_PAYMENT_DAYS, new ConfigurationKeyValuePathLevel(OFFLINE_PAYMENT_DAYS.getValue(), "2", null)));
    when(event.getZoneId()).thenReturn(ClockProvider.clock().getZone());
}
Also used : ConfigurationKeyValuePathLevel(alfio.model.system.ConfigurationKeyValuePathLevel) MaybeConfiguration(alfio.manager.system.ConfigurationManager.MaybeConfiguration)

Example 10 with ConfigurationKeyValuePathLevel

use of alfio.model.system.ConfigurationKeyValuePathLevel in project alf.io by alfio-event.

the class SendGridMailerTest method shouldSendEmail.

@Test
public void shouldSendEmail() throws IOException, InterruptedException {
    // Test data
    final var apiConfig = new ConfigurationManager.MaybeConfiguration(ConfigurationKeys.SENDGRID_API_KEY, new ConfigurationKeyValuePathLevel("key", "value", ConfigurationPathLevel.SYSTEM));
    final var fromConfig = new ConfigurationManager.MaybeConfiguration(ConfigurationKeys.SENDGRID_FROM, new ConfigurationKeyValuePathLevel("key", "value", ConfigurationPathLevel.SYSTEM));
    // Mock
    when(configurationManager.getFor(anySet(), any(ConfigurationLevel.class))).thenReturn(Map.of(ConfigurationKeys.SENDGRID_API_KEY, apiConfig, ConfigurationKeys.SENDGRID_FROM, fromConfig));
    final HttpResponse<Object> httpResponse = createMockHttpResponse();
    when(client.send(any(HttpRequest.class), any())).thenReturn(httpResponse);
    // Service call
    sendGridMailer.send(new EventAndOrganizationId(1, 2), "Test", "TestEmail", List.of(), "TestSubject", "Test", Optional.empty(), ArrayUtils.toArray());
    // Verify
    verify(configurationManager).getFor(anySet(), any(ConfigurationLevel.class));
    verify(client).send(any(HttpRequest.class), any());
    verifyNoMoreInteractions(configurationManager, client);
}
Also used : HttpRequest(java.net.http.HttpRequest) EventAndOrganizationId(alfio.model.EventAndOrganizationId) ConfigurationKeyValuePathLevel(alfio.model.system.ConfigurationKeyValuePathLevel) Test(org.junit.jupiter.api.Test)

Aggregations

ConfigurationKeyValuePathLevel (alfio.model.system.ConfigurationKeyValuePathLevel)14 Test (org.junit.jupiter.api.Test)9 MaybeConfiguration (alfio.manager.system.ConfigurationManager.MaybeConfiguration)7 ConfigurationManager (alfio.manager.system.ConfigurationManager)6 BeforeEach (org.junit.jupiter.api.BeforeEach)3 CheckInStatistics (alfio.manager.support.CheckInStatistics)2 ConfigurationLevel (alfio.manager.system.ConfigurationLevel)2 EventAndOrganizationId (alfio.model.EventAndOrganizationId)2 Organization (alfio.model.user.Organization)2 MessageSourceManager (alfio.manager.i18n.MessageSourceManager)1 AdminOpenIdAuthenticationManager (alfio.manager.openid.AdminOpenIdAuthenticationManager)1 PaymentResult (alfio.manager.support.PaymentResult)1 TemplateGenerator (alfio.manager.support.TemplateGenerator)1 Ticket (alfio.model.Ticket)1 WaitingQueueSubscription (alfio.model.WaitingQueueSubscription)1 TicketReservationWithOptionalCodeModification (alfio.model.modification.TicketReservationWithOptionalCodeModification)1 StripeCreditCardToken (alfio.model.transaction.token.StripeCreditCardToken)1 OrganizationRepository (alfio.repository.user.OrganizationRepository)1 UserRepository (alfio.repository.user.UserRepository)1 Json (alfio.util.Json)1