You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

TestPresetGeometries.java 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * ====================================================================
  3. * Licensed to the Apache Software Foundation (ASF) under one or more
  4. * contributor license agreements. See the NOTICE file distributed with
  5. * this work for additional information regarding copyright ownership.
  6. * The ASF licenses this file to You under the Apache License, Version 2.0
  7. * (the "License"); you may not use this file except in compliance with
  8. * the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. * ====================================================================
  18. */
  19. package org.apache.poi.sl.draw.geom;
  20. import static org.junit.jupiter.api.Assertions.assertEquals;
  21. import static org.junit.jupiter.api.Assertions.assertNotNull;
  22. import static org.junit.jupiter.api.Assertions.assertSame;
  23. import java.awt.geom.Path2D;
  24. import java.awt.geom.Rectangle2D;
  25. import java.util.stream.StreamSupport;
  26. import org.junit.jupiter.api.Assertions;
  27. import org.junit.jupiter.api.Test;
  28. class TestPresetGeometries {
  29. @Test
  30. void testRead(){
  31. PresetGeometries shapes = PresetGeometries.getInstance();
  32. assertEquals(187, shapes.size());
  33. assertEquals(0x4533584F, shapes.hashCode());
  34. for(String name : shapes.keySet()) {
  35. CustomGeometry geom = shapes.get(name);
  36. Context ctx = new Context(geom, new Rectangle2D.Double(0, 0, 100, 100), presetName -> null);
  37. for(PathIf p : geom){
  38. Path2D path = p.getPath(ctx);
  39. assertNotNull(path);
  40. }
  41. StreamSupport.stream(geom.spliterator(), true)
  42. .map(p -> p.getPath(ctx))
  43. .forEach(Assertions::assertNotNull);
  44. }
  45. // we get the same instance on further calls
  46. assertSame(shapes, PresetGeometries.getInstance());
  47. }
  48. }