forked from cloudfoundry/cf-java-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApplicationManifestUtilsV3Test.java
More file actions
127 lines (113 loc) · 5.78 KB
/
ApplicationManifestUtilsV3Test.java
File metadata and controls
127 lines (113 loc) · 5.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
package org.cloudfoundry.operations.applications;
import static org.junit.jupiter.api.Assertions.*;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import org.cloudfoundry.client.v3.Metadata;
import org.cloudfoundry.client.v3.processes.ReadinessHealthCheckType;
import org.junit.jupiter.api.Test;
class ApplicationManifestUtilsV3Test {
@Test
void testGenericApplication() throws IOException {
ManifestV3 manifest =
ManifestV3.builder()
.application(
ManifestV3Application.builder()
.name("test-app")
.buildpack("test-buildpack")
.command("test-command")
.disk(512)
.healthCheckHttpEndpoint("test-health-check-http-endpoint")
.instances(2)
.memory(512)
.randomRoute(true)
.stack("test-stack")
.timeout(120)
.environmentVariable("TEST_KEY_1", "test-value-1")
.processe(
ManifestV3Process.builder()
.type("web")
.command("test-command-1")
.readinessHealthCheckType(
ReadinessHealthCheckType.HTTP)
.readinessHealthCheckHttpEndpoint(
"test-readiness-health-check-http-endpoint")
.readinessHealthCheckInvocationTimeout(120)
.build())
.service(
ManifestV3Service.builder()
.name("test-service-1")
.build())
.build())
.build();
assertSerializeDeserialize(manifest);
}
@Test
void testWithDockerApp() throws IOException {
ManifestV3 manifest =
ManifestV3.builder()
.application(
ManifestV3Application.builder()
.name("test-app")
.docker(Docker.builder().image("test-image").build())
.build())
.build();
assertSerializeDeserialize(manifest);
}
@Test
void testWithMetadata() throws IOException {
ManifestV3 manifest =
ManifestV3.builder()
.application(
ManifestV3Application.builder()
.name("test-app")
.metadata(
Metadata.builder()
.label("test-label", "test-label-value")
.annotation(
"test-annotation",
"test-annotation-value")
.build())
.build())
.build();
assertSerializeDeserialize(manifest);
}
@Test
void testWithMetadataOnlyLabel() throws IOException {
ManifestV3 manifest =
ManifestV3.builder()
.application(
ManifestV3Application.builder()
.name("test-app")
.metadata(
Metadata.builder()
.label("test-label", "test-label-value")
.build())
.build())
.build();
assertSerializeDeserialize(manifest);
}
@Test
void testWithMetadataOnlyAnnotation() throws IOException {
ManifestV3 manifest =
ManifestV3.builder()
.application(
ManifestV3Application.builder()
.name("test-app")
.metadata(
Metadata.builder()
.annotation(
"test-annotation",
"test-annotation-value")
.build())
.build())
.build();
assertSerializeDeserialize(manifest);
}
private void assertSerializeDeserialize(ManifestV3 manifest) throws IOException {
Path file = Files.createTempFile("test-manifest-", ".yml");
ApplicationManifestUtilsV3.write(file, manifest);
ManifestV3 read = ApplicationManifestUtilsV3.read(file);
assertEquals(manifest, read);
}
}