Skip to content

Commit

Permalink
update ServiceUnitTests.java
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaede10 committed Dec 2, 2024
1 parent 6226600 commit ca0432e
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/main/java/com/datastat/dao/QueryDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ public class QueryDao {
public void init() {
esUrl = String.format("%s://%s:%s/", env.getProperty("es.scheme"), env.getProperty("es.host"), env.getProperty("es.port"));
esQueryUtils = new EsQueryUtils();
robotUsers = Arrays.asList(Objects.requireNonNull(env.getProperty("skip.robot.user")).split(","));
domain_ids = Arrays.asList(Objects.requireNonNull(env.getProperty("qa.domain.ids")).split(","));
robotUsers = Arrays.asList(Objects.requireNonNull(env.getProperty("skip.robot.user", "robot")).split(","));
domain_ids = Arrays.asList(Objects.requireNonNull(env.getProperty("qa.domain.ids", "qa.domain.ids")).split(","));
}

@SneakyThrows
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/datastat/dao/metric/MetricDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ public abstract class MetricDao {
@Autowired
EsAsyncHttpUtil esAsyncHttpUtil;

@Value("${company.query}")
@Value("${company.query:companyQuery}")
String companyQueryStr;

@Value("${user.query}")
@Value("${user.query:userQuery}")
String userQueryStr;

protected static String esUrl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,16 @@ public class OneidInterceptor implements HandlerInterceptor {
@Autowired
RedisDao redisDao;

@Value("${cookie.token.name}")
@Value("${cookie.token.name:default}")
private String cookieTokenName;

@Value("${cookie.token.domains}")
@Value("${cookie.token.domains:default}")
private String allowDomains;

@Value("${cookie.token.secures}")
@Value("${cookie.token.secures:default}")
private String cookieSecures;

@Value("${oneid.token.base.password}")
@Value("${oneid.token.base.password:default}")
private String oneidTokenBasePassword;

private static HashMap<String, Boolean> domain2secure;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/datastat/service/QueryService.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public class QueryService {
@PostConstruct
public void init() {
redisDefaultExpire = Long.parseLong(env.getProperty("redis.keyExpire", "60"));
communityList = Arrays.asList(env.getProperty("communitys").split(","));
communityList = Arrays.asList(env.getProperty("communitys", "").split(","));
}

public Boolean checkCommunity(String community) {
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/datastat/service/VersionService.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ public class VersionService {

@PostConstruct
public void init() {
esUrl = String.format("%s://%s:%s/", env.getProperty("es.scheme"), env.getProperty("es.host"), env.getProperty("es.port"));
esUrl = String.format("%s://%s:%s/", env.getProperty("es.scheme", "https"),
env.getProperty("es.host", "0.0.0.0"), env.getProperty("es.port", "9200"));
}


Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/datastat/util/EsAsyncHttpUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@

@Service
public class EsAsyncHttpUtil {
@Value("${es.user}")
@Value("${es.user:user}")
String esUser;

@Value("${es.password}")
@Value("${es.password:pwd}")
String esPassword;

static volatile AsyncHttpClient asyncHttpClient = null;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/datastat/util/RSAUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class RSAUtil implements Serializable {
@Value("${rsa.key.algorithm:RSA}")
public void setKeyAlgorithm(String keyAlgorithm) { RSAUtil.KEY_ALGORITHM = keyAlgorithm; }

@Value("${rsa.authing.algorithm}")
@Value("${rsa.authing.algorithm:RSA}")
public void setRsaAlgorithm(String rsaAlgorithm) { RSAUtil.RSA_ALGORITHM = rsaAlgorithm; }

/**
Expand Down
10 changes: 10 additions & 0 deletions src/test/java/com/datastat/ds/unit/ServiceUnitTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@
import org.mockito.MockitoAnnotations;
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 com.datastat.config.FoundryConfig;
import com.datastat.config.context.QueryConfContext;
import com.datastat.dao.FoundryDao;
import com.datastat.dao.KafkaDao;
import com.datastat.dao.ObsDao;
import com.datastat.dao.RedisDao;
import com.datastat.dao.context.QueryDaoContext;
import com.datastat.ds.common.CommonUtil;
Expand All @@ -33,6 +37,12 @@ void contextLoads() {
@Mock
QueryConfContext queryConfContext;

@MockBean
KafkaDao kafkaDao;

@MockBean
ObsDao obsDao;

@Mock
private RedisDao redisDao;

Expand Down

0 comments on commit ca0432e

Please sign in to comment.