Skip to content

Commit 0c7e3a9

Browse files
committed
Update unit tests
1 parent 1a8d81f commit 0c7e3a9

File tree

3 files changed

+28
-6
lines changed

3 files changed

+28
-6
lines changed

model/src/main/java/oracle/kubernetes/weblogic/domain/v2/DomainSpec.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,17 @@ public class DomainSpec extends BaseConfiguration {
218218
@Description("Configuration for the clusters")
219219
protected Map<String, Cluster> clusters = new HashMap<>();
220220

221+
/**
222+
* Adds a Cluster to the DomainSpec
223+
*
224+
* @param cluster
225+
* @return
226+
*/
227+
public DomainSpec withCluster(Cluster cluster) {
228+
clusters.put(cluster.getClusterName(), cluster);
229+
return this;
230+
}
231+
221232
public AdminServer getOrCreateAdminServer(String adminServerName) {
222233
if (adminServer != null) return adminServer;
223234

operator/src/test/java/oracle/kubernetes/operator/DomainPresenceTest.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
package oracle.kubernetes.operator;
66

77
import static oracle.kubernetes.operator.KubernetesConstants.DOMAIN_CONFIG_MAP_NAME;
8+
import static oracle.kubernetes.operator.KubernetesConstants.INTROSPECTOR_CONFIG_MAP_NAME_SUFFIX;
89
import static oracle.kubernetes.operator.LabelConstants.CHANNELNAME_LABEL;
910
import static oracle.kubernetes.operator.LabelConstants.CREATEDBYOPERATOR_LABEL;
1011
import static oracle.kubernetes.operator.LabelConstants.DOMAINUID_LABEL;
@@ -358,6 +359,11 @@ private void createCannedListDomainResponses() {
358359
.withName(DOMAIN_CONFIG_MAP_NAME)
359360
.ignoringBody()
360361
.returning(domainConfigMap);
362+
testSupport
363+
.createCannedResponse("readConfigMap")
364+
.withNamespace(NS)
365+
.withName(UID + INTROSPECTOR_CONFIG_MAP_NAME_SUFFIX)
366+
.returning(createEmptyConfigMap());
361367
}
362368

363369
private DomainList createEmptyDomainList() {
@@ -397,7 +403,7 @@ private V1PersistentVolumeClaimList createEmptyPersistentVolumeClaimList() {
397403
}
398404

399405
@SuppressWarnings("unchecked")
400-
// @Test
406+
@Test
401407
public void whenStrandedResourcesExist_removeThem() {
402408
addServiceResource(UID, NS, "admin");
403409
addServiceResource(UID, NS, "ms1", "channel1");

operator/src/test/java/oracle/kubernetes/operator/helpers/DomainIntrospectorJobTest.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,13 @@
2929
import oracle.kubernetes.operator.VersionConstants;
3030
import oracle.kubernetes.operator.work.FiberTestSupport;
3131
import oracle.kubernetes.operator.work.TerminalStep;
32+
import oracle.kubernetes.weblogic.domain.v2.Cluster;
3233
import oracle.kubernetes.weblogic.domain.v2.Domain;
3334
import oracle.kubernetes.weblogic.domain.v2.DomainSpec;
3435
import org.hamcrest.Matcher;
3536
import org.junit.After;
3637
import org.junit.Before;
38+
import org.junit.Test;
3739

3840
@SuppressWarnings({"ConstantConditions, unchecked", "SameParameterValue", "deprecation"})
3941
public class DomainIntrospectorJobTest {
@@ -155,6 +157,8 @@ private DomainPresenceInfo createDomainPresenceInfo(Domain domain) {
155157

156158
@SuppressWarnings("deprecation")
157159
private DomainSpec createDomainSpec() {
160+
Cluster cluster = new Cluster().withClusterName("cluster-1");
161+
cluster.setReplicas(1);
158162
DomainSpec spec =
159163
new DomainSpec()
160164
.withDomainName(DOMAIN_NAME)
@@ -163,6 +167,7 @@ private DomainSpec createDomainSpec() {
163167
.withAsPort(ADMIN_PORT)
164168
.withAdminSecret(new V1SecretReference().name(ADMIN_SECRET_NAME))
165169
.withConfigOverrides(OVERRIDES_CM)
170+
.withCluster(cluster)
166171
.withImage(LATEST_IMAGE);
167172

168173
List<String> overrideSecrets = new ArrayList();
@@ -181,7 +186,7 @@ String getJobDeletedMessageKey() {
181186
return JOB_DELETED;
182187
}
183188

184-
// @Test
189+
@Test
185190
public void whenNoJob_createIt() {
186191
expectCreateJob(jobWithName(getJobName())).returning(createJobModel());
187192
expectListPods(NS).returning(createListPods());
@@ -200,7 +205,7 @@ public void whenNoJob_createIt() {
200205
testSupport.verifyAllDefinedResponsesInvoked();
201206
}
202207

203-
// @Test
208+
@Test
204209
public void whenNoJob_retryOnFailure() {
205210
testSupport.addRetryStrategy(retryStrategy);
206211
expectCreateJob(jobWithName(getJobName())).failingWithStatus(401);
@@ -213,12 +218,12 @@ public void whenNoJob_retryOnFailure() {
213218
testSupport.verifyAllDefinedResponsesInvoked();
214219
}
215220

216-
// @Test
221+
@Test
217222
public void whenJobCreated_specHasOneContainer() {
218223
assertThat(getCreatedJob().getSpec().getTemplate().getSpec().getContainers(), hasSize(1));
219224
}
220225

221-
// @Test
226+
@Test
222227
public void whenJobCreated_containerHasExpectedVolumeMounts() {
223228
assertThat(
224229
getCreatedJobSpecContainer().getVolumeMounts(),
@@ -232,7 +237,7 @@ public void whenJobCreated_containerHasExpectedVolumeMounts() {
232237
}
233238

234239
@SuppressWarnings("unchecked")
235-
// @Test
240+
@Test
236241
public void whenJobCreated_hasPredefinedEnvVariables() {
237242
assertThat(
238243
getCreatedJobSpecContainer().getEnv(),

0 commit comments

Comments
 (0)