|
26 | 26 | import org.freedesktop.dbus.exceptions.DBusException; |
27 | 27 | import org.freedesktop.dbus.exceptions.DBusExecutionException; |
28 | 28 | import org.freedesktop.dbus.test.collections.empty.structs.ArrayStructIntStruct; |
29 | | -import org.freedesktop.dbus.test.collections.empty.structs.ArrayStructPrimative; |
| 29 | +import org.freedesktop.dbus.test.collections.empty.structs.ArrayStructPrimitive; |
30 | 30 | import org.freedesktop.dbus.test.collections.empty.structs.DeepArrayStruct; |
31 | 31 | import org.freedesktop.dbus.test.collections.empty.structs.DeepListStruct; |
32 | 32 | import org.freedesktop.dbus.test.collections.empty.structs.DeepMapStruct; |
33 | 33 | import org.freedesktop.dbus.test.collections.empty.structs.IEmptyCollectionStruct; |
34 | 34 | import org.freedesktop.dbus.test.collections.empty.structs.ListMapStruct; |
35 | | -import org.freedesktop.dbus.test.collections.empty.structs.ListStructPrimative; |
| 35 | +import org.freedesktop.dbus.test.collections.empty.structs.ListStructPrimitive; |
36 | 36 | import org.freedesktop.dbus.test.collections.empty.structs.ListStructStruct; |
37 | 37 | import org.freedesktop.dbus.test.collections.empty.structs.MapArrayStruct; |
38 | 38 | import org.freedesktop.dbus.test.collections.empty.structs.MapStructIntStruct; |
39 | | -import org.freedesktop.dbus.test.collections.empty.structs.MapStructPrimative; |
| 39 | +import org.freedesktop.dbus.test.collections.empty.structs.MapStructPrimitive; |
40 | 40 | import org.freedesktop.dbus.test.helper.structs.IntStruct; |
41 | 41 | import org.junit.jupiter.api.AfterEach; |
42 | 42 | import org.junit.jupiter.api.BeforeEach; |
|
45 | 45 | import org.junit.jupiter.params.provider.Arguments; |
46 | 46 | import org.junit.jupiter.params.provider.MethodSource; |
47 | 47 |
|
| 48 | +/** |
| 49 | + * |
| 50 | + * The test structure is a bit of a complex constructions. However the goal is very simple |
| 51 | + * |
| 52 | + * The class tests all structs implementing IEmptyCollectionStruct |
| 53 | + * |
| 54 | + * There are two tests: |
| 55 | + * |
| 56 | + * Empty test: |
| 57 | + * |
| 58 | + * The test creates an empty object with emptyFactory function and the testString and sends the object to the {@link ISampleCollectionInterface}. |
| 59 | + * This interface returns the {@link IEmptyCollectionStruct#getValidationValue()} that value can be |
| 60 | + * used to determine whether (de)serialization of object with an empty collection is executed correctly. |
| 61 | + * |
| 62 | + * Non Empty test: |
| 63 | + * |
| 64 | + * The test creates an non empty object with nonEmptyFactory function and the testString and sends the object to the {@link ISampleCollectionInterface}. |
| 65 | + * This interface returns the {@link IEmptyCollectionStruct#getStringTestValue()} that value can be |
| 66 | + * used to determine whether (de)serialization of non empty collection is executed correctly. |
| 67 | + * |
| 68 | + */ |
48 | 69 | class TestEmptyCollections { |
49 | 70 |
|
50 | 71 | private DBusConnection serverconn; |
@@ -117,24 +138,32 @@ <T extends IEmptyCollectionStruct<?>> void testNonEmpty(ArgumentObj<T> arguments |
117 | 138 | assertEquals(validationValue, result); |
118 | 139 | } |
119 | 140 |
|
| 141 | + /** |
| 142 | + * List of arguments for each scenario: |
| 143 | + * 1: Interface function to use for to test this struct |
| 144 | + * 2: Factory to create an empty structure |
| 145 | + * 3: Factory to create an non empty structure |
| 146 | + * 4: Name, which is also used for validating empty collections |
| 147 | + * 5: Expected to string value for non empty collection test |
| 148 | + */ |
120 | 149 | static Stream<Arguments> scenarios() { |
121 | 150 | return Stream.of( |
122 | | - Arguments.of(new ArgumentObj<>(ISampleCollectionInterface::testListPrimative, |
123 | | - s -> new ListStructPrimative(Collections.emptyList(), s), |
124 | | - s -> new ListStructPrimative(Arrays.asList(1, 2), s)), "ListPrimative", "1,2"), |
| 151 | + Arguments.of(new ArgumentObj<>(ISampleCollectionInterface::testListPrimitive, |
| 152 | + s -> new ListStructPrimitive(Collections.emptyList(), s), |
| 153 | + s -> new ListStructPrimitive(Arrays.asList(1, 2), s)), "ListPrimative", "1,2"), |
125 | 154 | Arguments.of(new ArgumentObj<>(ISampleCollectionInterface::testListIntStruct, |
126 | 155 | s -> new ListStructStruct(Collections.emptyList(), s), |
127 | 156 | s -> new ListStructStruct(Arrays.asList(new IntStruct(5, 6)), s)), "ListStruct", "(5,6)"), |
128 | | - Arguments.of(new ArgumentObj<>(ISampleCollectionInterface::testArrayPrimative, |
129 | | - s -> new ArrayStructPrimative(new int[0], s), |
130 | | - s -> new ArrayStructPrimative(new int[] {4,5}, s)), "ArrayPrimative", "4,5"), |
| 157 | + Arguments.of(new ArgumentObj<>(ISampleCollectionInterface::testArrayPrimitive, |
| 158 | + s -> new ArrayStructPrimitive(new int[0], s), |
| 159 | + s -> new ArrayStructPrimitive(new int[] {4,5}, s)), "ArrayPrimative", "4,5"), |
131 | 160 | Arguments.of(new ArgumentObj<>(ISampleCollectionInterface::testArrayIntStruct, |
132 | 161 | s -> new ArrayStructIntStruct(new IntStruct[0], s), |
133 | 162 | s -> new ArrayStructIntStruct(new IntStruct[] { new IntStruct(9, 12)}, s)), |
134 | 163 | "ArrayIntStruct", "(9,12)"), |
135 | | - Arguments.of(new ArgumentObj<>(ISampleCollectionInterface::testMapPrimative, |
136 | | - s -> new MapStructPrimative(Collections.emptyMap(), s), |
137 | | - s -> new MapStructPrimative(getIntHashMap(), s)), "MapPrimative", "{test:8}"), |
| 164 | + Arguments.of(new ArgumentObj<>(ISampleCollectionInterface::testMapPrimitive, |
| 165 | + s -> new MapStructPrimitive(Collections.emptyMap(), s), |
| 166 | + s -> new MapStructPrimitive(getIntHashMap(), s)), "MapPrimative", "{test:8}"), |
138 | 167 | Arguments.of(new ArgumentObj<>(ISampleCollectionInterface::testMapIntStruct, |
139 | 168 | s -> new MapStructIntStruct(Collections.emptyMap(), s), |
140 | 169 | s -> new MapStructIntStruct(getIntStructHashMap(), s)), "MapIntStruct", "{other:(12,17)}"), |
@@ -209,8 +238,6 @@ public ArgumentObj(BiFunction<ISampleCollectionInterface, T, String> function, F |
209 | 238 | this.function = function; |
210 | 239 | this.factoryEmpty = factoryEmpty; |
211 | 240 | this.factoryNonEmpty = factoryNonEmpty; |
212 | | - |
213 | 241 | } |
214 | 242 | } |
215 | | - |
216 | 243 | } |
0 commit comments