Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ void beforeEach() {
.build());

WireMock.stubFor(get(urlMatching("^/api/v1/namespaces/default/configmaps.*"))
.willReturn(aResponse().withStatus(200).withBody(new JSON().serialize(TEST_CONFIGMAP))));
.willReturn(aResponse().withStatus(200).withBody(JSON.serialize(TEST_CONFIGMAP))));
}

// 1. watchers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ public static void stubData() {
secretList.addItemsItem(secretTwo);

WireMock.stubFor(WireMock.get("/api/v1/namespaces/test/configmaps")
.willReturn(WireMock.aResponse().withStatus(200).withBody(new JSON().serialize(configMapList))));
.willReturn(WireMock.aResponse().withStatus(200).withBody(JSON.serialize(configMapList))));

WireMock.stubFor(WireMock.get("/api/v1/namespaces/test/secrets")
.willReturn(WireMock.aResponse().withStatus(200).withBody(new JSON().serialize(secretList))));
.willReturn(WireMock.aResponse().withStatus(200).withBody(JSON.serialize(secretList))));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public static void stubData() {
configMapList.addItemsItem(four);

WireMock.stubFor(WireMock.get("/api/v1/namespaces/spring-k8s/configmaps")
.willReturn(WireMock.aResponse().withStatus(200).withBody(new JSON().serialize(configMapList))));
.willReturn(WireMock.aResponse().withStatus(200).withBody(JSON.serialize(configMapList))));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public static void stubData() {
configMaps.addItemsItem(greenPurpleConfigMapK8s);

WireMock.stubFor(WireMock.get("/api/v1/namespaces/spring-k8s/configmaps")
.willReturn(WireMock.aResponse().withStatus(200).withBody(new JSON().serialize(configMaps))));
.willReturn(WireMock.aResponse().withStatus(200).withBody(JSON.serialize(configMaps))));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public static void stubData() {
secrets.addItemsItem(four);

WireMock.stubFor(WireMock.get("/api/v1/namespaces/spring-k8s/secrets")
.willReturn(WireMock.aResponse().withStatus(200).withBody(new JSON().serialize(secrets))));
.willReturn(WireMock.aResponse().withStatus(200).withBody(JSON.serialize(secrets))));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public static void stubData() {
secrets.addItemsItem(greenPurpleSecretK8s);

WireMock.stubFor(WireMock.get("/api/v1/namespaces/spring-k8s/secrets")
.willReturn(WireMock.aResponse().withStatus(200).withBody(new JSON().serialize(secrets))));
.willReturn(WireMock.aResponse().withStatus(200).withBody(JSON.serialize(secrets))));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public static void stubData() {

// the actual stub for CoreV1Api calls
WireMock.stubFor(WireMock.get("/api/v1/namespaces/spring-k8s/configmaps")
.willReturn(WireMock.aResponse().withStatus(200).withBody(new JSON().serialize(allConfigMaps))));
.willReturn(WireMock.aResponse().withStatus(200).withBody(JSON.serialize(allConfigMaps))));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public static void stubData() {

// the actual stub for CoreV1Api calls
WireMock.stubFor(WireMock.get("/api/v1/namespaces/spring-k8s/configmaps")
.willReturn(WireMock.aResponse().withStatus(200).withBody(new JSON().serialize(allConfigMaps))));
.willReturn(WireMock.aResponse().withStatus(200).withBody(JSON.serialize(allConfigMaps))));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public static void stubData() {

// the actual stub for CoreV1Api calls
WireMock.stubFor(WireMock.get("/api/v1/namespaces/spring-k8s/secrets")
.willReturn(WireMock.aResponse().withStatus(200).withBody(new JSON().serialize(allSecrets))));
.willReturn(WireMock.aResponse().withStatus(200).withBody(JSON.serialize(allSecrets))));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public static void stubData() {

// the actual stub for CoreV1Api calls
WireMock.stubFor(WireMock.get("/api/v1/namespaces/spring-k8s/secrets")
.willReturn(WireMock.aResponse().withStatus(200).withBody(new JSON().serialize(allSecrets))));
.willReturn(WireMock.aResponse().withStatus(200).withBody(JSON.serialize(allSecrets))));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public static void stubData() {

// the actual stub for CoreV1Api calls
WireMock.stubFor(WireMock.get("/api/v1/namespaces/spring-k8s/configmaps")
.willReturn(WireMock.aResponse().withStatus(200).withBody(new JSON().serialize(allConfigMaps))));
.willReturn(WireMock.aResponse().withStatus(200).withBody(JSON.serialize(allConfigMaps))));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public static void stubConfigMapData() {

// the actual stub for CoreV1Api calls
WireMock.stubFor(WireMock.get("/api/v1/namespaces/spring-k8s/configmaps")
.willReturn(WireMock.aResponse().withStatus(200).withBody(new JSON().serialize(allConfigMaps))));
.willReturn(WireMock.aResponse().withStatus(200).withBody(JSON.serialize(allConfigMaps))));
}

public static void stubSecretsData() {
Expand All @@ -105,7 +105,7 @@ public static void stubSecretsData() {

// the actual stub for CoreV1Api calls
WireMock.stubFor(WireMock.get("/api/v1/namespaces/spring-k8s/secrets")
.willReturn(WireMock.aResponse().withStatus(200).withBody(new JSON().serialize(allConfigMaps))));
.willReturn(WireMock.aResponse().withStatus(200).withBody(JSON.serialize(allConfigMaps))));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ static void setup() {

private static void stubConfigMapAndSecretsDefaults() {
// return empty config map / secret list to not fail context creation
stubFor(get(API).willReturn(aResponse().withStatus(200).withBody(new JSON().serialize(new V1ConfigMapList()))));
stubFor(get(API).willReturn(aResponse().withStatus(200).withBody(JSON.serialize(new V1ConfigMapList()))));
}

@AfterAll
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ static void setup() {

private static void stubConfigMapAndSecretsDefaults() {
// return empty config map / secret list to not fail context creation
stubFor(get(API).willReturn(aResponse().withStatus(200).withBody(new JSON().serialize(new V1ConfigMapList()))));
stubFor(get(API).willReturn(aResponse().withStatus(200).withBody(JSON.serialize(new V1ConfigMapList()))));
}

@AfterAll
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ public static void setup() {

private static void stubConfigMapAndSecretsDefaults() {
// return empty config map / secret list to not fail context creation
stubFor(get(API).willReturn(aResponse().withStatus(200).withBody(new JSON().serialize(new V1ConfigMapList()))));
stubFor(get(API).willReturn(aResponse().withStatus(200).withBody(JSON.serialize(new V1ConfigMapList()))));
stubFor(get(SECRETS_API)
.willReturn(aResponse().withStatus(200).withBody(new JSON().serialize(new V1SecretList()))));
.willReturn(aResponse().withStatus(200).withBody(JSON.serialize(new V1SecretList()))));
}

@AfterAll
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ static void setup() {

private static void stubConfigMapAndSecretsDefaults() {
// return empty config map / secret list to not fail context creation
stubFor(get(API).willReturn(aResponse().withStatus(200).withBody(new JSON().serialize(new V1ConfigMapList()))));
stubFor(get(API).willReturn(aResponse().withStatus(200).withBody(JSON.serialize(new V1ConfigMapList()))));
stubFor(get(SECRETS_API)
.willReturn(aResponse().withStatus(200).withBody(new JSON().serialize(new V1SecretList()))));
.willReturn(aResponse().withStatus(200).withBody(JSON.serialize(new V1SecretList()))));
}

@AfterAll
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ static void setup() {

private static void stubConfigMapAndSecretsDefaults() {
// return empty config map / secret list to not fail context creation
stubFor(get(API).willReturn(aResponse().withStatus(200).withBody(new JSON().serialize(new V1ConfigMapList()))));
stubFor(get(API).willReturn(aResponse().withStatus(200).withBody(JSON.serialize(new V1ConfigMapList()))));
}

@AfterAll
Expand Down Expand Up @@ -108,7 +108,7 @@ void locateShouldNotRetryWhenThereIsNoFailure() {
V1ConfigMapList configMapList = new V1ConfigMapList()
.addItemsItem(new V1ConfigMap().metadata(new V1ObjectMeta().name("application")).data(data));

stubFor(get(API).willReturn(aResponse().withStatus(200).withBody(new JSON().serialize(configMapList))));
stubFor(get(API).willReturn(aResponse().withStatus(200).withBody(JSON.serialize(configMapList))));

PropertySource<?>[] propertySource = new PropertySource<?>[1];
Assertions.assertThatCode(() -> propertySource[0] = propertySourceLocator.locate(new MockEnvironment()))
Expand Down Expand Up @@ -151,7 +151,7 @@ void locateShouldRetryAndRecover() {
// then succeed
stubFor(get(API).inScenario("Retry and Recover")
.whenScenarioStateIs("Failed thrice")
.willReturn(aResponse().withStatus(200).withBody(new JSON().serialize(configMapList))));
.willReturn(aResponse().withStatus(200).withBody(JSON.serialize(configMapList))));

PropertySource<?>[] propertySource = new PropertySource<?>[1];
Assertions.assertThatCode(() -> propertySource[0] = propertySourceLocator.locate(new MockEnvironment()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,14 @@ void watch() {
stubFor(get(urlMatching("^/api/v1/namespaces/default/configmaps.*")).inScenario("watch")
.whenScenarioStateIs("update")
.withQueryParam("watch", equalTo("true"))
.willReturn(aResponse().withStatus(200).withBody(new JSON().serialize(watchResponse)))
.willReturn(aResponse().withStatus(200).withBody(JSON.serialize(watchResponse)))
.willSetStateTo("add"));

stubFor(get(urlMatching("^/api/v1/namespaces/default/configmaps.*")).inScenario("watch")
.whenScenarioStateIs("add")
.withQueryParam("watch", equalTo("true"))
.willReturn(aResponse().withStatus(200)
.withBody(new JSON().serialize(new Watch.Response<>(EventType.ADDED.name(),
.withBody(JSON.serialize(new Watch.Response<>(EventType.ADDED.name(),
new V1ConfigMap().kind("ConfigMap")
.metadata(new V1ObjectMeta().namespace("default").name("bar3"))
.putDataItem(Constants.APPLICATION_PROPERTIES, "debug=true")))))
Expand All @@ -141,7 +141,7 @@ void watch() {
.whenScenarioStateIs("delete")
.withQueryParam("watch", equalTo("true"))
.willReturn(aResponse().withStatus(200)
.withBody(new JSON().serialize(new Watch.Response<>(EventType.DELETED.name(),
.withBody(JSON.serialize(new Watch.Response<>(EventType.DELETED.name(),
new V1ConfigMap().kind("ConfigMap")
.metadata(new V1ObjectMeta().namespace("default").name("bar1"))
.putDataItem(Constants.APPLICATION_PROPERTIES, "debug=true")))))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,20 +113,20 @@ void watch() {
stubFor(get(urlMatching("/api/v1/namespaces/default/secrets.*")).inScenario(SCENARIO)
.whenScenarioStateIs(STARTED)
.withQueryParams(WATCH_FALSE)
.willReturn(aResponse().withStatus(200).withBody(new JSON().serialize(secretList)))
.willReturn(aResponse().withStatus(200).withBody(JSON.serialize(secretList)))
.willSetStateTo("update"));

stubFor(get(urlMatching("/api/v1/namespaces/default/secrets.*")).inScenario(SCENARIO)
.whenScenarioStateIs("update")
.withQueryParams(WATCH_TRUE)
.willReturn(aResponse().withStatus(200).withBody(new JSON().serialize(watchResponse)))
.willReturn(aResponse().withStatus(200).withBody(JSON.serialize(watchResponse)))
.willSetStateTo("add"));

stubFor(get(urlMatching("/api/v1/namespaces/default/secrets.*")).inScenario(SCENARIO)
.whenScenarioStateIs("add")
.withQueryParams(WATCH_TRUE)
.willReturn(aResponse().withStatus(200)
.withBody(new JSON().serialize(new Watch.Response<>(EventType.ADDED.name(),
.withBody(JSON.serialize(new Watch.Response<>(EventType.ADDED.name(),
new V1Secret().metadata(new V1ObjectMeta().name("rabbit-password"))
.putDataItem("rabbit-pw", Base64.getEncoder().encode("password".getBytes()))))))
.willSetStateTo("delete"));
Expand All @@ -135,7 +135,7 @@ void watch() {
.whenScenarioStateIs("delete")
.withQueryParams(WATCH_TRUE)
.willReturn(aResponse().withStatus(200)
.withBody(new JSON().serialize(new Watch.Response<>(EventType.DELETED.name(),
.withBody(JSON.serialize(new Watch.Response<>(EventType.DELETED.name(),
new V1Secret().metadata(new V1ObjectMeta().name("rabbit-password"))
.putDataItem("rabbit-pw", Base64.getEncoder().encode("password".getBytes()))))))
.willSetStateTo("done"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ void test(CapturedOutput output) {
// second call passes (change data so that reload is triggered)
V1ConfigMap configMap = configMap(CONFIG_MAP_NAME, Map.of("a", "b"));
V1ConfigMapList configMapList = new V1ConfigMapList().addItemsItem(configMap);
stubFor(get(PATH).willReturn(aResponse().withStatus(200).withBody(new JSON().serialize(configMapList)))
stubFor(get(PATH).willReturn(aResponse().withStatus(200).withBody(JSON.serialize(configMapList)))
.inScenario(SCENARIO_NAME)
.whenScenarioStateIs("go-to-ok")
.willSetStateTo("done"));
Expand Down Expand Up @@ -205,7 +205,7 @@ AbstractEnvironment environment() {

// needed so that our environment is populated with 'something'
// this call is done in the method that returns the AbstractEnvironment
stubFor(get(PATH).willReturn(aResponse().withStatus(200).withBody(new JSON().serialize(configMapList)))
stubFor(get(PATH).willReturn(aResponse().withStatus(200).withBody(JSON.serialize(configMapList)))
.inScenario(SCENARIO_NAME)
.whenScenarioStateIs(Scenario.STARTED)
.willSetStateTo("go-to-fail"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ void test(CapturedOutput output) {
// second call passes (change data so that reload is triggered)
V1Secret secret = secret(SECRET_NAME, Map.of("a", "b"));
V1SecretList secretList = new V1SecretList().addItemsItem(secret);
stubFor(get(PATH).willReturn(aResponse().withStatus(200).withBody(new JSON().serialize(secretList)))
stubFor(get(PATH).willReturn(aResponse().withStatus(200).withBody(JSON.serialize(secretList)))
.inScenario(SCENARIO_NAME)
.whenScenarioStateIs("go-to-ok")
.willSetStateTo("done"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ void test(CapturedOutput output) {
// second reload call passes
V1ConfigMap configMapTwo = configMap(CONFIG_MAP_NAME, Map.of("a", "b"));
V1ConfigMapList listTwo = new V1ConfigMapList().addItemsItem(configMapTwo);
stubFor(get(PATH).willReturn(aResponse().withStatus(200).withBody(new JSON().serialize(listTwo)))
stubFor(get(PATH).willReturn(aResponse().withStatus(200).withBody(JSON.serialize(listTwo)))
.inScenario(SCENARIO_NAME)
.whenScenarioStateIs("go-to-ok")
.willSetStateTo("done"));
Expand Down Expand Up @@ -181,7 +181,7 @@ AbstractEnvironment environment() {

// needed so that our environment is populated with 'something'
// this call is done in the method that returns the AbstractEnvironment
stubFor(get(PATH).willReturn(aResponse().withStatus(200).withBody(new JSON().serialize(listOne)))
stubFor(get(PATH).willReturn(aResponse().withStatus(200).withBody(JSON.serialize(listOne)))
.inScenario(SCENARIO_NAME)
.whenScenarioStateIs(Scenario.STARTED)
.willSetStateTo("go-to-fail"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ void test(CapturedOutput output) {

V1Secret secretTwo = secret(SECRET_NAME, Map.of("a", "b"));
V1SecretList listTwo = new V1SecretList().addItemsItem(secretTwo);
stubFor(get(PATH).willReturn(aResponse().withStatus(200).withBody(new JSON().serialize(listTwo)))
stubFor(get(PATH).willReturn(aResponse().withStatus(200).withBody(JSON.serialize(listTwo)))
.inScenario(SCENARIO_NAME)
.willSetStateTo("done")
.whenScenarioStateIs("go-to-ok"));
Expand Down Expand Up @@ -183,7 +183,7 @@ AbstractEnvironment environment() {

// needed so that our environment is populated with 'something'
// this call is done in the method that returns the AbstractEnvironment
stubFor(get(PATH).willReturn(aResponse().withStatus(200).withBody(new JSON().serialize(listOne)))
stubFor(get(PATH).willReturn(aResponse().withStatus(200).withBody(JSON.serialize(listOne)))
.inScenario(SCENARIO_NAME)
.whenScenarioStateIs(Scenario.STARTED)
.willSetStateTo("go-to-fail"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ public static void setup() {

private static void stubConfigMapAndSecretsDefaults() {
// return empty config map / secret list to not fail context creation
stubFor(get(API).willReturn(aResponse().withStatus(200).withBody(new JSON().serialize(new V1ConfigMapList()))));
stubFor(get(API).willReturn(aResponse().withStatus(200).withBody(JSON.serialize(new V1ConfigMapList()))));
stubFor(get(SECRETS_API)
.willReturn(aResponse().withStatus(200).withBody(new JSON().serialize(new V1SecretList()))));
.willReturn(aResponse().withStatus(200).withBody(JSON.serialize(new V1SecretList()))));
}

@AfterAll
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ void locateShouldNotRetryWhenThereIsNoFailure() {
V1SecretList secretList = new V1SecretList()
.addItemsItem(new V1Secret().metadata(new V1ObjectMeta().name("my-secret")).data(data));

stubFor(get(API).willReturn(aResponse().withStatus(200).withBody(new JSON().serialize(secretList))));
stubFor(get(API).willReturn(aResponse().withStatus(200).withBody(JSON.serialize(secretList))));

final PropertySource<?>[] propertySource = new PropertySource<?>[1];
Assertions.assertThatCode(() -> propertySource[0] = propertySourceLocator.locate(new MockEnvironment()))
Expand Down Expand Up @@ -158,7 +158,7 @@ void locateShouldRetryAndRecover() {
// then succeed
stubFor(get(API).inScenario("Retry and Recover")
.whenScenarioStateIs("Failed thrice")
.willReturn(aResponse().withStatus(200).withBody(new JSON().serialize(secretList))));
.willReturn(aResponse().withStatus(200).withBody(JSON.serialize(secretList))));

final PropertySource<?>[] propertySource = new PropertySource<?>[1];
Assertions.assertThatNoException()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,11 @@ public void before() throws JsonProcessingException {
.withHeader("content-type", "application/json")));
stubFor(get("/api/v1/namespaces/default/endpoints?resourceVersion=0&watch=false")
.willReturn(aResponse().withStatus(200)
.withBody(new JSON().serialize(ENDPOINTS_LIST))
.withBody(JSON.serialize(ENDPOINTS_LIST))
.withHeader("content-type", "application/json")));
stubFor(get("/api/v1/namespaces/default/services?resourceVersion=0&watch=false")
.willReturn(aResponse().withStatus(200)
.withBody(new JSON().serialize(SERVICE_LIST))
.withBody(JSON.serialize(SERVICE_LIST))
.withHeader("content-type", "application/json")));
stubFor(get(urlMatching("/api/v1/namespaces/default/services.*.watch=true"))
.willReturn(aResponse().withStatus(200)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,12 @@ ApiClient apiClient() {
WireMock.configureFor(wireMockServer.port());
stubFor(get("/api/v1/namespaces/test/endpoints?resourceVersion=0&watch=false")
.willReturn(aResponse().withStatus(200)
.withBody(new JSON().serialize(new V1EndpointsListBuilder()
.withBody(JSON.serialize(new V1EndpointsListBuilder()
.withMetadata(new V1ListMetaBuilder().withResourceVersion("0").build())
.build()))));
stubFor(get("/api/v1/namespaces/test/services?resourceVersion=0&watch=false")
.willReturn(aResponse().withStatus(200)
.withBody(new JSON().serialize(new V1ServiceListBuilder()
.withBody(JSON.serialize(new V1ServiceListBuilder()
.withMetadata(new V1ListMetaBuilder().withResourceVersion("0").build())
.build()))));
return new ClientBuilder().setBasePath(wireMockServer.baseUrl()).build();
Expand Down
Loading
Loading