Search in sources :

Example 76 with Environment

use of org.springframework.core.env.Environment in project flow by vaadin.

the class SpringServlet method setProperty.

private void setProperty(String envProperty, String initParam, Properties properties) {
    Environment env = context.getBean(Environment.class);
    String value = env.getProperty(upperCaseToDashSeparated(envProperty));
    if (value == null) {
        value = env.getProperty(envProperty);
    }
    if (value != null) {
        properties.put(initParam, value);
    }
}
Also used : Environment(org.springframework.core.env.Environment)

Example 77 with Environment

use of org.springframework.core.env.Environment 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 78 with Environment

use of org.springframework.core.env.Environment in project dq-easy-cloud by dq-open-cloud.

the class EcAuditConditional method matches.

@Override
public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
    // 获取上下文环境
    Environment env = context.getEnvironment();
    Boolean auditSwitch = env.getProperty(EcConditionalSwitchKey.AUDIT_SWITCH, Boolean.class);
    if (auditSwitch == null) {
        return true;
    }
    return auditSwitch;
}
Also used : Environment(org.springframework.core.env.Environment)

Example 79 with Environment

use of org.springframework.core.env.Environment in project dq-easy-cloud by dq-open-cloud.

the class EcRedissonLockCondition method matches.

@Override
public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
    // 获取上下文环境
    Environment env = context.getEnvironment();
    Boolean lockSwitch = env.getProperty(EcConditionalSwitchKey.LOCK_SWITCH, Boolean.class);
    if (lockSwitch == null) {
        return true;
    }
    return lockSwitch;
}
Also used : Environment(org.springframework.core.env.Environment)

Example 80 with Environment

use of org.springframework.core.env.Environment in project data-prep by Talend.

the class NoOpQuotaServiceTest method givenQuotaProperty.

private void givenQuotaProperty(String returnValue) {
    Environment environment = mock(Environment.class);
    when(context.getEnvironment()).thenReturn(environment);
    when(environment.getProperty("dataset.quota.check.enabled")).thenReturn(returnValue);
}
Also used : Environment(org.springframework.core.env.Environment)

Aggregations

Environment (org.springframework.core.env.Environment)161 Test (org.junit.jupiter.api.Test)68 StandardEnvironment (org.springframework.core.env.StandardEnvironment)30 EnvironmentVariableUtility (com.synopsys.integration.alert.environment.EnvironmentVariableUtility)26 MockEnvironment (org.springframework.mock.env.MockEnvironment)24 SpringApplication (org.springframework.boot.SpringApplication)21 EnvironmentProcessingResult (com.synopsys.integration.alert.environment.EnvironmentProcessingResult)19 EnvironmentVariableHandler (com.synopsys.integration.alert.environment.EnvironmentVariableHandler)19 EnvironmentVariableHandlerFactory (com.synopsys.integration.alert.environment.EnvironmentVariableHandlerFactory)19 HashMap (java.util.HashMap)13 ResourceLoader (org.springframework.core.io.ResourceLoader)13 Collectors (java.util.stream.Collectors)11 ConfigurableEnvironment (org.springframework.core.env.ConfigurableEnvironment)10 AlertIntegrationTest (com.synopsys.integration.alert.util.AlertIntegrationTest)9 MutablePropertySources (org.springframework.core.env.MutablePropertySources)8 AlertConstants (com.synopsys.integration.alert.api.common.model.AlertConstants)7 ChannelKeys (com.synopsys.integration.alert.descriptor.api.model.ChannelKeys)7 EnvironmentVariableMockingUtil (com.synopsys.integration.alert.test.common.EnvironmentVariableMockingUtil)7 Map (java.util.Map)7 Predicate (java.util.function.Predicate)7