KubernetesContext extends Context { public static KubernetesContextBuilder builder() { return new KubernetesContextBuilder(); } private  KubernetesContext();  KubernetesContext(String namespace, String clusterid, Map<String, Object> properties); @JsonAnyGetter Map<String, Object> getSerializableProperties(); @JsonProperty String getNamespace(); @JsonProperty String getClusterid(); static KubernetesContextBuilder builder(); static final String KUBERNETES_PLATFORM; static final String NAMESPACE_KEY; static final String CLUSTERID_KEY; }
@Test void partialContextIsSerialized() { KubernetesContext context = KubernetesContext.builder() .property("key1", "value1") .namespace("namespace") .property("key2", "value2") .build(); DocumentContext json = JsonUtils.toJsonPath(context); JsonPathAssert.assertThat(json).hasPath("$.platform").isEqualTo("kubernetes"); JsonPathAssert.assertThat(json).hasPath("$.namespace").isEqualTo("namespace"); JsonPathAssert.assertThat(json).hasPath("$.key1").isEqualTo("value1"); JsonPathAssert.assertThat(json).hasPath("$.key2").isEqualTo("value2"); JsonPathAssert.assertThat(json).hasMapAtPath("$").hasSize(4); JsonUtils.assertThatJsonHasExactNumberOfProperties(context, 4 + 1); }
@Test void fullContextIsSerialized() { KubernetesContext context = KubernetesContext.builder() .property("key1", "value1") .namespace("namespace") .clusterid("clusterid") .property("key2", "value2") .build(); DocumentContext json = JsonUtils.toJsonPath(context); JsonPathAssert.assertThat(json).hasPath("$.platform").isEqualTo("kubernetes"); JsonPathAssert.assertThat(json).hasPath("$.namespace").isEqualTo("namespace"); JsonPathAssert.assertThat(json).hasPath("$.clusterid").isEqualTo("clusterid"); JsonPathAssert.assertThat(json).hasPath("$.key1").isEqualTo("value1"); JsonPathAssert.assertThat(json).hasPath("$.key2").isEqualTo("value2"); JsonPathAssert.assertThat(json).hasMapAtPath("$").hasSize(5); JsonUtils.assertThatJsonHasExactNumberOfProperties(context, 5 + 1); }