5
5
package oracle .kubernetes .operator .create ;
6
6
7
7
import static java .util .Arrays .asList ;
8
- import static oracle .kubernetes .operator .LabelConstants .*;
9
- import static oracle .kubernetes .operator .VersionConstants .*;
10
- import static oracle .kubernetes .operator .utils .CreateDomainInputs .readInputsYamlFile ;
11
- import static oracle .kubernetes .operator .utils .KubernetesArtifactUtils .*;
8
+ import static oracle .kubernetes .operator .LabelConstants .APP_LABEL ;
9
+ import static oracle .kubernetes .operator .LabelConstants .CLUSTERNAME_LABEL ;
10
+ import static oracle .kubernetes .operator .LabelConstants .DOMAINNAME_LABEL ;
11
+ import static oracle .kubernetes .operator .LabelConstants .DOMAINUID_LABEL ;
12
+ import static oracle .kubernetes .operator .LabelConstants .RESOURCE_VERSION_LABEL ;
13
+ import static oracle .kubernetes .operator .VersionConstants .APACHE_LOAD_BALANCER_V1 ;
14
+ import static oracle .kubernetes .operator .VersionConstants .DOMAIN_V1 ;
15
+ import static oracle .kubernetes .operator .VersionConstants .TRAEFIK_LOAD_BALANCER_V1 ;
16
+ import static oracle .kubernetes .operator .VersionConstants .VOYAGER_LOAD_BALANCER_V1 ;
17
+ import static oracle .kubernetes .operator .utils .KubernetesArtifactUtils .API_GROUP_RBAC ;
18
+ import static oracle .kubernetes .operator .utils .KubernetesArtifactUtils .API_VERSION_APPS_V1BETA1 ;
19
+ import static oracle .kubernetes .operator .utils .KubernetesArtifactUtils .API_VERSION_EXTENSIONS_V1BETA1 ;
20
+ import static oracle .kubernetes .operator .utils .KubernetesArtifactUtils .API_VERSION_RBAC_V1 ;
21
+ import static oracle .kubernetes .operator .utils .KubernetesArtifactUtils .KIND_CLUSTER_ROLE ;
22
+ import static oracle .kubernetes .operator .utils .KubernetesArtifactUtils .KIND_SERVICE_ACCOUNT ;
23
+ import static oracle .kubernetes .operator .utils .KubernetesArtifactUtils .containsRegexps ;
24
+ import static oracle .kubernetes .operator .utils .KubernetesArtifactUtils .getThenEmptyConfigMapDataValue ;
25
+ import static oracle .kubernetes .operator .utils .KubernetesArtifactUtils .newClusterRole ;
26
+ import static oracle .kubernetes .operator .utils .KubernetesArtifactUtils .newClusterRoleBinding ;
27
+ import static oracle .kubernetes .operator .utils .KubernetesArtifactUtils .newClusterStartup ;
28
+ import static oracle .kubernetes .operator .utils .KubernetesArtifactUtils .newClusterStartupList ;
29
+ import static oracle .kubernetes .operator .utils .KubernetesArtifactUtils .newConfigMap ;
30
+ import static oracle .kubernetes .operator .utils .KubernetesArtifactUtils .newConfigMapVolumeSource ;
31
+ import static oracle .kubernetes .operator .utils .KubernetesArtifactUtils .newContainer ;
32
+ import static oracle .kubernetes .operator .utils .KubernetesArtifactUtils .newContainerPort ;
33
+ import static oracle .kubernetes .operator .utils .KubernetesArtifactUtils .newDeployment ;
34
+ import static oracle .kubernetes .operator .utils .KubernetesArtifactUtils .newDeploymentSpec ;
35
+ import static oracle .kubernetes .operator .utils .KubernetesArtifactUtils .newDomain ;
36
+ import static oracle .kubernetes .operator .utils .KubernetesArtifactUtils .newDomainSpec ;
37
+ import static oracle .kubernetes .operator .utils .KubernetesArtifactUtils .newEnvVar ;
38
+ import static oracle .kubernetes .operator .utils .KubernetesArtifactUtils .newEnvVarList ;
39
+ import static oracle .kubernetes .operator .utils .KubernetesArtifactUtils .newHTTPGetAction ;
40
+ import static oracle .kubernetes .operator .utils .KubernetesArtifactUtils .newHostPathVolumeSource ;
41
+ import static oracle .kubernetes .operator .utils .KubernetesArtifactUtils .newIntOrString ;
42
+ import static oracle .kubernetes .operator .utils .KubernetesArtifactUtils .newJob ;
43
+ import static oracle .kubernetes .operator .utils .KubernetesArtifactUtils .newJobSpec ;
44
+ import static oracle .kubernetes .operator .utils .KubernetesArtifactUtils .newLabelSelector ;
45
+ import static oracle .kubernetes .operator .utils .KubernetesArtifactUtils .newLocalObjectReferenceList ;
46
+ import static oracle .kubernetes .operator .utils .KubernetesArtifactUtils .newObjectMeta ;
47
+ import static oracle .kubernetes .operator .utils .KubernetesArtifactUtils .newPersistentVolume ;
48
+ import static oracle .kubernetes .operator .utils .KubernetesArtifactUtils .newPersistentVolumeClaim ;
49
+ import static oracle .kubernetes .operator .utils .KubernetesArtifactUtils .newPersistentVolumeClaimSpec ;
50
+ import static oracle .kubernetes .operator .utils .KubernetesArtifactUtils .newPersistentVolumeClaimVolumeSource ;
51
+ import static oracle .kubernetes .operator .utils .KubernetesArtifactUtils .newPersistentVolumeSpec ;
52
+ import static oracle .kubernetes .operator .utils .KubernetesArtifactUtils .newPodSpec ;
53
+ import static oracle .kubernetes .operator .utils .KubernetesArtifactUtils .newPodTemplateSpec ;
54
+ import static oracle .kubernetes .operator .utils .KubernetesArtifactUtils .newPolicyRule ;
55
+ import static oracle .kubernetes .operator .utils .KubernetesArtifactUtils .newProbe ;
56
+ import static oracle .kubernetes .operator .utils .KubernetesArtifactUtils .newResourceRequirements ;
57
+ import static oracle .kubernetes .operator .utils .KubernetesArtifactUtils .newRoleRef ;
58
+ import static oracle .kubernetes .operator .utils .KubernetesArtifactUtils .newSecretReference ;
59
+ import static oracle .kubernetes .operator .utils .KubernetesArtifactUtils .newSecretVolumeSource ;
60
+ import static oracle .kubernetes .operator .utils .KubernetesArtifactUtils .newServerStartup ;
61
+ import static oracle .kubernetes .operator .utils .KubernetesArtifactUtils .newServerStartupList ;
62
+ import static oracle .kubernetes .operator .utils .KubernetesArtifactUtils .newService ;
63
+ import static oracle .kubernetes .operator .utils .KubernetesArtifactUtils .newServiceAccount ;
64
+ import static oracle .kubernetes .operator .utils .KubernetesArtifactUtils .newServicePort ;
65
+ import static oracle .kubernetes .operator .utils .KubernetesArtifactUtils .newServiceSpec ;
66
+ import static oracle .kubernetes .operator .utils .KubernetesArtifactUtils .newSubject ;
67
+ import static oracle .kubernetes .operator .utils .KubernetesArtifactUtils .newTCPSocketAction ;
68
+ import static oracle .kubernetes .operator .utils .KubernetesArtifactUtils .newToleration ;
69
+ import static oracle .kubernetes .operator .utils .KubernetesArtifactUtils .newVolume ;
70
+ import static oracle .kubernetes .operator .utils .KubernetesArtifactUtils .newVolumeMount ;
12
71
import static oracle .kubernetes .operator .utils .YamlUtils .yamlEqualTo ;
13
72
import static org .hamcrest .MatcherAssert .assertThat ;
14
- import static org .hamcrest .Matchers .* ;
73
+ import static org .hamcrest .Matchers .containsString ;
15
74
16
75
import io .kubernetes .client .custom .Quantity ;
17
- import io .kubernetes .client .models .*;
18
- import oracle .kubernetes .operator .utils .CreateDomainInputs ;
76
+ import io .kubernetes .client .models .ExtensionsV1beta1Deployment ;
77
+ import io .kubernetes .client .models .V1ConfigMap ;
78
+ import io .kubernetes .client .models .V1Job ;
79
+ import io .kubernetes .client .models .V1PersistentVolume ;
80
+ import io .kubernetes .client .models .V1PersistentVolumeClaim ;
81
+ import io .kubernetes .client .models .V1Service ;
82
+ import io .kubernetes .client .models .V1ServiceAccount ;
83
+ import io .kubernetes .client .models .V1beta1ClusterRole ;
84
+ import io .kubernetes .client .models .V1beta1ClusterRoleBinding ;
85
+ import oracle .kubernetes .operator .utils .DomainValues ;
86
+ import oracle .kubernetes .operator .utils .DomainYamlFactory ;
19
87
import oracle .kubernetes .operator .utils .GeneratedDomainYamlFiles ;
20
88
import oracle .kubernetes .operator .utils .ParsedApacheSecurityYaml ;
21
89
import oracle .kubernetes .operator .utils .ParsedApacheYaml ;
30
98
import oracle .kubernetes .operator .utils .ParsedWeblogicDomainPersistentVolumeClaimYaml ;
31
99
import oracle .kubernetes .operator .utils .ParsedWeblogicDomainPersistentVolumeYaml ;
32
100
import oracle .kubernetes .weblogic .domain .v1 .Domain ;
33
- import org .junit .AfterClass ;
34
101
import org .junit .Test ;
35
102
36
103
/**
40
107
*/
41
108
public abstract class CreateDomainGeneratedFilesBaseTest {
42
109
43
- private static CreateDomainInputs inputs ;
110
+ private static DomainValues inputs ;
44
111
private static GeneratedDomainYamlFiles generatedFiles ;
112
+ private static DomainYamlFactory factory ;
45
113
46
114
private static final String PROPERTY_TRAEFIK_TOML = "traefik.toml" ;
47
115
private static final String PROPERTY_UTILITY_SH = "utility.sh" ;
@@ -50,31 +118,31 @@ public abstract class CreateDomainGeneratedFilesBaseTest {
50
118
private static final String PROPERTY_CREATE_DOMAIN_SCRIPT_SH = "create-domain-script.sh" ;
51
119
private static final String PROPERTY_CREATE_DOMAIN_PY = "create-domain.py" ;
52
120
53
- protected static CreateDomainInputs getInputs () {
121
+ protected static DomainValues getInputs () {
54
122
return inputs ;
55
123
}
56
124
57
- protected static GeneratedDomainYamlFiles getGeneratedFiles () {
125
+ private static GeneratedDomainYamlFiles getGeneratedFiles () {
58
126
return generatedFiles ;
59
127
}
60
128
61
- protected ParsedCreateWeblogicDomainJobYaml getCreateWeblogicDomainJobYaml () {
129
+ private ParsedCreateWeblogicDomainJobYaml getCreateWeblogicDomainJobYaml () {
62
130
return getGeneratedFiles ().getCreateWeblogicDomainJobYaml ();
63
131
}
64
132
65
- protected ParsedDeleteWeblogicDomainJobYaml getDeleteWeblogicDomainJobYaml () {
133
+ private ParsedDeleteWeblogicDomainJobYaml getDeleteWeblogicDomainJobYaml () {
66
134
return getGeneratedFiles ().getDeleteWeblogicDomainJobYaml ();
67
135
}
68
136
69
- protected ParsedDomainCustomResourceYaml getDomainCustomResourceYaml () {
137
+ private ParsedDomainCustomResourceYaml getDomainCustomResourceYaml () {
70
138
return getGeneratedFiles ().getDomainCustomResourceYaml ();
71
139
}
72
140
73
- protected ParsedTraefikSecurityYaml getTraefikSecurityYaml () {
141
+ private ParsedTraefikSecurityYaml getTraefikSecurityYaml () {
74
142
return getGeneratedFiles ().getTraefikSecurityYaml ();
75
143
}
76
144
77
- protected ParsedTraefikYaml getTraefikYaml () {
145
+ private ParsedTraefikYaml getTraefikYaml () {
78
146
return getGeneratedFiles ().getTraefikYaml ();
79
147
}
80
148
@@ -107,74 +175,14 @@ protected ParsedWeblogicDomainPersistentVolumeYaml getWeblogicDomainPersistentVo
107
175
return getGeneratedFiles ().getWeblogicDomainPersistentVolumeYaml ();
108
176
}
109
177
110
- protected static void setup (CreateDomainInputs val ) throws Exception {
111
- inputs = val ;
112
- generatedFiles = GeneratedDomainYamlFiles .generateDomainYamlFiles (getInputs ());
113
- }
114
-
115
- @ AfterClass
116
- public static void tearDown () throws Exception {
117
- if (generatedFiles != null ) {
118
- generatedFiles .remove ();
119
- }
120
- }
121
-
122
- @ Test
123
- public void generatedCorrect_weblogicDomainInputsYaml () throws Exception {
124
- assertThat (
125
- readInputsYamlFile (generatedFiles .getDomainFiles ().getCreateWeblogicDomainInputsYamlPath ()),
126
- yamlEqualTo (readInputsYamlFile (generatedFiles .getInputsYamlPath ())));
127
- }
128
-
129
- @ Test
130
- public void createWeblogicDomainJobYaml_hasCorrectNumberOfObjects () throws Exception {
131
- assertThat (
132
- getCreateWeblogicDomainJobYaml ().getObjectCount (),
133
- is (getCreateWeblogicDomainJobYaml ().getExpectedObjectCount ()));
134
- }
135
-
136
- @ Test
137
- public void deleteWeblogicDomainJobYaml_hasCorrectNumberOfObjects () throws Exception {
138
- assertThat (
139
- getDeleteWeblogicDomainJobYaml ().getObjectCount (),
140
- is (getDeleteWeblogicDomainJobYaml ().getExpectedObjectCount ()));
141
- }
142
-
143
- @ Test
144
- public void domainCustomResourceYaml_hasCorrectNumberOfObjects () throws Exception {
145
- assertThat (
146
- getDomainCustomResourceYaml ().getObjectCount (),
147
- is (getDomainCustomResourceYaml ().getExpectedObjectCount ()));
148
- }
149
-
150
- @ Test
151
- public void loadBalancerSecurityYaml_hasCorrectNumberOfObjects () throws Exception {
152
- assertThat (
153
- getTraefikSecurityYaml ().getObjectCount (),
154
- is (getTraefikSecurityYaml ().getExpectedObjectCount ()));
155
- }
156
-
157
- @ Test
158
- public void loadBalancerYaml_hasCorrectNumberOfObjects () throws Exception {
159
- assertThat (getTraefikYaml ().getObjectCount (), is (getTraefikYaml ().getExpectedObjectCount ()));
160
- }
161
-
162
- @ Test
163
- public void weblogicDomainPersistentVolumeClaimYaml_hasCorrectNumberOfObjects () throws Exception {
164
- assertThat (
165
- getWeblogicDomainPersistentVolumeClaimYaml ().getObjectCount (),
166
- is (getWeblogicDomainPersistentVolumeClaimYaml ().getExpectedObjectCount ()));
167
- }
168
-
169
- @ Test
170
- public void weblogicDomainPersistentVolumeYaml_hasCorrectNumberOfObjects () throws Exception {
171
- assertThat (
172
- getWeblogicDomainPersistentVolumeYaml ().getObjectCount (),
173
- is (getWeblogicDomainPersistentVolumeYaml ().getExpectedObjectCount ()));
178
+ protected static void setup (DomainYamlFactory factory , DomainValues values ) throws Exception {
179
+ CreateDomainGeneratedFilesBaseTest .factory = factory ;
180
+ inputs = values ;
181
+ generatedFiles = factory .generate (values );
174
182
}
175
183
176
184
@ Test
177
- public void generatesCorrect_createWeblogicDomainJob () throws Exception {
185
+ public void generatesCorrect_createWeblogicDomainJob () {
178
186
assertThat (
179
187
getActualCreateWeblogicDomainJob (), yamlEqualTo (getExpectedCreateWeblogicDomainJob ()));
180
188
}
@@ -407,7 +415,7 @@ public void generatesCorrect_domain() throws Exception {
407
415
assertThat (getActualDomain (), yamlEqualTo (getExpectedDomain ()));
408
416
}
409
417
410
- protected Domain getActualDomain () {
418
+ private Domain getActualDomain () {
411
419
return getDomainCustomResourceYaml ().getDomain ();
412
420
}
413
421
0 commit comments