@@ -0,0 +1,2957 @@
+package com.github.gabrielruiu.spring.cloud.config.redis;%0A%0Aimport com.google.common.collect.Lists;%0Aimport com.google.common.collect.Sets;%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;%0Aimport org.springframework.beans.factory.annotation.Autowired;%0Aimport org.springframework.boot.context.embedded.LocalServerPort;%0Aimport org.springframework.boot.test.context.SpringBootTest;%0Aimport org.springframework.boot.test.mock.mockito.MockBean;%0Aimport org.springframework.boot.test.web.client.TestRestTemplate;%0Aimport org.springframework.cloud.config.environment.Environment;%0Aimport org.springframework.cloud.config.environment.PropertySource;%0Aimport org.springframework.data.redis.core.StringRedisTemplate;%0Aimport org.springframework.data.redis.core.ValueOperations;%0Aimport org.springframework.test.context.junit4.SpringRunner;%0A%0Aimport java.util.List;%0Aimport java.util.Set;%0A%0Aimport static org.hamcrest.MatcherAssert.assertThat;%0Aimport static org.hamcrest.Matchers.*;%0Aimport static org.mockito.BDDMockito.given;%0Aimport static org.mockito.Mockito.mock;%0A%0A/**%0A * @author Gabriel Mihai Ruiu (gabriel.ruiu@mail.com)%0A */%0A@RunWith(SpringRunner.class)%0A@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)%0Apublic class RedisEnvironmentRepositoryTest %7B%0A%0A    @LocalServerPort%0A    int port;%0A%0A    @MockBean%0A    StringRedisTemplate stringRedisTemplate;%0A%0A    @Autowired%0A    TestRestTemplate testRestTemplate;%0A%0A    @Test%0A    public void shouldRetrieveEnvironment() %7B%0A        String pattern = %22application:default:master:*%22;%0A        List%3CString%3E properties = Lists.newArrayList(%22http://localhost:8080/url%22, %22dd/MM/yyyy%22);%0A        Set%3CString%3E keys = Sets.newHashSet(%22application:default:master:url%22, %22application:default:master:format:date%22);%0A        ValueOperations%3CString, String%3E valueOps = mock(ValueOperations.class);%0A        given(stringRedisTemplate.keys(pattern)).willReturn(keys);%0A        given(stringRedisTemplate.opsForValue()).willReturn(valueOps);%0A        given(valueOps.multiGet(keys)).willReturn(properties);%0A        String url = String.format(%22http://localhost:%25d/application/default/master%22, port);%0A%0A        Environment env = testRestTemplate.getForObject(url, Environment.class);%0A%0A        assertThat(env, notNullValue());%0A        assertThat(env.getName(), is(%22application%22));%0A        assertThat(env.getVersion(), nullValue());%0A        assertThat(env.getProfiles(), arrayWithSize(1));%0A        assertThat(env.getLabel(), is(%22master%22));%0A        assertThat(env.getPropertySources(), hasSize(1));%0A        PropertySource propertySource = env.getPropertySources().get(0);%0A        assertThat(propertySource, notNullValue());%0A        assertThat(propertySource.getName(), is(%22application%22));%0A        assertThat(propertySource.getSource(), notNullValue());%0A        assertThat(propertySource.getSource(), hasEntry(%22format.date%22, %22dd/MM/yyyy%22));%0A        assertThat(propertySource.getSource(), hasEntry(%22url%22, %22http://localhost:8080/url%22));%0A    %7D%0A%7D%0A

Add basic integration test that checks a simple retrieval of an Environment object. Several other tests will be added later