File tree Expand file tree Collapse file tree 2 files changed +6
-14
lines changed
operator-framework-core/src
main/java/io/javaoperatorsdk/operator/processing/event
test/java/io/javaoperatorsdk/operator/api/reconciler Expand file tree Collapse file tree 2 files changed +6
-14
lines changed Original file line number Diff line number Diff line change @@ -62,17 +62,9 @@ public boolean equals(Object o) {
6262 return Objects .equals (name , that .name ) && Objects .equals (namespace , that .namespace );
6363 }
6464
65- public boolean isSameResource (HasMetadata hasMetadata ) {
66- if (hasMetadata == null ) {
67- return false ;
68- }
69- final var metadata = hasMetadata .getMetadata ();
70- return isSameResource (metadata .getName (), metadata .getNamespace ());
71- }
72-
7365 /**
74- * Whether this ResourceID points to the same resource as the one identified by the specified name
75- * and namespace.
66+ * Whether this ResourceID points to the same resource as the one identified only by the specified
67+ * name and namespace.
7668 *
7769 * <p>Note that this doesn't take API version or Kind into account so this should only be used
7870 * when checking resources that are reasonably expected to be of the same type.
@@ -83,7 +75,7 @@ public boolean isSameResource(HasMetadata hasMetadata) {
8375 * specified name and namespace, {@code false} otherwise
8476 * @since 5.3.0
8577 */
86- public boolean isSameResource (String name , String namespace ) {
78+ public boolean equals (String name , String namespace ) {
8779 return Objects .equals (this .name , name ) && Objects .equals (this .namespace , namespace );
8880 }
8981
Original file line number Diff line number Diff line change @@ -95,23 +95,23 @@ void latestDistinctKeepsOnlyLatestResourceVersion() {
9595 // Find pod1 in default namespace - should have version 200
9696 final var pod1InDefault =
9797 result .stream ()
98- .filter (r -> ResourceID .fromResource (r ).isSameResource ( "pod1" , "default" ))
98+ .filter (r -> ResourceID .fromResource (r ).equals ( new ResourceID ( "pod1" , "default" ) ))
9999 .findFirst ()
100100 .orElseThrow ();
101101 assertThat (pod1InDefault .getMetadata ().getResourceVersion ()).isEqualTo ("200" );
102102
103103 // Find pod2 in default namespace - should exist
104104 HasMetadata pod2InDefault =
105105 result .stream ()
106- .filter (r -> ResourceID .fromResource (r ).isSameResource ("pod2" , "default" ))
106+ .filter (r -> ResourceID .fromResource (r ).equals ("pod2" , "default" ))
107107 .findFirst ()
108108 .orElseThrow ();
109109 assertThat (pod2InDefault .getMetadata ().getResourceVersion ()).isEqualTo ("100" );
110110
111111 // Find pod1 in other namespace - should exist
112112 HasMetadata pod1InOther =
113113 result .stream ()
114- .filter (r -> ResourceID .fromResource (r ).isSameResource ("pod1" , "other" ))
114+ .filter (r -> ResourceID .fromResource (r ).equals ("pod1" , "other" ))
115115 .findFirst ()
116116 .orElseThrow ();
117117 assertThat (pod1InOther .getMetadata ().getResourceVersion ()).isEqualTo ("50" );
You can’t perform that action at this time.
0 commit comments