use of io.kubernetes.client.common.KubernetesType in project java by kubernetes-client.
the class YamlTest method testLoadAllFile.
@Test
public void testLoadAllFile() throws Exception {
List<Object> list = Yaml.loadAll(new File(TEST_YAML_FILE_PATH));
List<KubernetesType> k8ObjectList = new ArrayList<>();
for (Object object : list) {
String type = object.getClass().getSimpleName();
if (type.equals("V1Service")) {
V1Service svc = (V1Service) object;
assertEquals("v1", svc.getApiVersion());
assertEquals("Service", svc.getKind());
assertEquals("mock", svc.getMetadata().getName());
k8ObjectList.add(svc);
} else if (type.equals("V1Deployment")) {
V1Deployment deploy = (V1Deployment) object;
assertEquals("apps/v1", deploy.getApiVersion());
assertEquals("Deployment", deploy.getKind());
assertEquals("helloworld", deploy.getMetadata().getName());
k8ObjectList.add(deploy);
} else if (type.equals("V1Secret")) {
V1Secret secret = (V1Secret) object;
assertEquals("Secret", secret.getKind());
assertEquals("secret", secret.getMetadata().getName());
assertEquals("Opaque", secret.getType());
assertEquals("hello", new String(secret.getData().get("secret-data"), UTF_8));
k8ObjectList.add(secret);
} else {
throw new Exception("some thing wrong happened");
}
}
String result = Yaml.dumpAll(k8ObjectList.iterator());
String expected = Resources.toString(EXPECTED_YAML_FILE, UTF_8).replace("\r\n", "\n");
assertThat(result, equalTo(expected));
}
Aggregations