File tree Expand file tree Collapse file tree 2 files changed +26
-2
lines changed
main/java/io/kubernetes/client/custom
test/java/io/kubernetes/client/custom Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -86,8 +86,7 @@ public boolean equals(Object o) {
86
86
87
87
Quantity otherQuantity = (Quantity ) o ;
88
88
89
- return ObjectUtils .compare (this .number , otherQuantity .number ) == 0
90
- && Objects .equals (this .format , otherQuantity .format );
89
+ return ObjectUtils .compare (this .number , otherQuantity .number ) == 0 ;
91
90
}
92
91
93
92
public static class QuantityAdapter extends TypeAdapter <Quantity > {
Original file line number Diff line number Diff line change 16
16
import static org .junit .Assert .assertThat ;
17
17
18
18
import java .math .BigDecimal ;
19
+
20
+ import org .junit .Assert ;
19
21
import org .junit .Test ;
20
22
21
23
public class QuantityFormatterTest {
22
24
25
+ @ Test
26
+ public void testEqualsAfterSerialAndDeSerial () {
27
+ testSerialDeSerial ("0.5Gi" );
28
+ testSerialDeSerial ("0.5G" );
29
+ testSerialDeSerial ("1Gi" );
30
+ testSerialDeSerial ("1G" );
31
+ testSerialDeSerial ("500Mi" );
32
+ testSerialDeSerial ("500M" );
33
+ testSerialDeSerial ("500m" );
34
+ testSerialDeSerial ("0.5" );
35
+ testSerialDeSerial ("1" );
36
+ }
37
+
38
+ private static void testSerialDeSerial (String value ) {
39
+ Quantity quantity = Quantity .fromString (value );
40
+ // simulate the serialize-method
41
+ String suffixedString = quantity .toSuffixedString ();
42
+ // simulate the deserialize-method, @see io.kubernetes.client.custom.Quantity.QuantityAdapter
43
+ Quantity deSerial = Quantity .fromString (suffixedString );
44
+
45
+ Assert .assertEquals (quantity ,deSerial );
46
+ }
47
+
23
48
@ Test
24
49
public void testParsePlain () {
25
50
final Quantity quantity = new QuantityFormatter ().parse ("1" );
You can’t perform that action at this time.
0 commit comments