Search in sources :

Example 1 with Environment

use of br.com.caelum.vraptor.environment.Environment in project mamute by caelum.

the class ScriptSessionCreator method buildEnv.

private Environment buildEnv() {
    Environment env;
    try {
        String envName = System.getenv("DATAIMPORT_ENV");
        if (isNullOrEmpty(envName)) {
            envName = firstNonNull(System.getProperty(ENVIRONMENT_PROPERTY), "development");
        }
        env = new DefaultEnvironment(new EnvironmentType(envName));
        LOG.info("using env '" + envName + "' for script session creator");
        return env;
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : DefaultEnvironment(br.com.caelum.vraptor.environment.DefaultEnvironment) EnvironmentType(br.com.caelum.vraptor.environment.EnvironmentType) DefaultEnvironment(br.com.caelum.vraptor.environment.DefaultEnvironment) Environment(br.com.caelum.vraptor.environment.Environment) IOException(java.io.IOException)

Example 2 with Environment

use of br.com.caelum.vraptor.environment.Environment in project mamute by caelum.

the class TagsValidatorTest method setup.

@Before
public void setup() {
    environment = mock(Environment.class);
    when(environment.get("tags.sanitizer.regex")).thenReturn("[a-zA-Z0-9-]");
    messageFactory = new MessageFactory(bundle);
    validator = new MockValidator();
    tagsValidator = new TagsValidator(environment, validator, messageFactory);
    User user = user("any", "any@brutal.com");
    java = new Tag("java", "", user);
    ruby = new Tag("ruby", "", user);
    rails = new Tag("rails", "", user);
    nonalpha = new Tag("java,mysql", "", user);
}
Also used : User(org.mamute.model.User) MessageFactory(org.mamute.factory.MessageFactory) MockValidator(br.com.caelum.vraptor.util.test.MockValidator) Environment(br.com.caelum.vraptor.environment.Environment) Tag(org.mamute.model.Tag) Before(org.junit.Before)

Example 3 with Environment

use of br.com.caelum.vraptor.environment.Environment in project mamute by caelum.

the class QuestionIndexProviderTest method should_build_solr_question_index.

@Test
public void should_build_solr_question_index() throws Exception {
    Environment env = mock(Environment.class);
    when(env.get(eq("feature.solr"), anyString())).thenReturn("true");
    Instance<SolrServer> instance = mock(Instance.class);
    Iterator<SolrServer> iterator = mock(Iterator.class);
    when(instance.iterator()).thenReturn(iterator);
    QuestionIndexProvider provider = new QuestionIndexProvider(env, instance);
    QuestionIndex build = provider.build();
    assertTrue(SolrQuestionIndex.class.isInstance(build));
}
Also used : Environment(br.com.caelum.vraptor.environment.Environment) SolrServer(org.apache.solr.client.solrj.SolrServer) Test(org.junit.Test)

Example 4 with Environment

use of br.com.caelum.vraptor.environment.Environment in project mamute by caelum.

the class QuestionIndexProviderTest method should_build_null_question_index.

@Test
public void should_build_null_question_index() throws Exception {
    Environment env = mock(Environment.class);
    when(env.get(eq("feature.solr"), anyString())).thenReturn("false");
    Instance<SolrServer> instance = mock(Instance.class);
    QuestionIndexProvider provider = new QuestionIndexProvider(env, instance);
    QuestionIndex build = provider.build();
    assertTrue(NullQuestionIndex.class.isInstance(build));
}
Also used : Environment(br.com.caelum.vraptor.environment.Environment) SolrServer(org.apache.solr.client.solrj.SolrServer) Test(org.junit.Test)

Aggregations

Environment (br.com.caelum.vraptor.environment.Environment)4 SolrServer (org.apache.solr.client.solrj.SolrServer)2 Test (org.junit.Test)2 DefaultEnvironment (br.com.caelum.vraptor.environment.DefaultEnvironment)1 EnvironmentType (br.com.caelum.vraptor.environment.EnvironmentType)1 MockValidator (br.com.caelum.vraptor.util.test.MockValidator)1 IOException (java.io.IOException)1 Before (org.junit.Before)1 MessageFactory (org.mamute.factory.MessageFactory)1 Tag (org.mamute.model.Tag)1 User (org.mamute.model.User)1