@@ -37,46 +37,32 @@ using namespace eprosima;
3737 *
3838 * POSITIVE CASES:
3939 * - 1 address
40- * - 1 connection N addresses
41- * - N connections 1 addresses
40+ * - N addresses
4241 *
4342 * NEGATIVE CASES:
4443 * - not list format
45- * - incorrect guid format
46- * - not list of addresses
4744 * - incorrect address format
4845 */
4946TEST (YamlGetDiscoveryServerParticipantConfigurationTest, get_participant_connection_addresses)
5047{
5148 ddsrouter::core::types::ParticipantKind kind = ddsrouter::core::types::ParticipantKind::discovery_server;
5249 ddspipe::core::types::ParticipantId id = ddspipe::core::testing::random_participant_id ();
53- ddspipe::core::types::GuidPrefix guid_prefix = ddspipe::core::testing::random_guid_prefix ();
5450
5551 // 1 address
5652 {
5753 Yaml yml;
5854 Yaml yml_participant;
5955 Yaml yml_connection_addresses;
60- Yaml yml_connection_address;
61- Yaml yml_addresses;
6256 Yaml yml_address;
6357
6458 // Add required fields
6559 ddspipe::yaml::testing::participantid_to_yaml (yml_participant, id);
6660 ddsrouter::yaml::testing::participantkind_to_yaml (yml_participant, kind);
67- ddspipe::yaml::testing::discovery_server_guid_prefix_to_yaml (yml_participant, guid_prefix);
6861
6962 // Add address
7063 ddspipe::participants::types::Address address = ddspipe::participants::testing::random_address ();
7164 ddspipe::yaml::testing::address_to_yaml (yml_address, address);
72- yml_addresses.push_back (yml_address);
73- yml_connection_address[ddspipe::yaml::COLLECTION_ADDRESSES_TAG ] = yml_addresses;
74-
75- // Add server guid
76- ddspipe::core::types::GuidPrefix connection_guid = ddspipe::core::testing::random_guid_prefix ();
77- ddspipe::yaml::testing::discovery_server_guid_prefix_to_yaml (yml_connection_address, connection_guid);
78-
79- yml_connection_addresses.push_back (yml_connection_address);
65+ yml_connection_addresses.push_back (yml_address);
8066
8167 yml_participant[ddspipe::yaml::CONNECTION_ADDRESSES_TAG ] = yml_connection_addresses;
8268 yml[" participant" ] = yml_participant;
@@ -89,22 +75,18 @@ TEST(YamlGetDiscoveryServerParticipantConfigurationTest, get_participant_connect
8975
9076 // Check result
9177 ASSERT_EQ (result.connection_addresses .size (), 1u );
92- ASSERT_EQ (result.connection_addresses .begin ()->addresses ().size (), 1u );
93- ASSERT_EQ (address, *result.connection_addresses .begin ()->addresses ().begin ());
78+ ASSERT_EQ (address, *result.connection_addresses .begin ());
9479 }
9580
96- // 1 connection N addresses
81+ // N addresses
9782 {
9883 Yaml yml;
9984 Yaml yml_participant;
10085 Yaml yml_connection_addresses;
101- Yaml yml_connection_address;
102- Yaml yml_addresses;
10386
10487 // Add required fields
10588 ddspipe::yaml::testing::participantid_to_yaml (yml_participant, id);
10689 ddsrouter::yaml::testing::participantkind_to_yaml (yml_participant, kind);
107- ddspipe::yaml::testing::discovery_server_guid_prefix_to_yaml (yml_participant, guid_prefix);
10890
10991 // Add addresses
11092 std::vector<ddspipe::participants::types::Address> addresses;
@@ -117,15 +99,8 @@ TEST(YamlGetDiscoveryServerParticipantConfigurationTest, get_participant_connect
11799 // Add it to yaml
118100 Yaml yml_address;
119101 ddspipe::yaml::testing::address_to_yaml (yml_address, address);
120- yml_addresses .push_back (yml_address);
102+ yml_connection_addresses .push_back (yml_address);
121103 }
122- yml_connection_address[ddspipe::yaml::COLLECTION_ADDRESSES_TAG ] = yml_addresses;
123-
124- // Add server guid
125- ddspipe::core::types::GuidPrefix connection_guid = ddspipe::core::testing::random_guid_prefix ();
126- ddspipe::yaml::testing::discovery_server_guid_prefix_to_yaml (yml_connection_address, connection_guid);
127-
128- yml_connection_addresses.push_back (yml_connection_address);
129104
130105 yml_participant[ddspipe::yaml::CONNECTION_ADDRESSES_TAG ] = yml_connection_addresses;
131106 yml[" participant" ] = yml_participant;
@@ -137,141 +112,36 @@ TEST(YamlGetDiscoveryServerParticipantConfigurationTest, get_participant_connect
137112 ddspipe::yaml::YamlReaderVersion::LATEST );
138113
139114 // Check result
140- ASSERT_EQ (result.connection_addresses .size (), 1u );
141- ASSERT_EQ (addresses.size (), result.connection_addresses .begin ()->addresses ().size ());
115+ ASSERT_EQ (addresses.size (), result.connection_addresses .size ()) << yml;
142116 // Check every address is inside connection addresses of the configuration
143117 for (ddspipe::participants::types::Address address : addresses)
144118 {
145- // ATTENTION: this previous declaration is needed as listening_addresses () does not return a reference
119+ // ATTENTION: this previous declaration is needed as connection_addresses () does not return a reference
146120 std::set<ddspipe::participants::types::Address> addresses_result =
147- result.connection_addresses . begin ()-> addresses () ;
121+ result.connection_addresses ;
148122 ASSERT_NE (
149123 addresses_result.find (address),
150124 addresses_result.end ());
151125 }
152126 }
153127
154- // N connections 1 address
155- {
156- Yaml yml;
157- Yaml yml_participant;
158- Yaml yml_connection_addresses;
159-
160- // Add required fields
161- ddspipe::yaml::testing::participantid_to_yaml (yml_participant, id);
162- ddsrouter::yaml::testing::participantkind_to_yaml (yml_participant, kind);
163- ddspipe::yaml::testing::discovery_server_guid_prefix_to_yaml (yml_participant, guid_prefix);
164-
165- std::vector<ddspipe::core::types::GuidPrefix> connection_guids;
166-
167- // Add connections
168- for (uint32_t i = 0 ; i < ddsrouter::yaml::testing::TEST_ITERATIONS ; i++)
169- {
170- Yaml yml_connection_address;
171- Yaml yml_addresses;
172-
173- // Add address
174- ddspipe::participants::types::Address address = ddspipe::participants::testing::random_address (i);
175-
176- // Add it to yaml
177- Yaml yml_address;
178- ddspipe::yaml::testing::address_to_yaml (yml_address, address);
179- yml_addresses.push_back (yml_address);
180- yml_connection_address[ddspipe::yaml::COLLECTION_ADDRESSES_TAG ] = yml_addresses;
181-
182- // Add server guid
183- ddspipe::core::types::GuidPrefix connection_guid = ddspipe::core::testing::random_guid_prefix (i);
184- connection_guids.push_back (connection_guid);
185- ddspipe::yaml::testing::discovery_server_guid_prefix_to_yaml (yml_connection_address, connection_guid);
186-
187- yml_connection_addresses.push_back (yml_connection_address);
188- }
189-
190-
191- yml_participant[ddspipe::yaml::CONNECTION_ADDRESSES_TAG ] = yml_connection_addresses;
192- yml[" participant" ] = yml_participant;
193-
194- // Get configuration object from yaml
195- ddspipe::participants::DiscoveryServerParticipantConfiguration result =
196- ddspipe::yaml::YamlReader::get<ddspipe::participants::DiscoveryServerParticipantConfiguration>(yml,
197- " participant" ,
198- ddspipe::yaml::YamlReaderVersion::LATEST );
199-
200- // Check result
201- ASSERT_EQ (connection_guids.size (), result.connection_addresses .size ());
202- // Check that every connection has a correct number of addresses and a guid given
203- for (ddspipe::participants::types::DiscoveryServerConnectionAddress connection : result.connection_addresses )
204- {
205- ASSERT_EQ (connection.addresses ().size (), 1u );
206- }
207- }
208-
209128 // not list format
210129 {
211130 Yaml yml;
212131 Yaml yml_participant;
213132 Yaml yml_connection_addresses;
214- Yaml yml_connection_address;
215- Yaml yml_addresses;
216133 Yaml yml_address;
217134
218135 // Add required fields
219136 ddspipe::yaml::testing::participantid_to_yaml (yml_participant, id);
220137 ddsrouter::yaml::testing::participantkind_to_yaml (yml_participant, kind);
221- ddspipe::yaml::testing::discovery_server_guid_prefix_to_yaml (yml_participant, guid_prefix);
222138
223139 // Add address
224140 ddspipe::participants::types::Address address = ddspipe::participants::testing::random_address ();
225141 ddspipe::yaml::testing::address_to_yaml (yml_address, address);
226- yml_addresses.push_back (yml_address);
227- yml_connection_address[ddspipe::yaml::COLLECTION_ADDRESSES_TAG ] = yml_addresses;
228-
229- // Add server guid
230- ddspipe::core::types::GuidPrefix connection_guid = ddspipe::core::testing::random_guid_prefix ();
231- ddspipe::yaml::testing::discovery_server_guid_prefix_to_yaml (yml_connection_address, connection_guid);
232142
233143 // Add connection wrongly
234- yml_connection_addresses[" address1" ] = yml_connection_address;
235-
236- yml_participant[ddspipe::yaml::CONNECTION_ADDRESSES_TAG ] = yml_connection_addresses;
237- yml[" participant" ] = yml_participant;
238-
239- // Get configuration object from yaml
240- ASSERT_THROW (
241- ddspipe::participants::DiscoveryServerParticipantConfiguration result =
242- ddspipe::yaml::YamlReader::get<ddspipe::participants::DiscoveryServerParticipantConfiguration>(yml,
243- " participant" , ddspipe::yaml::YamlReaderVersion::LATEST ),
244- eprosima::utils::ConfigurationException);
245- }
246-
247- // not list of addresses
248- {
249- Yaml yml;
250- Yaml yml_participant;
251- Yaml yml_connection_addresses;
252- Yaml yml_connection_address;
253- Yaml yml_addresses;
254- Yaml yml_address;
255-
256- // Add required fields
257- ddspipe::yaml::testing::participantid_to_yaml (yml_participant, id);
258- ddsrouter::yaml::testing::participantkind_to_yaml (yml_participant, kind);
259- ddspipe::yaml::testing::discovery_server_guid_prefix_to_yaml (yml_participant, guid_prefix);
260-
261- // Add address
262- ddspipe::participants::types::Address address = ddspipe::participants::testing::random_address ();
263- ddspipe::yaml::testing::address_to_yaml (yml_address, address);
264- // Add address wrongly
265- yml_addresses[" address1" ] = yml_address;
266-
267- yml_connection_address[ddspipe::yaml::COLLECTION_ADDRESSES_TAG ] = yml_addresses;
268-
269- // Add server guid
270- ddspipe::core::types::GuidPrefix connection_guid = ddspipe::core::testing::random_guid_prefix ();
271- ddspipe::yaml::testing::discovery_server_guid_prefix_to_yaml (yml_connection_address, connection_guid);
272-
273- // Add connection
274- yml_connection_addresses.push_back (yml_connection_address);
144+ yml_connection_addresses[" address1" ] = yml_address;
275145
276146 yml_participant[ddspipe::yaml::CONNECTION_ADDRESSES_TAG ] = yml_connection_addresses;
277147 yml[" participant" ] = yml_participant;
@@ -289,26 +159,14 @@ TEST(YamlGetDiscoveryServerParticipantConfigurationTest, get_participant_connect
289159 Yaml yml;
290160 Yaml yml_participant;
291161 Yaml yml_connection_addresses;
292- Yaml yml_connection_address;
293- Yaml yml_addresses;
294162 Yaml yml_address;
295163
296164 // Add required fields
297165 ddspipe::yaml::testing::participantid_to_yaml (yml_participant, id);
298166 ddsrouter::yaml::testing::participantkind_to_yaml (yml_participant, kind);
299- ddspipe::yaml::testing::discovery_server_guid_prefix_to_yaml (yml_participant, guid_prefix);
300-
301- // Add empty address
302- yml_addresses.push_back (yml_address);
303- yml_connection_address[ddspipe::yaml::COLLECTION_ADDRESSES_TAG ] = yml_addresses;
304-
305- // Add server guid
306- ddspipe::core::types::GuidPrefix connection_guid = ddspipe::core::testing::random_guid_prefix ();
307- ddspipe::yaml::testing::discovery_server_guid_prefix_to_yaml (yml_connection_address, connection_guid);
308-
309- // Add connection wrongly
310- yml_connection_addresses.push_back (yml_connection_address);
311167
168+ // Add connection wrongly (empty yaml = incorrect address)
169+ yml_connection_addresses.push_back (yml_address);
312170 yml_participant[ddspipe::yaml::CONNECTION_ADDRESSES_TAG ] = yml_connection_addresses;
313171 yml[" participant" ] = yml_participant;
314172
0 commit comments