use of org.assertj.core.api.AbstractObjectAssert in project quarkus by quarkusio.
the class OpenshiftWithLegacySidecarAndS2iTest method assertGeneratedResources.
@Test
public void assertGeneratedResources() throws IOException {
final Path kubernetesDir = prodModeTestResults.getBuildDir().resolve("kubernetes");
assertThat(kubernetesDir).isDirectoryContaining(p -> p.getFileName().endsWith("openshift.json")).isDirectoryContaining(p -> p.getFileName().endsWith("openshift.yml"));
List<HasMetadata> openshiftList = DeserializationUtil.deserializeAsList(kubernetesDir.resolve("openshift.yml"));
assertThat(openshiftList).filteredOn(h -> "DeploymentConfig".equals(h.getKind())).singleElement().satisfies(h -> {
assertThat(h.getMetadata()).satisfies(m -> {
assertThat(m.getName()).isEqualTo("openshift-sidecar-test");
assertThat(m.getLabels().get("app.openshift.io/runtime")).isEqualTo("quarkus");
});
AbstractObjectAssert<?, ?> specAssert = assertThat(h).extracting("spec");
specAssert.extracting("template").extracting("spec").isInstanceOfSatisfying(PodSpec.class, podSpec -> {
assertThat(podSpec.getContainers()).hasSize(2);
assertSidecar(podSpec);
assertApplicationContainer(podSpec);
});
});
}
use of org.assertj.core.api.AbstractObjectAssert in project quarkus by quarkusio.
the class OpenshiftWithSidecarAndS2iTest method assertGeneratedResources.
@Test
public void assertGeneratedResources() throws IOException {
final Path kubernetesDir = prodModeTestResults.getBuildDir().resolve("kubernetes");
assertThat(kubernetesDir).isDirectoryContaining(p -> p.getFileName().endsWith("openshift.json")).isDirectoryContaining(p -> p.getFileName().endsWith("openshift.yml"));
List<HasMetadata> openshiftList = DeserializationUtil.deserializeAsList(kubernetesDir.resolve("openshift.yml"));
assertThat(openshiftList).filteredOn(h -> "DeploymentConfig".equals(h.getKind())).singleElement().satisfies(h -> {
assertThat(h.getMetadata()).satisfies(m -> {
assertThat(m.getName()).isEqualTo("openshift-sidecar-test");
assertThat(m.getLabels().get("app.openshift.io/runtime")).isEqualTo("quarkus");
});
AbstractObjectAssert<?, ?> specAssert = assertThat(h).extracting("spec");
specAssert.extracting("template").extracting("spec").isInstanceOfSatisfying(PodSpec.class, podSpec -> {
assertThat(podSpec.getContainers()).hasSize(2);
assertSidecar(podSpec);
assertApplicationContainer(podSpec);
});
});
}
use of org.assertj.core.api.AbstractObjectAssert in project quarkus by quarkusio.
the class OpenshiftWithAppConfigMapTest method assertGeneratedResources.
@Test
public void assertGeneratedResources() throws IOException {
Path kubernetesDir = prodModeTestResults.getBuildDir().resolve("kubernetes");
assertThat(kubernetesDir).isDirectoryContaining(p -> p.getFileName().endsWith("openshift.json")).isDirectoryContaining(p -> p.getFileName().endsWith("openshift.yml"));
List<HasMetadata> openshiftList = DeserializationUtil.deserializeAsList(kubernetesDir.resolve("openshift.yml"));
assertThat(openshiftList).filteredOn(h -> "DeploymentConfig".equals(h.getKind())).singleElement().satisfies(h -> {
assertThat(h.getMetadata()).satisfies(m -> {
assertThat(m.getName()).isEqualTo("openshift-with-app-config-map");
assertThat(m.getLabels().get("app.openshift.io/runtime")).isEqualTo("quarkus");
});
AbstractObjectAssert<?, ?> specAssert = assertThat(h).extracting("spec");
specAssert.extracting("template").extracting("spec").isInstanceOfSatisfying(PodSpec.class, podSpec -> {
assertThat(podSpec.getContainers()).singleElement().satisfies(container -> {
List<EnvVar> envVars = container.getEnv();
assertThat(envVars).anySatisfy(envVar -> {
assertThat(envVar.getName()).isEqualTo("SMALLRYE_CONFIG_LOCATIONS");
assertThat(envVar.getValue()).isEqualTo("/mnt/app-config-map");
});
List<VolumeMount> mounts = container.getVolumeMounts();
assertThat(mounts).anySatisfy(mount -> {
assertThat(mount.getName()).isEqualTo("app-config-map");
assertThat(mount.getMountPath()).isEqualTo("/mnt/app-config-map");
});
});
List<Volume> volumes = podSpec.getVolumes();
assertThat(volumes).anySatisfy(volume -> {
assertThat(volume.getName()).isEqualTo("app-config-map");
assertThat(volume.getConfigMap().getName()).isEqualTo("my-config-map");
});
});
});
}
use of org.assertj.core.api.AbstractObjectAssert in project quarkus by quarkusio.
the class OpenshiftWithApplicationPropertiesTest method assertGeneratedResources.
@Test
public void assertGeneratedResources() throws IOException {
Path kubernetesDir = prodModeTestResults.getBuildDir().resolve("kubernetes");
assertThat(kubernetesDir).isDirectoryContaining(p -> p.getFileName().endsWith("openshift.json")).isDirectoryContaining(p -> p.getFileName().endsWith("openshift.yml"));
List<HasMetadata> openshiftList = DeserializationUtil.deserializeAsList(kubernetesDir.resolve("openshift.yml"));
assertThat(openshiftList).filteredOn(h -> "DeploymentConfig".equals(h.getKind())).singleElement().satisfies(h -> {
assertThat(h.getMetadata()).satisfies(m -> {
assertThat(m.getName()).isEqualTo("test-it");
assertThat(m.getLabels()).contains(entry("foo", "bar"));
assertThat(m.getNamespace()).isEqualTo("applications");
});
AbstractObjectAssert<?, ?> specAssert = assertThat(h).extracting("spec");
specAssert.extracting("replicas").isEqualTo(3);
specAssert.extracting("template").extracting("spec").isInstanceOfSatisfying(PodSpec.class, podSpec -> {
assertThat(podSpec.getContainers()).singleElement().satisfies(container -> {
assertThat(container.getEnv()).extracting("name", "value").contains(tuple("MY_ENV_VAR", "SOMEVALUE"));
assertThat(container.getImagePullPolicy()).isEqualTo("IfNotPresent");
});
});
specAssert.extracting("selector").isInstanceOfSatisfying(Map.class, selectorsMap -> {
assertThat(selectorsMap).containsOnly(entry("app.kubernetes.io/name", "test-it"));
});
});
assertThat(openshiftList).filteredOn(h -> "Service".equals(h.getKind())).singleElement().satisfies(h -> {
assertThat(h).isInstanceOfSatisfying(Service.class, s -> {
assertThat(s.getMetadata()).satisfies(m -> {
assertThat(m.getNamespace()).isEqualTo("applications");
});
assertThat(s.getSpec()).satisfies(spec -> {
assertThat(spec.getSelector()).containsOnly(entry("app.kubernetes.io/name", "test-it"));
assertThat(spec.getPorts()).hasSize(1).singleElement().satisfies(p -> {
assertThat(p.getPort()).isEqualTo(80);
assertThat(p.getTargetPort().getIntVal()).isEqualTo(9090);
});
});
});
});
assertThat(openshiftList).filteredOn(i -> "Route".equals(i.getKind())).singleElement().satisfies(i -> {
assertThat(i).isInstanceOfSatisfying(Route.class, r -> {
// Check that labels and annotations are also applied to Routes (#10260)
assertThat(r.getMetadata()).satisfies(m -> {
assertThat(m.getName()).isEqualTo("test-it");
assertThat(m.getLabels()).contains(entry("foo", "bar"));
assertThat(m.getAnnotations()).contains(entry("bar", "baz"));
assertThat(m.getNamespace()).isEqualTo("applications");
});
assertThat(r.getSpec().getPort().getTargetPort().getIntVal()).isEqualTo(9090);
});
});
}
use of org.assertj.core.api.AbstractObjectAssert in project quarkus by quarkusio.
the class OpenshiftV4Test method assertGeneratedResources.
@Test
public void assertGeneratedResources() throws IOException {
Path kubernetesDir = prodModeTestResults.getBuildDir().resolve("kubernetes");
assertThat(kubernetesDir).isDirectoryContaining(p -> p.getFileName().endsWith("openshift.json")).isDirectoryContaining(p -> p.getFileName().endsWith("openshift.yml")).satisfies(p -> assertThat(p.toFile().listFiles()).hasSize(2));
List<HasMetadata> openshiftList = DeserializationUtil.deserializeAsList(kubernetesDir.resolve("openshift.yml"));
assertThat(openshiftList).filteredOn(h -> "DeploymentConfig".equals(h.getKind())).singleElement().satisfies(h -> {
assertThat(h.getMetadata()).satisfies(m -> {
assertThat(m.getName()).isEqualTo("openshift-v4");
assertThat(m.getLabels().get("app.openshift.io/runtime")).isEqualTo("quarkus");
assertThat(m.getLabels().get("app.kubernetes.io/name")).isEqualTo("openshift-v4");
assertThat(m.getLabels().get("app")).isNull();
assertThat(m.getNamespace()).isNull();
});
AbstractObjectAssert<?, ?> specAssert = assertThat(h).extracting("spec");
specAssert.extracting("selector").isInstanceOfSatisfying(Map.class, selectorsMap -> {
assertThat(selectorsMap).containsOnly(entry("app.kubernetes.io/name", "openshift-v4"), entry("app.kubernetes.io/version", "0.1-SNAPSHOT"));
});
});
assertThat(openshiftList).filteredOn(h -> "Service".equals(h.getKind())).singleElement().satisfies(h -> {
assertThat(h).isInstanceOfSatisfying(Service.class, s -> {
assertThat(s.getMetadata()).satisfies(m -> {
assertThat(m.getNamespace()).isNull();
assertThat(m.getLabels().get("app.kubernetes.io/name")).isEqualTo("openshift-v4");
assertThat(m.getLabels().get("app")).isNull();
});
assertThat(s.getSpec()).satisfies(spec -> {
assertThat(spec.getSelector()).containsOnly(entry("app.kubernetes.io/name", "openshift-v4"), entry("app.kubernetes.io/version", "0.1-SNAPSHOT"));
});
});
});
}
Aggregations