@@ -280,6 +280,86 @@ public void intersectionOfUnions() {
280280 assertThat (actual .toProto ()).isEqualTo (expected );
281281 }
282282
283+ @ Test
284+ public void unionOfRules () {
285+ GcRule protoGCRule =
286+ GcRule .newBuilder ()
287+ .setUnion (
288+ Union .newBuilder ()
289+ .addRules (buildAgeRule (10 , 0 ))
290+ .addRules (buildVersionsRule (1 ))
291+ .addRules (buildAgeRule (20 , 2 )))
292+ .build ();
293+
294+ GCRules .GCRule modelGCRule =
295+ GCRULES
296+ .union ()
297+ .rule (GCRULES .maxAge (Duration .ofSeconds (10 )))
298+ .rule (GCRULES .maxVersions (1 ))
299+ .rule (GCRULES .maxAge (Duration .ofSeconds (20 , 2 )));
300+ assertThat (GCRULES .fromProto (protoGCRule )).isEqualTo (modelGCRule );
301+ }
302+
303+ @ Test
304+ public void intersectionWithFromProto () {
305+ GcRule protoGCRule =
306+ GcRule .newBuilder ()
307+ .setIntersection (
308+ Intersection .newBuilder ()
309+ .addRules (buildAgeRule (10 , 5 ))
310+ .addRules (buildVersionsRule (1 ))
311+ .addRules (buildVersionsRule (2 )))
312+ .build ();
313+
314+ GCRules .GCRule modelGCRule =
315+ GCRules .GCRULES
316+ .intersection ()
317+ .rule (GCRULES .maxAge (org .threeten .bp .Duration .ofSeconds (10 , 5 )))
318+ .rule (GCRULES .maxVersions (1 ))
319+ .rule (GCRULES .maxVersions (2 ));
320+ assertThat (GCRULES .fromProto (protoGCRule )).isEqualTo (modelGCRule );
321+ }
322+
323+ @ Test
324+ public void unionOfIntersectionFromProto () {
325+ GcRule protoGCRule =
326+ GcRule .newBuilder ()
327+ .setUnion (
328+ Union .newBuilder ()
329+ .addRules (
330+ GcRule .newBuilder ()
331+ .setIntersection (
332+ Intersection .newBuilder ()
333+ .addRules (buildVersionsRule (10 ))
334+ .addRules (buildAgeRule (2 , 4 ))
335+ .build ())
336+ .build ())
337+ .addRules (
338+ GcRule .newBuilder ()
339+ .setIntersection (
340+ Intersection .newBuilder ()
341+ .addRules (buildVersionsRule (1 ))
342+ .addRules (buildAgeRule (1 , 1 ))
343+ .build ())
344+ .build ()))
345+ .build ();
346+
347+ GCRules .GCRule modelGCRule =
348+ GCRULES
349+ .union ()
350+ .rule (
351+ GCRULES
352+ .intersection ()
353+ .rule (GCRULES .maxVersions (10 ))
354+ .rule (GCRULES .maxAge (Duration .ofSeconds (2 , 4 ))))
355+ .rule (
356+ GCRULES
357+ .intersection ()
358+ .rule (GCRULES .maxVersions (1 ))
359+ .rule (GCRULES .maxAge (Duration .ofSeconds (1 , 1 ))));
360+ assertThat (GCRules .GCRULES .fromProto (protoGCRule )).isEqualTo (modelGCRule );
361+ }
362+
283363 public static GcRule buildAgeRule (long seconds , int nanos ) {
284364 com .google .protobuf .Duration .Builder duartionBuilder =
285365 com .google .protobuf .Duration .newBuilder ();
0 commit comments