1. Project Clover database Wed Nov 12 2025 05:07:35 UTC
  2. Package guru.mikelue.foxglove.jdbc

File ReferenceSettingStepImplTest.java

 

Code metrics

2
9
4
1
82
54
5
0.56
2.25
4
1.25

Classes

Class Line # Actions
ReferenceSettingStepImplTest 15 9 0% 5 0
1.0100%
 

Contributing tests

This file is covered by 4 tests. .

Source view

1    package guru.mikelue.foxglove.jdbc;
2   
3    import java.util.stream.IntStream;
4   
5    import org.apache.commons.lang3.mutable.MutableObject;
6    import org.junit.jupiter.api.AfterEach;
7    import org.junit.jupiter.api.BeforeEach;
8    import org.junit.jupiter.params.ParameterizedTest;
9    import org.junit.jupiter.params.provider.CsvSource;
10   
11    import guru.mikelue.misc.testlib.AbstractTestBase;
12   
13    import static org.assertj.core.api.Assertions.assertThat;
14   
 
15    public class ReferenceSettingStepImplTest extends AbstractTestBase {
 
16  4 toggle public ReferenceSettingStepImplTest() {}
17   
 
18  4 toggle @BeforeEach
19    void setup() {}
20   
 
21  4 toggle @AfterEach
22    void tearDown() {}
23   
24    /**
25    * Tests the generator by cardinality setting.
26    */
 
27  4 toggle @ParameterizedTest
28    @CsvSource({
29    "4,1,1",
30    "5,1,3",
31    "4,3,3",
32    "5,3,10",
33    })
34    void cardinality(
35    int numberOfParentRows,
36    int minCardinality, int maxCardinality
37    ) {
38    /*
39    * Prepares tested step
40    */
41  4 var cardinalityInfoHolder = new MutableObject<CardinalityInfo<?>>();
42   
43  4 var testedStep = new ReferenceSettingStepImpl<String>(
44    JdbcTableFacet.builder("sample_child_table"),
45    cardinalityInfoHolder::setValue
46    );
47    // :~)
48   
49  4 var parent = JdbcTableFacet.builder("sample_parent_table")
50    .build();
51  4 testedStep.parent(
52    parent, "pt_source"
53    )
54    .cardinality(minCardinality, maxCardinality);
55   
56    /*
57    * Prepares data of parent
58    */
59  4 TombTestUtils.setupTomb(
60    parent.getValueTomb(), "pt_source",
61    IntStream.rangeClosed(1001, 1001 + numberOfParentRows - 1)
62    .boxed()
63    .toArray()
64    );
65    // :~)
66   
67  4 var testedInfo = cardinalityInfoHolder.get();
68   
69    /*
70    * Asserts the expected rows of children
71    */
72  4 if (minCardinality == maxCardinality) {
73  2 assertThat(testedInfo.getNumberOfRows())
74    .isEqualTo(numberOfParentRows * minCardinality);
75    } else {
76  2 assertThat(testedInfo.getNumberOfRows())
77    .isGreaterThanOrEqualTo(numberOfParentRows * minCardinality)
78    .isLessThanOrEqualTo(numberOfParentRows * maxCardinality);
79    }
80    // :~)
81    }
82    }