This repository has been archived by the owner on Jun 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from patientsknowbest/PHR-6960_move_all_testsu…
…pport_pulsar Move all TestSupport functions to Pulsar PHR-6960
- Loading branch information
Showing
12 changed files
with
223 additions
and
119 deletions.
There are no files selected for viewing
41 changes: 0 additions & 41 deletions
41
infrastructure/src/main/java/com/pkb/common/DateTimeTestSupportServlet.java
This file was deleted.
Oops, something went wrong.
33 changes: 0 additions & 33 deletions
33
infrastructure/src/main/java/com/pkb/common/InjectableConfigTestSupportServlet.java
This file was deleted.
Oops, something went wrong.
15 changes: 0 additions & 15 deletions
15
infrastructure/src/main/java/com/pkb/common/InjectablePrimaryConfigTestSupportServlet.java
This file was deleted.
Oops, something went wrong.
15 changes: 0 additions & 15 deletions
15
infrastructure/src/main/java/com/pkb/common/InjectableSecondaryConfigTestSupportServlet.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
testsupport/src/main/java/com/pkb/common/testsupport/ClearTestStatesService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.pkb.common.testsupport; | ||
|
||
import com.pkb.common.ClearableInternalState; | ||
import com.pkb.common.config.ConfigStorage; | ||
import com.pkb.common.datetime.DateTimeService; | ||
import com.pkb.pulsar.payload.ClearTestStatesRequest; | ||
import com.pkb.pulsar.payload.ClearTestStatesResponse; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.util.Set; | ||
|
||
class ClearTestStatesService { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(java.lang.invoke.MethodHandles.lookup().lookupClass()); | ||
|
||
private final DateTimeService dateTimeService; | ||
private final ConfigStorage configStorage; | ||
private final Set<ClearableInternalState> clearables; | ||
|
||
ClearTestStatesService(DateTimeService dateTimeService, ConfigStorage configStorage, Set<ClearableInternalState> clearables) { | ||
this.dateTimeService = dateTimeService; | ||
this.configStorage = configStorage; | ||
this.clearables = clearables; | ||
} | ||
|
||
ClearTestStatesResponse process(ClearTestStatesRequest message) { | ||
LOGGER.info("ClearTestStatesService.process message received"); | ||
|
||
boolean clearFixedTimestamp = message.getClearFixedTimestamp(); | ||
if (clearFixedTimestamp) { | ||
dateTimeService.forgetFixedCurrentTimeForTesting(); | ||
} | ||
|
||
if (configStorage.isMutableConfigEnabled()) { | ||
configStorage.reset(); | ||
} | ||
|
||
clearables.forEach(ClearableInternalState::clearState); | ||
|
||
LOGGER.info("ClearTestStatesService.process done."); | ||
|
||
return ClearTestStatesResponse.newBuilder().build(); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
testsupport/src/main/java/com/pkb/common/testsupport/InjectConfigValueService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.pkb.common.testsupport; | ||
|
||
import com.pkb.common.config.ConfigStorage; | ||
import com.pkb.pulsar.payload.InjectConfigRequest; | ||
import com.pkb.pulsar.payload.InjectConfigResponse; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class InjectConfigValueService { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(java.lang.invoke.MethodHandles.lookup().lookupClass()); | ||
|
||
private ConfigStorage configStorage; | ||
|
||
public InjectConfigValueService(ConfigStorage configStorage) { | ||
this.configStorage = configStorage; | ||
} | ||
|
||
public InjectConfigResponse process(InjectConfigRequest message) { | ||
LOGGER.info("InjectConfigValueService.process message received"); | ||
String key = message.getKey(); | ||
String value = message.getValue(); | ||
LOGGER.info(String.format("InjectConfigValueService.process setting key %s to value %s", key, value)); | ||
|
||
boolean success = true; | ||
if (configStorage.isMutableConfigEnabled()) { | ||
configStorage.setValue(key, value); | ||
} else { | ||
success = false; | ||
} | ||
|
||
LOGGER.info("InjectConfigValueService.process done."); | ||
return InjectConfigResponse.newBuilder().setKey(key).setValue(value).setSuccess(success).build(); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
testsupport/src/main/java/com/pkb/common/testsupport/LogTestNameService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.pkb.common.testsupport; | ||
|
||
import com.pkb.common.config.BaseConfig; | ||
import com.pkb.pulsar.payload.LogTestNameRequest; | ||
import com.pkb.pulsar.payload.LogTestNameResponse; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
class LogTestNameService { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(java.lang.invoke.MethodHandles.lookup().lookupClass()); | ||
|
||
private final BaseConfig config; | ||
|
||
LogTestNameService(BaseConfig config) { | ||
this.config = config; | ||
} | ||
|
||
LogTestNameResponse process(LogTestNameRequest message) { | ||
LOGGER.info("LogTestNameService.process message received"); | ||
String testName = message.getTestName(); | ||
boolean success = true; | ||
if (config.isFakeDateTimeServiceEnabled()) { | ||
LOGGER.info("test name is now {}", testName); | ||
} else { | ||
success = false; | ||
} | ||
|
||
LOGGER.info("LogTestNameService.process done."); | ||
|
||
return LogTestNameResponse.newBuilder().setTestName(testName).setSuccess(success).build(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.