generated from quarkiverse/quarkiverse-template
-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: status detection in non-CR resources
Fixes #673
- Loading branch information
Showing
4 changed files
with
99 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
common-deployment/src/test/java/io/quarkiverse/operatorsdk/common/ClassUtilsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package io.quarkiverse.operatorsdk.common; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import io.fabric8.kubernetes.api.model.HasMetadata; | ||
import io.fabric8.kubernetes.api.model.ObjectMeta; | ||
import io.fabric8.kubernetes.api.model.certificates.v1.CertificateSigningRequest; | ||
import io.quarkus.test.common.TestClassIndexer; | ||
|
||
public class ClassUtilsTest { | ||
|
||
@Test | ||
void canFindStatusDirectly() { | ||
final var index = TestClassIndexer.readIndex(CertificateSigningRequest.class); | ||
final var info = index.getClassByName(CertificateSigningRequest.class); | ||
assertTrue(ClassUtils.hasField(index, info, "status")); | ||
} | ||
|
||
@Test | ||
void canFindStatusInHierachy() { | ||
final var index = TestClassIndexer.readIndex(Child.class); | ||
final var info = index.getClassByName(Child.class); | ||
assertTrue(ClassUtils.hasField(index, info, "status")); | ||
} | ||
|
||
@Test | ||
void shouldNotFindNonExistingField() { | ||
final var index = TestClassIndexer.readIndex(Child.class); | ||
final var info = index.getClassByName(Child.class); | ||
assertFalse(ClassUtils.hasField(index, info, "foo")); | ||
} | ||
|
||
static abstract class Parent implements HasMetadata { | ||
private Object status; | ||
} | ||
|
||
static class Child extends Parent { | ||
|
||
@Override | ||
public ObjectMeta getMetadata() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void setMetadata(ObjectMeta objectMeta) { | ||
|
||
} | ||
|
||
@Override | ||
public void setApiVersion(String s) { | ||
|
||
} | ||
} | ||
} |