Skip to content

Commit 9ffd490

Browse files
committed
#246 print hoverfly version on start up
1 parent 56eda74 commit 9ffd490

File tree

5 files changed

+19
-4
lines changed

5 files changed

+19
-4
lines changed

src/main/java/io/specto/hoverfly/junit/api/view/HoverflyInfoView.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public class HoverflyInfoView {
1616
private final Usage usage;
1717
private final Middleware middleware;
1818
private final String upstreamProxy;
19+
private final String version;
1920

2021

2122
@JsonCreator
@@ -24,13 +25,15 @@ public HoverflyInfoView(@JsonProperty("destination") String destination,
2425
@JsonProperty("arguments") ModeArguments modeArguments,
2526
@JsonProperty("usage") Usage usage,
2627
@JsonProperty("middleware") Middleware middleware,
27-
@JsonProperty("upstream-proxy") String upstreamProxy) {
28+
@JsonProperty("upstream-proxy") String upstreamProxy,
29+
@JsonProperty("version") String version) {
2830
this.destination = destination;
2931
this.mode = mode;
3032
this.modeArguments = modeArguments;
3133
this.usage = usage;
3234
this.middleware = middleware;
3335
this.upstreamProxy = upstreamProxy;
36+
this.version = version;
3437
}
3538

3639

@@ -58,6 +61,10 @@ public String getUpstreamProxy() {
5861
return upstreamProxy;
5962
}
6063

64+
public String getVersion() {
65+
return version;
66+
}
67+
6168
private static class Usage {
6269

6370
private Counters counters;

src/main/java/io/specto/hoverfly/junit/core/Hoverfly.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ public void start() {
143143
}
144144

145145
waitForHoverflyToBecomeHealthy();
146+
LOGGER.info("A {} Hoverfly with version {} is ready", hoverflyConfig.isRemoteInstance() ? "remote" : "local", hoverflyClient.getConfigInfo().getVersion());
146147

147148
setModeWithArguments(hoverflyMode, hoverflyConfig);
148149

src/test/java/io/specto/hoverfly/junit/core/HoverflyTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,9 @@ public void tearDown() {
759759

760760
private HoverflyClient createMockHoverflyClient(Hoverfly hoverfly) {
761761
HoverflyClient hoverflyClient = mock(HoverflyClient.class);
762+
HoverflyInfoView mockHoverflyInfoView = mock(HoverflyInfoView.class);
763+
when(mockHoverflyInfoView.getVersion()).thenReturn("v1.0.0");
764+
when(hoverflyClient.getConfigInfo()).thenReturn(mockHoverflyInfoView);
762765
Whitebox.setInternalState(hoverfly, "hoverflyClient", hoverflyClient);
763766
return hoverflyClient;
764767
}

src/test/java/io/specto/hoverfly/junit/core/RemoteHoverflyStubTest.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.specto.hoverfly.junit.core;
22

3+
import io.specto.hoverfly.junit.api.command.ModeCommand;
34
import io.specto.hoverfly.junit.api.view.HoverflyInfoView;
45
import io.specto.hoverfly.junit.dsl.HttpBodyConverter;
56
import org.junit.After;
@@ -30,8 +31,11 @@ public void setUp() {
3031
.get("/api/health")
3132
.willReturn(success())
3233

34+
.get("/api/v2/hoverfly")
35+
.willReturn(success().body(HttpBodyConverter.json(new HoverflyInfoView(null, SIMULATE.getValue(), null, null, null, null, "v1.0.0"))))
36+
3337
.put("/api/v2/hoverfly/mode")
34-
.body(HttpBodyConverter.json(new HoverflyInfoView(null, SIMULATE.getValue(), null, null, null, null)))
38+
.body(HttpBodyConverter.json(new ModeCommand(SIMULATE)))
3539
.willReturn(success())
3640
));
3741
}

src/test/java/io/specto/hoverfly/junit/core/model/HoverflyInfoViewTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class HoverflyInfoViewTest {
1111
@Test
1212
public void shouldNotSerializeNullField() throws Exception {
1313

14-
HoverflyInfoView hoverflyInfoView = new HoverflyInfoView("www.test.com", null, null, null, null, null);
14+
HoverflyInfoView hoverflyInfoView = new HoverflyInfoView("www.test.com", null, null, null, null, null, null);
1515

1616
ObjectMapper objectMapper = new ObjectMapper();
1717

@@ -20,4 +20,4 @@ public void shouldNotSerializeNullField() throws Exception {
2020
JSONAssert.assertEquals("{\"destination\": \"www.test.com\"}", json, true);
2121

2222
}
23-
}
23+
}

0 commit comments

Comments
 (0)