diff --git a/api/pom.xml b/api/pom.xml
index cc08bb9c..5d1eb6e2 100644
--- a/api/pom.xml
+++ b/api/pom.xml
@@ -6,7 +6,7 @@
ca.bc.gov.educ
educ-grad-trax-api
- 1.8.56
+ 1.8.57
educ-grad-trax-api
Ministry of Education GRAD TRAX API
@@ -79,8 +79,10 @@
redis.clients
jedis
-
-
+
+ org.apache.commons
+ commons-pool2
+
org.apache.logging.log4j
log4j-api
diff --git a/api/src/main/java/ca/bc/gov/educ/api/trax/config/GradTraxConfig.java b/api/src/main/java/ca/bc/gov/educ/api/trax/config/GradTraxConfig.java
index 9202f87c..17733c10 100644
--- a/api/src/main/java/ca/bc/gov/educ/api/trax/config/GradTraxConfig.java
+++ b/api/src/main/java/ca/bc/gov/educ/api/trax/config/GradTraxConfig.java
@@ -18,8 +18,6 @@
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.security.oauth2.client.*;
import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository;
-import org.springframework.security.oauth2.client.web.DefaultOAuth2AuthorizedClientManager;
-import org.springframework.security.oauth2.client.web.OAuth2AuthorizedClientRepository;
import org.springframework.security.oauth2.client.web.reactive.function.client.ServletOAuth2AuthorizedClientExchangeFilterFunction;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.web.client.RestTemplate;
@@ -80,18 +78,6 @@ public WebClient getInstituteWebClient(OAuth2AuthorizedClientManager authorizedC
.apply(filter.oauth2Configuration())
.build();
}
- /*@Bean
- public OAuth2AuthorizedClientManager authorizedClientManager(
- ClientRegistrationRepository clientRegistrationRepository,
- OAuth2AuthorizedClientRepository authorizedClientRepository) {
- OAuth2AuthorizedClientProvider authorizedClientProvider = OAuth2AuthorizedClientProviderBuilder.builder()
- .clientCredentials()
- .build();
- DefaultOAuth2AuthorizedClientManager authorizedClientManager = new DefaultOAuth2AuthorizedClientManager(
- clientRegistrationRepository, authorizedClientRepository);
- authorizedClientManager.setAuthorizedClientProvider(authorizedClientProvider);
- return authorizedClientManager;
- }*/
@Bean
public OAuth2AuthorizedClientManager authorizedClientManager(
diff --git a/api/src/main/java/ca/bc/gov/educ/api/trax/config/RedisConfig.java b/api/src/main/java/ca/bc/gov/educ/api/trax/config/RedisConfig.java
index e031932c..d41c9438 100644
--- a/api/src/main/java/ca/bc/gov/educ/api/trax/config/RedisConfig.java
+++ b/api/src/main/java/ca/bc/gov/educ/api/trax/config/RedisConfig.java
@@ -1,55 +1,55 @@
package ca.bc.gov.educ.api.trax.config;
import ca.bc.gov.educ.api.trax.util.EducGradTraxApiConstants;
+import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisClusterConfiguration;
import org.springframework.data.redis.connection.RedisClusterNode;
-import org.springframework.data.redis.connection.RedisNode;
-import org.springframework.data.redis.connection.RedisStandaloneConfiguration;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
-import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.repository.configuration.EnableRedisRepositories;
-import org.springframework.data.redis.serializer.GenericToStringSerializer;
-import org.springframework.data.redis.serializer.JdkSerializationRedisSerializer;
-import org.springframework.data.redis.serializer.StringRedisSerializer;
-import redis.clients.jedis.Jedis;
+import redis.clients.jedis.HostAndPort;
+import redis.clients.jedis.JedisCluster;
+
+import java.time.Duration;
+import java.util.HashSet;
+import java.util.Set;
@Configuration
@EnableRedisRepositories("ca.bc.gov.educ.api.trax.repository.redis")
public class RedisConfig {
@Autowired
private EducGradTraxApiConstants constants;
+
@Bean
public JedisConnectionFactory jedisConnectionFactory() {
- RedisStandaloneConfiguration redisStandaloneConfiguration = new RedisStandaloneConfiguration();
- redisStandaloneConfiguration.setHostName(constants.getRedisUrl());
- redisStandaloneConfiguration.setPort(Integer.parseInt(constants.getRedisPort()));
- redisStandaloneConfiguration.setPassword(constants.getRedisSecret());
-
- //Cluster Configuration
RedisClusterConfiguration redisClusterConfiguration = new RedisClusterConfiguration();
- RedisNode node0 = new RedisNode(constants.getRedisUrl(), Integer.parseInt(constants.getRedisPort()));
- redisClusterConfiguration.addClusterNode(node0);
-
- RedisClusterNode rcn = new RedisClusterNode(constants.getRedisUrl(), Integer.parseInt(constants.getRedisPort()));
-
- return new JedisConnectionFactory(redisStandaloneConfiguration);
+ redisClusterConfiguration.addClusterNode(new RedisClusterNode(
+ constants.getRedisUrl(),
+ Integer.parseInt(constants.getRedisPort())));
+ redisClusterConfiguration.setPassword(constants.getRedisSecret());
+ return new JedisConnectionFactory(redisClusterConfiguration);
}
@Bean
- public RedisTemplate redisTemplate() {
- final RedisTemplate template = new RedisTemplate<>();
- template.setConnectionFactory(jedisConnectionFactory());
- template.setKeySerializer(new StringRedisSerializer());
- template.setValueSerializer(new GenericToStringSerializer<>(Object.class));
- template.setHashKeySerializer(new JdkSerializationRedisSerializer());
- template.setHashValueSerializer(new JdkSerializationRedisSerializer());
- template.setEnableTransactionSupport(true);
- template.afterPropertiesSet();
-
- return template;
+ public JedisCluster jedisCluster() {
+ Set jedisClusterNodes = new HashSet<>();
+ jedisClusterNodes.add(
+ new HostAndPort(constants.getRedisUrl(),
+ Integer.parseInt(constants.getRedisPort())));
+
+ GenericObjectPoolConfig poolConfig = new GenericObjectPoolConfig();
+ poolConfig.setMaxTotal(8);
+ poolConfig.setMaxIdle(8);
+ poolConfig.setMinIdle(0);
+ poolConfig.setBlockWhenExhausted(true);
+ poolConfig.setMaxWait(Duration.ofSeconds(1));
+ poolConfig.setTestWhileIdle(true);
+ poolConfig.setTimeBetweenEvictionRuns(Duration.ofSeconds(1));
+
+ return new JedisCluster(jedisClusterNodes, 5000, 5000, 3,
+ constants.getRedisUser(), constants.getRedisSecret(),
+ "educ-grad-trax-api", poolConfig);
}
-
}
diff --git a/api/src/main/java/ca/bc/gov/educ/api/trax/service/EventCommonService.java b/api/src/main/java/ca/bc/gov/educ/api/trax/service/EventCommonService.java
index d07b18ee..bfb40695 100644
--- a/api/src/main/java/ca/bc/gov/educ/api/trax/service/EventCommonService.java
+++ b/api/src/main/java/ca/bc/gov/educ/api/trax/service/EventCommonService.java
@@ -281,7 +281,7 @@ private void checkAndPopulateTraxStudentStatus(TraxStudentEntity traxStudentEnti
newArchiveFlag = "I";
} else if (StringUtils.equals(gradStudentStatus, "TER")) {
newStudStatus = "T";
- newArchiveFlag = "I";
+ newArchiveFlag = "A";
}
if (!StringUtils.equalsIgnoreCase(studStatus, newStudStatus)) {
diff --git a/api/src/main/java/ca/bc/gov/educ/api/trax/service/institute/ServiceHelper.java b/api/src/main/java/ca/bc/gov/educ/api/trax/service/institute/ServiceHelper.java
index 72aa7196..7b5a1726 100644
--- a/api/src/main/java/ca/bc/gov/educ/api/trax/service/institute/ServiceHelper.java
+++ b/api/src/main/java/ca/bc/gov/educ/api/trax/service/institute/ServiceHelper.java
@@ -4,18 +4,18 @@
import ca.bc.gov.educ.api.trax.constant.CacheStatus;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
+import redis.clients.jedis.JedisCluster;
@Slf4j
@Component
public class ServiceHelper {
@Autowired
- RedisTemplate redisTemplate;
+ JedisCluster jedisCluster;
public void initializeCache(boolean force, CacheKey cacheKey, T service) {
- String cacheStatus = redisTemplate.opsForValue().get(cacheKey.name());
+ String cacheStatus = jedisCluster.get(cacheKey.name());
cacheStatus = cacheStatus == null ? "" : cacheStatus;
if (CacheStatus.LOADING.name().compareToIgnoreCase(cacheStatus) == 0
|| CacheStatus.READY.name().compareToIgnoreCase(cacheStatus) == 0) {
@@ -33,9 +33,9 @@ public void initializeCache(boolean force, CacheKey cacheKey, T service) {
}
private void loadCache(CacheKey cacheKey, T service) {
- redisTemplate.opsForValue().set(cacheKey.name(), CacheStatus.LOADING.name());
+ jedisCluster.set(cacheKey.name(), CacheStatus.LOADING.name());
loadDataIntoRedisCache(cacheKey, service);
- redisTemplate.opsForValue().set(cacheKey.name(), CacheStatus.READY.name());
+ jedisCluster.set(cacheKey.name(), CacheStatus.READY.name());
log.info(String.format("Success! - %s is now READY", cacheKey));
}
diff --git a/api/src/main/java/ca/bc/gov/educ/api/trax/util/EducGradTraxApiConstants.java b/api/src/main/java/ca/bc/gov/educ/api/trax/util/EducGradTraxApiConstants.java
index a4ad024f..7b78fcee 100644
--- a/api/src/main/java/ca/bc/gov/educ/api/trax/util/EducGradTraxApiConstants.java
+++ b/api/src/main/java/ca/bc/gov/educ/api/trax/util/EducGradTraxApiConstants.java
@@ -138,6 +138,9 @@ public class EducGradTraxApiConstants {
@Value("${redis.port}")
private String redisPort;
+ @Value("${redis.user}")
+ private String redisUser;
+
@Value("${redis.secret}")
private String redisSecret;
diff --git a/api/src/main/resources/application.yaml b/api/src/main/resources/application.yaml
index 4ba48ea2..0565b42f 100644
--- a/api/src/main/resources/application.yaml
+++ b/api/src/main/resources/application.yaml
@@ -134,6 +134,7 @@ nats:
redis:
url: ${REDIS_URL}
port: ${REDIS_PORT}
+ user: ${REDIS_USER}
secret: ${REDIS_SECRET}
#Scheduler
diff --git a/api/src/main/resources/db/migration/1.0/V1.0.28__DDL-CREATE_TABLE-EVENT_HISTORY.sql b/api/src/main/resources/db/migration/1.0/V1.0.28__DDL-CREATE_TABLE-EVENT_HISTORY.sql
new file mode 100644
index 00000000..de8e7a73
--- /dev/null
+++ b/api/src/main/resources/db/migration/1.0/V1.0.28__DDL-CREATE_TABLE-EVENT_HISTORY.sql
@@ -0,0 +1,14 @@
+CREATE TABLE "EVENT_HISTORY"
+( "EVENT_HISTORY_ID" RAW(16) DEFAULT SYS_GUID() NOT NULL ENABLE,
+ "EVENT_ID" RAW(16) NOT NULL ENABLE,
+ "ACKNOWLEDGE_FLAG" VARCHAR2(1) NOT NULL ENABLE,
+ "CREATE_USER" VARCHAR2(32) DEFAULT USER NOT NULL ENABLE,
+ "CREATE_DATE" DATE DEFAULT SYSTIMESTAMP NOT NULL ENABLE,
+ "UPDATE_USER" VARCHAR2(32) DEFAULT USER NOT NULL ENABLE,
+ "UPDATE_DATE" DATE DEFAULT SYSTIMESTAMP NOT NULL ENABLE,
+
+ CONSTRAINT "EVENT_HISTORY_ID_PK" PRIMARY KEY ("EVENT_HISTORY_ID")
+ USING INDEX TABLESPACE "API_GRAD_IDX" ENABLE
+) SEGMENT CREATION IMMEDIATE
+ NOCOMPRESS LOGGING
+ TABLESPACE "API_GRAD_DATA" NO INMEMORY ;
\ No newline at end of file
diff --git a/api/src/test/java/ca/bc/gov/educ/api/trax/service/BaseReplicationServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/trax/service/BaseReplicationServiceTest.java
index 24dbd242..8ae57049 100644
--- a/api/src/test/java/ca/bc/gov/educ/api/trax/service/BaseReplicationServiceTest.java
+++ b/api/src/test/java/ca/bc/gov/educ/api/trax/service/BaseReplicationServiceTest.java
@@ -11,11 +11,13 @@
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
+import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository;
import org.springframework.security.oauth2.client.web.OAuth2AuthorizedClientRepository;
import org.springframework.security.oauth2.client.OAuth2AuthorizedClientService;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
+import redis.clients.jedis.JedisCluster;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = {EducGradTraxApiApplication.class})
@@ -42,6 +44,10 @@ public abstract class BaseReplicationServiceTest {
public OAuth2AuthorizedClientRepository oAuth2AuthorizedClientRepository;
@MockBean
public OAuth2AuthorizedClientService oAuth2AuthorizedClientService;
+ @MockBean
+ private JedisConnectionFactory jedisConnectionFactoryMock;
+ @MockBean
+ private JedisCluster jedisClusterMock;
@Before
public void resetState() {
diff --git a/api/src/test/java/ca/bc/gov/educ/api/trax/service/ChoreographedEventPersistenceServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/trax/service/ChoreographedEventPersistenceServiceTest.java
index daa9ff92..a64b83cc 100644
--- a/api/src/test/java/ca/bc/gov/educ/api/trax/service/ChoreographedEventPersistenceServiceTest.java
+++ b/api/src/test/java/ca/bc/gov/educ/api/trax/service/ChoreographedEventPersistenceServiceTest.java
@@ -19,10 +19,12 @@
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.annotation.Bean;
+import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.security.oauth2.client.registration.ClientRegistration;
import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
+import redis.clients.jedis.JedisCluster;
import java.util.Optional;
import java.util.UUID;
@@ -53,6 +55,11 @@ public class ChoreographedEventPersistenceServiceTest {
@MockBean
private Subscriber subscriber;
+ @MockBean
+ private JedisConnectionFactory jedisConnectionFactory;
+ @MockBean
+ private JedisCluster jedisClusterMock;
+
@TestConfiguration
static class TestConfig {
diff --git a/api/src/test/java/ca/bc/gov/educ/api/trax/service/CodeServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/trax/service/CodeServiceTest.java
index 0ce5e3a6..6252e90a 100644
--- a/api/src/test/java/ca/bc/gov/educ/api/trax/service/CodeServiceTest.java
+++ b/api/src/test/java/ca/bc/gov/educ/api/trax/service/CodeServiceTest.java
@@ -19,10 +19,12 @@
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.annotation.Bean;
+import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.security.oauth2.client.registration.ClientRegistration;
import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
+import redis.clients.jedis.JedisCluster;
import java.util.ArrayList;
import java.util.List;
@@ -58,6 +60,10 @@ public class CodeServiceTest {
@MockBean
private Subscriber subscriber;
+ @MockBean
+ private JedisConnectionFactory jedisConnectionFactoryMock;
+ @MockBean
+ private JedisCluster jedisClusterMock;
@TestConfiguration
static class TestConfig {
diff --git a/api/src/test/java/ca/bc/gov/educ/api/trax/service/DistrictServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/trax/service/DistrictServiceTest.java
index e78077b4..b75a811a 100644
--- a/api/src/test/java/ca/bc/gov/educ/api/trax/service/DistrictServiceTest.java
+++ b/api/src/test/java/ca/bc/gov/educ/api/trax/service/DistrictServiceTest.java
@@ -21,11 +21,13 @@
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.annotation.Bean;
+import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.security.oauth2.client.registration.ClientRegistration;
import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.web.reactive.function.client.WebClient;
+import redis.clients.jedis.JedisCluster;
import java.util.List;
import java.util.Optional;
@@ -51,6 +53,10 @@ public class DistrictServiceTest {
@Mock WebClient.RequestBodySpec requestBodyMock;
@Mock WebClient.RequestBodyUriSpec requestBodyUriMock;
@Mock WebClient.ResponseSpec responseMock;
+ @MockBean
+ private JedisConnectionFactory jedisConnectionFactoryMock;
+ @MockBean
+ private JedisCluster jedisClusterMock;
@MockBean
@Qualifier("default")
diff --git a/api/src/test/java/ca/bc/gov/educ/api/trax/service/EdwServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/trax/service/EdwServiceTest.java
index c9dc8733..6555b550 100644
--- a/api/src/test/java/ca/bc/gov/educ/api/trax/service/EdwServiceTest.java
+++ b/api/src/test/java/ca/bc/gov/educ/api/trax/service/EdwServiceTest.java
@@ -15,10 +15,12 @@
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.annotation.Bean;
+import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.security.oauth2.client.registration.ClientRegistration;
import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
+import redis.clients.jedis.JedisCluster;
import java.math.BigDecimal;
import java.util.Arrays;
@@ -51,6 +53,10 @@ public class EdwServiceTest {
@MockBean
private Subscriber subscriber;
+ @MockBean
+ private JedisConnectionFactory jedisConnectionFactoryMock;
+ @MockBean
+ private JedisCluster jedisClusterMock;
@TestConfiguration
diff --git a/api/src/test/java/ca/bc/gov/educ/api/trax/service/GradStudentGraduatedServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/trax/service/GradStudentGraduatedServiceTest.java
index 6bf5f8c7..cec4b060 100644
--- a/api/src/test/java/ca/bc/gov/educ/api/trax/service/GradStudentGraduatedServiceTest.java
+++ b/api/src/test/java/ca/bc/gov/educ/api/trax/service/GradStudentGraduatedServiceTest.java
@@ -18,10 +18,12 @@
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.annotation.Bean;
+import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.security.oauth2.client.registration.ClientRegistration;
import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
+import redis.clients.jedis.JedisCluster;
import static org.mockito.MockitoAnnotations.openMocks;
@@ -47,6 +49,10 @@ public class GradStudentGraduatedServiceTest {
@MockBean
private Subscriber subscriber;
+ @MockBean
+ private JedisConnectionFactory jedisConnectionFactoryMock;
+ @MockBean
+ private JedisCluster jedisClusterMock;
@TestConfiguration
static class TestConfig {
diff --git a/api/src/test/java/ca/bc/gov/educ/api/trax/service/GradStudentUndoCompletionServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/trax/service/GradStudentUndoCompletionServiceTest.java
index 102578ce..f4c56d8f 100644
--- a/api/src/test/java/ca/bc/gov/educ/api/trax/service/GradStudentUndoCompletionServiceTest.java
+++ b/api/src/test/java/ca/bc/gov/educ/api/trax/service/GradStudentUndoCompletionServiceTest.java
@@ -18,10 +18,12 @@
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.annotation.Bean;
+import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.security.oauth2.client.registration.ClientRegistration;
import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
+import redis.clients.jedis.JedisCluster;
import static org.mockito.MockitoAnnotations.openMocks;
@@ -47,6 +49,10 @@ public class GradStudentUndoCompletionServiceTest {
@MockBean
private Subscriber subscriber;
+ @MockBean
+ private JedisConnectionFactory jedisConnectionFactoryMock;
+ @MockBean
+ private JedisCluster jedisClusterMock;
@TestConfiguration
static class TestConfig {
diff --git a/api/src/test/java/ca/bc/gov/educ/api/trax/service/GradStudentUpdatedServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/trax/service/GradStudentUpdatedServiceTest.java
index 04fd2f95..c3d45833 100644
--- a/api/src/test/java/ca/bc/gov/educ/api/trax/service/GradStudentUpdatedServiceTest.java
+++ b/api/src/test/java/ca/bc/gov/educ/api/trax/service/GradStudentUpdatedServiceTest.java
@@ -18,10 +18,12 @@
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.annotation.Bean;
+import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.security.oauth2.client.registration.ClientRegistration;
import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
+import redis.clients.jedis.JedisCluster;
import static org.mockito.MockitoAnnotations.openMocks;
@@ -47,6 +49,10 @@ public class GradStudentUpdatedServiceTest {
@MockBean
private Subscriber subscriber;
+ @MockBean
+ private JedisConnectionFactory jedisConnectionFactoryMock;
+ @MockBean
+ private JedisCluster jedisClusterMock;
@TestConfiguration
static class TestConfig {
diff --git a/api/src/test/java/ca/bc/gov/educ/api/trax/service/PsiServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/trax/service/PsiServiceTest.java
index 62b60b0a..d4bb6035 100644
--- a/api/src/test/java/ca/bc/gov/educ/api/trax/service/PsiServiceTest.java
+++ b/api/src/test/java/ca/bc/gov/educ/api/trax/service/PsiServiceTest.java
@@ -23,10 +23,12 @@
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.annotation.Bean;
import org.springframework.data.jpa.domain.Specification;
+import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.security.oauth2.client.registration.ClientRegistration;
import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
+import redis.clients.jedis.JedisCluster;
import java.util.ArrayList;
import java.util.List;
@@ -64,6 +66,10 @@ public class PsiServiceTest {
@MockBean
private Subscriber subscriber;
+ @MockBean
+ private JedisConnectionFactory jedisConnectionFactoryMock;
+ @MockBean
+ private JedisCluster jedisClusterMock;
@TestConfiguration
static class TestConfig {
diff --git a/api/src/test/java/ca/bc/gov/educ/api/trax/service/SchoolServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/trax/service/SchoolServiceTest.java
index 4892a7c1..49408079 100644
--- a/api/src/test/java/ca/bc/gov/educ/api/trax/service/SchoolServiceTest.java
+++ b/api/src/test/java/ca/bc/gov/educ/api/trax/service/SchoolServiceTest.java
@@ -26,11 +26,13 @@
import org.springframework.context.annotation.Bean;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.data.jpa.domain.Specification;
+import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.security.oauth2.client.registration.ClientRegistration;
import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Mono;
+import redis.clients.jedis.JedisCluster;
import java.util.ArrayList;
import java.util.List;
@@ -76,6 +78,10 @@ class SchoolServiceTest {
@MockBean
private CommonSchoolCache commonSchoolCache;
+ @MockBean
+ private JedisConnectionFactory jedisConnectionFactoryMock;
+ @MockBean
+ private JedisCluster jedisClusterMock;
@TestConfiguration
static class TestConfig {
diff --git a/api/src/test/java/ca/bc/gov/educ/api/trax/service/TraxCommonServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/trax/service/TraxCommonServiceTest.java
index e8c32fe1..dc82677d 100644
--- a/api/src/test/java/ca/bc/gov/educ/api/trax/service/TraxCommonServiceTest.java
+++ b/api/src/test/java/ca/bc/gov/educ/api/trax/service/TraxCommonServiceTest.java
@@ -20,10 +20,12 @@
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.annotation.Bean;
import org.springframework.data.domain.*;
+import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.security.oauth2.client.registration.ClientRegistration;
import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
+import redis.clients.jedis.JedisCluster;
import java.math.BigDecimal;
import java.util.*;
@@ -67,6 +69,10 @@ public class TraxCommonServiceTest {
@MockBean
private Subscriber subscriber;
+ @MockBean
+ private JedisConnectionFactory jedisConnectionFactoryMock;
+ @MockBean
+ private JedisCluster jedisClusterMock;
@TestConfiguration
static class TestConfig {
diff --git a/api/src/test/java/ca/bc/gov/educ/api/trax/service/TraxUpdateServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/trax/service/TraxUpdateServiceTest.java
index a124dd1d..513ea66a 100644
--- a/api/src/test/java/ca/bc/gov/educ/api/trax/service/TraxUpdateServiceTest.java
+++ b/api/src/test/java/ca/bc/gov/educ/api/trax/service/TraxUpdateServiceTest.java
@@ -25,10 +25,12 @@
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.annotation.Bean;
+import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.security.oauth2.client.registration.ClientRegistration;
import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
+import redis.clients.jedis.JedisCluster;
import java.math.BigDecimal;
import java.time.LocalDateTime;
@@ -79,6 +81,10 @@ public class TraxUpdateServiceTest {
@MockBean
private Subscriber subscriber;
+ @MockBean
+ private JedisConnectionFactory jedisConnectionFactoryMock;
+ @MockBean
+ private JedisCluster jedisClusterMock;
@TestConfiguration
static class TestConfig {
diff --git a/api/src/test/java/ca/bc/gov/educ/api/trax/service/institute/InstituteCodeServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/trax/service/institute/InstituteCodeServiceTest.java
index bb08b8eb..63f0ac50 100644
--- a/api/src/test/java/ca/bc/gov/educ/api/trax/service/institute/InstituteCodeServiceTest.java
+++ b/api/src/test/java/ca/bc/gov/educ/api/trax/service/institute/InstituteCodeServiceTest.java
@@ -6,6 +6,7 @@
import ca.bc.gov.educ.api.trax.messaging.jetstream.Publisher;
import ca.bc.gov.educ.api.trax.messaging.jetstream.Subscriber;
import ca.bc.gov.educ.api.trax.model.dto.ResponseObj;
+import ca.bc.gov.educ.api.trax.model.dto.institute.District;
import ca.bc.gov.educ.api.trax.model.dto.institute.SchoolCategoryCode;
import ca.bc.gov.educ.api.trax.model.dto.institute.SchoolFundingGroupCode;
import ca.bc.gov.educ.api.trax.model.entity.institute.SchoolCategoryCodeEntity;
@@ -29,8 +30,7 @@
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.annotation.Bean;
import org.springframework.core.ParameterizedTypeReference;
-import org.springframework.data.redis.core.RedisTemplate;
-import org.springframework.data.redis.core.ValueOperations;
+import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.http.HttpHeaders;
import org.springframework.security.oauth2.client.registration.ClientRegistration;
import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository;
@@ -38,6 +38,7 @@
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Mono;
+import redis.clients.jedis.JedisCluster;
import java.util.ArrayList;
import java.util.Arrays;
@@ -45,7 +46,6 @@
import java.util.function.Consumer;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
-import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.*;
@@ -69,14 +69,14 @@ public class InstituteCodeServiceTest {
private GradCountryRepository gradCountryRepository;
@MockBean
private GradProvinceRepository gradProvinceRepository;
+ @MockBean
+ private JedisConnectionFactory jedisConnectionFactoryMock;
+ @MockBean
+ private JedisCluster jedisClusterMock;
@MockBean
@Qualifier("default")
WebClient webClientMock;
- @MockBean
- RedisTemplate redisTemplateMock;
- @Mock
- ValueOperations valueOperationsMock;
@Mock
private WebClient.RequestHeadersSpec requestHeadersSpecMock;
@Mock
@@ -226,21 +226,19 @@ public void whenGetSchoolCategoryCodesFromRedisCache_GetSchoolCategoryCodes() {
@Test
public void whenInitializeSchoolCategoryCodeCache_WithLoadingAndFalse_DoNotForceLoad() {
- when(redisTemplateMock.opsForValue())
- .thenReturn(valueOperationsMock);
- when(valueOperationsMock.get(CacheKey.SCHOOL_CATEGORY_CODE_CACHE.name()))
+ when(jedisClusterMock.get(CacheKey.SCHOOL_CATEGORY_CODE_CACHE.name()))
.thenReturn(String.valueOf(CacheStatus.LOADING));
- doNothing().when(valueOperationsMock).set(CacheKey.SCHOOL_CATEGORY_CODE_CACHE.name(), CacheStatus.LOADING.name());
+ when(jedisClusterMock.set(CacheKey.SCHOOL_CATEGORY_CODE_CACHE.name(), CacheStatus.LOADING.name()))
+ .thenReturn(anyString());
codeService.initializeSchoolCategoryCodeCache(false);
}
@Test
public void whenInitializeSchoolCategoryCodeCache_WithReadyAndFalse_DoNotForceLoad() {
- when(redisTemplateMock.opsForValue())
- .thenReturn(valueOperationsMock);
- when(valueOperationsMock.get(CacheKey.SCHOOL_CATEGORY_CODE_CACHE.name()))
+ when(jedisClusterMock.get(CacheKey.SCHOOL_CATEGORY_CODE_CACHE.name()))
.thenReturn(String.valueOf(CacheStatus.READY));
- doNothing().when(valueOperationsMock).set(CacheKey.SCHOOL_CATEGORY_CODE_CACHE.name(), CacheStatus.READY.name());
+ when(jedisClusterMock.set(CacheKey.SCHOOL_CATEGORY_CODE_CACHE.name(), CacheStatus.READY.name()))
+ .thenReturn(anyString());
codeService.initializeSchoolCategoryCodeCache(false);
}
@@ -300,11 +298,8 @@ public void whenInitializeSchoolCategoryCodeCache_WithLoadingAndTrue_ThenForceLo
when(this.responseObjectMock.getAccess_token())
.thenReturn("accessToken");
- when(redisTemplateMock.opsForValue())
- .thenReturn(valueOperationsMock);
- when(valueOperationsMock.get(CacheKey.SCHOOL_CATEGORY_CODE_CACHE.name()))
+ when(jedisClusterMock.get(CacheKey.SCHOOL_CATEGORY_CODE_CACHE.name()))
.thenReturn(String.valueOf(CacheStatus.LOADING));
- doNothing().when(valueOperationsMock).set(CacheKey.SCHOOL_CATEGORY_CODE_CACHE.name(), CacheStatus.LOADING.name());
CodeService codeServicemock = mock(CodeService.class);
when(codeServicemock.getSchoolCategoryCodesFromInstituteApi()).thenReturn(sccs);
@@ -316,11 +311,10 @@ public void whenInitializeSchoolCategoryCodeCache_WithLoadingAndTrue_ThenForceLo
@Test
public void whenInitializeSchoolCategoryCodeCache_WithReadyAndTrue_ThenForceLoad() {
- when(redisTemplateMock.opsForValue())
- .thenReturn(valueOperationsMock);
- when(valueOperationsMock.get(CacheKey.SCHOOL_CATEGORY_CODE_CACHE.name()))
+ when(jedisClusterMock.get(CacheKey.SCHOOL_CATEGORY_CODE_CACHE.name()))
.thenReturn(String.valueOf(CacheStatus.READY));
- doNothing().when(valueOperationsMock).set(CacheKey.SCHOOL_CATEGORY_CODE_CACHE.name(), CacheStatus.READY.name());
+ when(jedisClusterMock.set(CacheKey.SCHOOL_CATEGORY_CODE_CACHE.name(), CacheStatus.READY.name()))
+ .thenReturn(anyString());
codeService.initializeSchoolCategoryCodeCache(true);
}
@@ -341,21 +335,19 @@ public void whenGetSchoolFundingGroupCodesFromRedisCache_GetSchoolFundingGroupCo
@Test
public void whenInitializeSchoolFundingGroupCodeCache_WithLoadingAndFalse_DoNotForceLoad() {
- when(redisTemplateMock.opsForValue())
- .thenReturn(valueOperationsMock);
- when(valueOperationsMock.get(CacheKey.SCHOOL_FUNDING_GROUP_CODE_CACHE.name()))
+ when(jedisClusterMock.get(CacheKey.SCHOOL_FUNDING_GROUP_CODE_CACHE.name()))
.thenReturn(String.valueOf(CacheStatus.LOADING));
- doNothing().when(valueOperationsMock).set(CacheKey.SCHOOL_FUNDING_GROUP_CODE_CACHE.name(), CacheStatus.LOADING.name());
+ when(jedisClusterMock.set(CacheKey.SCHOOL_FUNDING_GROUP_CODE_CACHE.name(), CacheStatus.LOADING.name()))
+ .thenReturn(anyString());
codeService.initializeSchoolFundingGroupCodeCache(false);
}
@Test
public void whenInitializeSchoolFundingGroupCodeCache_WithReadyAndFalse_DoNotForceLoad() {
- when(redisTemplateMock.opsForValue())
- .thenReturn(valueOperationsMock);
- when(valueOperationsMock.get(CacheKey.SCHOOL_FUNDING_GROUP_CODE_CACHE.name()))
+ when(jedisClusterMock.get(CacheKey.SCHOOL_FUNDING_GROUP_CODE_CACHE.name()))
.thenReturn(String.valueOf(CacheStatus.READY));
- doNothing().when(valueOperationsMock).set(CacheKey.SCHOOL_FUNDING_GROUP_CODE_CACHE.name(), CacheStatus.READY.name());
+ when(jedisClusterMock.set(CacheKey.SCHOOL_FUNDING_GROUP_CODE_CACHE.name(), CacheStatus.READY.name()))
+ .thenReturn(anyString());
codeService.initializeSchoolFundingGroupCodeCache(false);
}
@@ -413,11 +405,8 @@ public void whenInitializeSchoolFundingGroupCodeCache_WithLoadingAndTrue_ThenFor
when(this.responseObjectMock.getAccess_token())
.thenReturn("accessToken");
- when(redisTemplateMock.opsForValue())
- .thenReturn(valueOperationsMock);
- when(valueOperationsMock.get(CacheKey.SCHOOL_CATEGORY_CODE_CACHE.name()))
+ when(jedisClusterMock.get(CacheKey.SCHOOL_CATEGORY_CODE_CACHE.name()))
.thenReturn(String.valueOf(CacheStatus.LOADING));
- doNothing().when(valueOperationsMock).set(CacheKey.SCHOOL_CATEGORY_CODE_CACHE.name(), CacheStatus.LOADING.name());
CodeService codeServicemock = mock(CodeService.class);
when(codeServicemock.getSchoolFundingGroupCodesFromInstituteApi()).thenReturn(sfgcs);
@@ -425,15 +414,34 @@ public void whenInitializeSchoolFundingGroupCodeCache_WithLoadingAndTrue_ThenFor
codeService.initializeSchoolFundingGroupCodeCache(true);
//verify(codeServicemock).loadSchoolCategoryCodesIntoRedisCache(sccs);
+
}
@Test
public void whenInitializeSchoolFundingGroupCodeCache_WithReadyAndTrue_ThenForceLoad() {
- when(redisTemplateMock.opsForValue())
- .thenReturn(valueOperationsMock);
- when(valueOperationsMock.get(CacheKey.SCHOOL_FUNDING_GROUP_CODE_CACHE.name()))
+
+ SchoolFundingGroupCode sfgc = new SchoolFundingGroupCode();
+ List sfgcs = new ArrayList();
+ sfgc.setSchoolFundingGroupCode("SCC1");
+ sfgc.setLabel("SCC1-label");
+ sfgc.setDescription("Desc");
+ sfgc.setDisplayOrder("10");
+ sfgc.setEffectiveDate("01-01-2024");
+ sfgc.setExpiryDate("01-01-2024");
+ sfgcs.add(sfgc);
+ sfgc = new SchoolFundingGroupCode();
+ sfgc.setSchoolFundingGroupCode("SCC2");
+ sfgc.setLabel("SCC2-label");
+ sfgc.setDescription("Desc");
+ sfgc.setDisplayOrder("20");
+ sfgc.setEffectiveDate("01-01-2024");
+ sfgc.setExpiryDate("01-01-2024");
+ sfgcs.add(sfgc);
+
+ when(jedisClusterMock.get(CacheKey.SCHOOL_FUNDING_GROUP_CODE_CACHE.name()))
.thenReturn(String.valueOf(CacheStatus.READY));
- doNothing().when(valueOperationsMock).set(CacheKey.SCHOOL_FUNDING_GROUP_CODE_CACHE.name(), CacheStatus.READY.name());
+ when(jedisClusterMock.set(CacheKey.SCHOOL_FUNDING_GROUP_CODE_CACHE.name(), CacheStatus.READY.name()))
+ .thenReturn(anyString());
codeService.initializeSchoolFundingGroupCodeCache(true);
}
}
diff --git a/api/src/test/java/ca/bc/gov/educ/api/trax/service/institute/InstituteDistrictServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/trax/service/institute/InstituteDistrictServiceTest.java
index 66b9220e..6ad328f1 100644
--- a/api/src/test/java/ca/bc/gov/educ/api/trax/service/institute/InstituteDistrictServiceTest.java
+++ b/api/src/test/java/ca/bc/gov/educ/api/trax/service/institute/InstituteDistrictServiceTest.java
@@ -7,22 +7,18 @@
import ca.bc.gov.educ.api.trax.messaging.jetstream.Subscriber;
import ca.bc.gov.educ.api.trax.model.dto.ResponseObj;
import ca.bc.gov.educ.api.trax.model.dto.institute.District;
-import ca.bc.gov.educ.api.trax.model.dto.institute.DistrictContact;
-import ca.bc.gov.educ.api.trax.model.dto.institute.SchoolCategoryCode;
import ca.bc.gov.educ.api.trax.model.entity.institute.DistrictContactEntity;
import ca.bc.gov.educ.api.trax.model.entity.institute.DistrictEntity;
-import ca.bc.gov.educ.api.trax.model.entity.institute.SchoolCategoryCodeEntity;
-import ca.bc.gov.educ.api.trax.model.entity.institute.SchoolFundingGroupCodeEntity;
import ca.bc.gov.educ.api.trax.model.transformer.institute.DistrictTransformer;
-import ca.bc.gov.educ.api.trax.repository.GradCountryRepository;
-import ca.bc.gov.educ.api.trax.repository.GradProvinceRepository;
import ca.bc.gov.educ.api.trax.repository.redis.DistrictRedisRepository;
import ca.bc.gov.educ.api.trax.util.EducGradTraxApiConstants;
import ca.bc.gov.educ.api.trax.util.RestUtils;
+import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
import org.junit.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.runner.RunWith;
import org.mockito.Mock;
+import org.mockito.exceptions.base.MockitoException;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
@@ -31,7 +27,8 @@
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.annotation.Bean;
import org.springframework.core.ParameterizedTypeReference;
-import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.data.redis.connection.RedisClusterConfiguration;
+import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.http.HttpHeaders;
import org.springframework.security.oauth2.client.registration.ClientRegistration;
@@ -40,13 +37,14 @@
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Mono;
+import redis.clients.jedis.JedisCluster;
+import java.time.Duration;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.function.Consumer;
-import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
@@ -67,14 +65,14 @@ public class InstituteDistrictServiceTest {
private DistrictService districtService;
@MockBean
private DistrictRedisRepository districtRedisRepository;
+ @MockBean
+ private JedisConnectionFactory jedisConnectionFactoryMock;
+ @MockBean
+ private JedisCluster jedisClusterMock;
@MockBean
@Qualifier("default")
WebClient webClientMock;
- @MockBean
- RedisTemplate redisTemplateMock;
- @Mock
- ValueOperations valueOperationsMock;
@Mock
private WebClient.RequestHeadersSpec requestHeadersSpecMock;
@Mock
@@ -160,21 +158,17 @@ public void whenLoadDistrictsIntoRedisCache_DoesNotThrow() {
@Test
public void whenInitializeDistrictCache_WithLoadingAndFalse_DoNotForceLoad() {
- when(redisTemplateMock.opsForValue())
- .thenReturn(valueOperationsMock);
- when(valueOperationsMock.get(CacheKey.DISTRICT_CACHE.name()))
+ when(jedisClusterMock.get(CacheKey.DISTRICT_CACHE.name()))
.thenReturn(String.valueOf(CacheStatus.LOADING));
- doNothing().when(valueOperationsMock).set(CacheKey.DISTRICT_CACHE.name(), CacheStatus.LOADING.name());
+ doThrow(new MockitoException("")).when(jedisClusterMock).set(CacheKey.DISTRICT_CACHE.name(), CacheStatus.LOADING.name());
districtService.initializeDistrictCache(false);
}
@Test
public void whenInitializeDistrictCache_WithReadyAndFalse_DoNotForceLoad() {
- when(redisTemplateMock.opsForValue())
- .thenReturn(valueOperationsMock);
- when(valueOperationsMock.get(CacheKey.DISTRICT_CACHE.name()))
+ when(jedisClusterMock.get(CacheKey.DISTRICT_CACHE.name()))
.thenReturn(String.valueOf(CacheStatus.READY));
- doNothing().when(valueOperationsMock).set(CacheKey.DISTRICT_CACHE.name(), CacheStatus.READY.name());
+ doThrow(new MockitoException("")).when(jedisClusterMock).set(CacheKey.DISTRICT_CACHE.name(), CacheStatus.READY.name());
districtService.initializeDistrictCache(false);
}
@@ -224,11 +218,9 @@ public void whenInitializeDistrictCache_WithLoadingAndTrue_ThenForceLoad() {
when(this.responseObjectMock.getAccess_token())
.thenReturn("accessToken");
- when(redisTemplateMock.opsForValue())
- .thenReturn(valueOperationsMock);
- when(valueOperationsMock.get(CacheKey.DISTRICT_CACHE.name()))
+ when(jedisClusterMock.get(CacheKey.DISTRICT_CACHE.name()))
.thenReturn(String.valueOf(CacheStatus.LOADING));
- doNothing().when(valueOperationsMock).set(CacheKey.DISTRICT_CACHE.name(), CacheStatus.LOADING.name());
+
DistrictService districtServiceMock = mock(DistrictService.class);
when(districtServiceMock.getDistrictsFromInstituteApi()).thenReturn(ds);
@@ -240,11 +232,21 @@ public void whenInitializeDistrictCache_WithLoadingAndTrue_ThenForceLoad() {
@Test
public void whenInitializeDistrictCache_WithReadyAndTrue_ThenForceLoad() {
- when(redisTemplateMock.opsForValue())
- .thenReturn(valueOperationsMock);
- when(valueOperationsMock.get(CacheKey.DISTRICT_CACHE.name()))
+
+ District d = new District();
+ List ds = new ArrayList();
+ d.setDistrictId("123");
+ d.setDistrictNumber("456");
+ ds.add(d);
+ d = new District();
+ d.setDistrictId("789");
+ d.setDistrictNumber("012");
+ ds.add(d);
+
+ when(jedisClusterMock.get(CacheKey.DISTRICT_CACHE.name()))
.thenReturn(String.valueOf(CacheStatus.READY));
- doNothing().when(valueOperationsMock).set(CacheKey.DISTRICT_CACHE.name(), CacheStatus.READY.name());
+ when(jedisClusterMock.set(CacheKey.DISTRICT_CACHE.name(), CacheStatus.READY.name()))
+ .thenReturn(anyString());
districtService.initializeDistrictCache(true);
}
}
diff --git a/api/src/test/java/ca/bc/gov/educ/api/trax/service/institute/InstituteSchoolServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/trax/service/institute/InstituteSchoolServiceTest.java
index d1a253b8..ed7f10d1 100644
--- a/api/src/test/java/ca/bc/gov/educ/api/trax/service/institute/InstituteSchoolServiceTest.java
+++ b/api/src/test/java/ca/bc/gov/educ/api/trax/service/institute/InstituteSchoolServiceTest.java
@@ -28,6 +28,7 @@
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.annotation.Bean;
import org.springframework.core.ParameterizedTypeReference;
+import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.http.HttpHeaders;
import org.springframework.security.oauth2.client.registration.ClientRegistration;
import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository;
@@ -35,6 +36,7 @@
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Mono;
+import redis.clients.jedis.JedisCluster;
import java.util.ArrayList;
import java.util.Arrays;
@@ -61,6 +63,10 @@ public class InstituteSchoolServiceTest {
@MockBean
private SchoolRedisRepository schoolRedisRepository;
@MockBean
+ private JedisConnectionFactory jedisConnectionFactoryMock;
+ @MockBean
+ private JedisCluster jedisClusterMock;
+ @MockBean
@Qualifier("default")
WebClient webClientMock;
@Mock
diff --git a/api/src/test/java/ca/bc/gov/educ/api/trax/support/TestUtils.java b/api/src/test/java/ca/bc/gov/educ/api/trax/support/TestUtils.java
index 327d62c4..e2a7b93e 100644
--- a/api/src/test/java/ca/bc/gov/educ/api/trax/support/TestUtils.java
+++ b/api/src/test/java/ca/bc/gov/educ/api/trax/support/TestUtils.java
@@ -178,7 +178,7 @@ public static TraxStudentEntity createTraxStudent(String program, String student
traxStudent.setArchiveFlag("I");
} else if (StringUtils.equals(studentStatus, "TER")) {
traxStudent.setStudStatus("T");
- traxStudent.setArchiveFlag("I");
+ traxStudent.setArchiveFlag("A");
}
return traxStudent;
}
diff --git a/api/src/test/resources/application.yaml b/api/src/test/resources/application.yaml
index ffad5705..1e0bdd5e 100644
--- a/api/src/test/resources/application.yaml
+++ b/api/src/test/resources/application.yaml
@@ -76,6 +76,7 @@ nats:
redis:
url: '127.0.0.1'
port: '54321'
+ user: 'default'
secret: 'its-a-secret'
#Scheduler