View Javadoc
1   /*
2   * Copyright 2018-2026 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.bremersee.geojson.model;
18  
19  import java.math.BigDecimal;
20  import java.util.Arrays;
21  import java.util.Collections;
22  import org.assertj.core.api.SoftAssertions;
23  import org.assertj.core.api.junit.jupiter.SoftAssertionsExtension;
24  import org.junit.jupiter.api.Test;
25  import org.junit.jupiter.api.extension.ExtendWith;
26  
27  /**
28   * The bounding box test.
29   *
30   * @author Christian Bremer
31   */
32  @ExtendWith(SoftAssertionsExtension.class)
33  class BoundingBoxTest {
34  
35    /**
36     * Test model.
37     *
38     * @param softly the soft assertions
39     */
40    @Test
41    void testModel(SoftAssertions softly) {
42      BoundingBox model = new BoundingBox();
43      softly.assertThat(model).isNotEqualTo(null);
44      softly.assertThat(model).isNotEqualTo(new Object());
45      softly.assertThat(model).isEqualTo(model);
46      softly.assertThat(model).isEqualTo(new BoundingBox());
47      softly.assertThat(model.toString()).hasSizeGreaterThan(0);
48  
49      BigDecimal value = new BigDecimal("123.4");
50      model = new BoundingBox(Collections.singleton(value));
51      softly.assertThat(model).isNotEqualTo(null);
52      softly.assertThat(model).isNotEqualTo(new Object());
53      softly.assertThat(model).isEqualTo(model);
54      softly.assertThat(model).isEqualTo(new BoundingBox(Collections.singleton(value)));
55      softly.assertThat(model.toString()).contains(value.toString());
56  
57      softly.assertThat(model.toDoubleArray()).isNull();
58  
59      double[] values = new double[]{0., 0., 1., 1.};
60      model = new BoundingBox(Arrays.stream(values)
61          .mapToObj(BigDecimal::valueOf)
62          .toList());
63      softly.assertThat(model.toDoubleArray()).containsExactly(values);
64    }
65  
66  }