Skip to content

Commit

Permalink
Init containers
Browse files Browse the repository at this point in the history
  • Loading branch information
Assamir committed Feb 23, 2025
1 parent 164ea12 commit e351a66
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,30 +36,20 @@ public void startMockClient() {
mockServerClient = new MockServerClient(mockServer.getHost(), mockServer.getServerPort());

// Add rule by file
// http://localhost:1080/mockserver/dashboard
// http://localhost:1080/my-api/sample-1
/*
{
"source": "MySystem",
"transportMode": "AIR",
"totalPackages": 1000,
"commercialValue": {
"cost": 200,
"currency": "USD"
},
"isCancelled": false
}
*/
addRule("/my-api/sample-1", "sample-mock-response-1.json");
addRule("/my-api/sample-2", "sample-mock-response-2.json");

// Add conditional rule
addRuleConditionTxt("/cst/integration/api/createRequestV3", "20220415-43872", Map.of(
"AI24000595", "20220415-66666",
"BY24001263", "20220415-66666"
// http://localhost:1080/my-api/sample-text-1
addRuleConditionTxt("/my-api/sample-text-1", "First sample response", Map.of(
"Key-string-in-the-body-1", "Second sample response",
"Key-string-in-the-body-2", "Third sample response"
));

// Add text response
addRuleTxt("/cst/integration/api/closeRequest", "CST request closed");
addRuleTxt("/cst/integration/api/proceedNextStep", "CST request proceeded to the next step");
addRuleTxt("/my-api/sample-text-4", "Fourth sample response");

logger.info("Mock URL: {}:{}", mockServer.getHost(), mockServer.getServerPort());
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import java.util.Map;

public class MyTestResources implements QuarkusTestResourceLifecycleManager {
// private final Network network = TestNetwork.getInstance().getNetwork();
// private final Network network = TestNetwork.getInstance().getNetwork();
private final Network network = TestNetwork.createReusableNetwork();
private RawmindWebContainer rawmindWebContainer = null;
private MyMockServer myMockServer = null;
Expand All @@ -29,9 +29,7 @@ public Map<String, String> start() {

private void startMockServer() {
if (myMockServer == null || !isContainerRunning(Configuration.MY_MOCK_NAME)) {
// if(myMockServer == null || !isContainerRunning(Configuration.MY_MOCK_NAME)) {
myMockServer = new MyMockServer(network);
// myMockServer.start();
if (!myMockServer.isRunning()) {
myMockServer.start();
}
Expand Down Expand Up @@ -71,6 +69,7 @@ private boolean isContainerRunning(String containerName) {
public void stop() {
if (!Configuration.DEBUG) {
stopContainer(rawmindWebContainer);
stopContainer(myMockServer);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.testcontainers.utility.DockerImageName;

import java.util.ArrayList;
import java.util.Arrays;

public class RawmindWebContainer extends GenericContainer<RawmindWebContainer> {
private static final String NETWORK_ALIAS = "rawmind";
Expand All @@ -27,12 +28,8 @@ public RawmindWebContainer(Network network) {
.withExposedPorts(APP_PORT)
.waitingFor(Wait.forLogMessage(".*Running web-test service.*", 1))
.withStartupTimeout(java.time.Duration.ofSeconds(20));
withCreateContainerCmdModifier(cmd -> cmd.withHostConfig(
new HostConfig().withPortBindings(
new PortBinding(Ports.Binding.bindPort(APP_PORT), new ExposedPort(APP_PORT))
)
));
withCreateContainerCmdModifier(cmd -> cmd.withName(Configuration.MY_WEB_APP_NAME));
setPortBindings(Arrays.asList("8080:8080"));
logger().info("RawmindWebContainer starting...");
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"source": "MySystem-2",
"transportMode": "Land",
"totalPackages": 2000,
"commercialValue": {
"cost": 400,
"currency": "USD"
},
"isCancelled": true
}

0 comments on commit e351a66

Please sign in to comment.