@@ -90,6 +90,37 @@ namespace CSAPItest {
9090 }
9191 }
9292
93+ ConnectedSystemsAPI::DataModels::DataStream createDataStream () {
94+ auto booleanField = ConnectedSystemsAPI::DataModels::Component::BooleanBuilder ()
95+ .withType (" Boolean" s)
96+ .withName (" Test Boolean Field" s)
97+ .withDescription (" This is a test boolean field" s)
98+ .build ();
99+
100+ auto resultSchemaPtr = std::make_unique<ConnectedSystemsAPI::DataModels::Component::DataRecord>(
101+ ConnectedSystemsAPI::DataModels::Component::DataRecordBuilder ()
102+ .withType (" DataRecord" )
103+ .addField (std::make_unique<ConnectedSystemsAPI::DataModels::Component::Boolean>(booleanField))
104+ .build ()
105+ );
106+
107+ auto observationSchemaPtr = std::make_unique<ConnectedSystemsAPI::DataModels::ObservationSchema>(
108+ ConnectedSystemsAPI::DataModels::ObservationSchemaBuilder ()
109+ .withObservationFormat (" application/om+json" s)
110+ .withResultSchema (std::move (resultSchemaPtr))
111+ .build ()
112+ );
113+
114+ auto dataStream = ConnectedSystemsAPI::DataModels::DataStreamBuilder ()
115+ .withName (" Test DataStream 001" s)
116+ .withOutputName (" test_output_001" s)
117+ .withDescription (" This is a test data stream created by CSAPI-test" s)
118+ .withSchema (std::move (observationSchemaPtr))
119+ .build ();
120+
121+ return dataStream;
122+ }
123+
93124 // Debug stuff
94125 template <typename T>
95126 void printResponse (const ConnectedSystemsAPI::APIResponse<T>& response) {
@@ -223,37 +254,17 @@ namespace CSAPItest {
223254 TEST_METHOD (CreateDataStream) {
224255 createTestSystem ();
225256 std::string systemId = getTestSystemId ();
226-
227- auto booleanField = ConnectedSystemsAPI::DataModels::Component::BooleanBuilder ()
228- .withType (" Boolean" s)
229- .withName (" Test Boolean Field" s)
230- .withDescription (" This is a test boolean field" s)
231- .build ();
232-
233- auto resultSchemaPtr = std::make_unique<ConnectedSystemsAPI::DataModels::Component::DataRecord>(
234- ConnectedSystemsAPI::DataModels::Component::DataRecordBuilder ()
235- .withType (" DataRecord" )
236- .addField (std::make_unique<ConnectedSystemsAPI::DataModels::Component::Boolean>(booleanField))
237- .build ()
238- );
239-
240- auto observationSchemaPtr = std::make_unique<ConnectedSystemsAPI::DataModels::ObservationSchema>(
241- ConnectedSystemsAPI::DataModels::ObservationSchemaBuilder ()
242- .withObservationFormat (" application/om+json" s)
243- .withResultSchema (std::move (resultSchemaPtr))
244- .build ()
245- );
246-
247- auto dataStream = ConnectedSystemsAPI::DataModels::DataStreamBuilder ()
248- .withName (" Test DataStream 001" s)
249- .withOutputName (" test_output_001" s)
250- .withDescription (" This is a test data stream created by CSAPI-test" s)
251- .withSchema (std::move (observationSchemaPtr))
252- .build ();
253-
254-
257+ auto dataStream = createDataStream ();
255258 auto response = csapi.getDataStreamsAPI ().createDataStream (systemId, dataStream);
256259 Assert::IsTrue (response.isSuccessful ());
257260 }
261+
262+ TEST_METHOD (DeleteDataStream) {
263+ createTestSystem ();
264+ std::string systemId = getTestSystemId ();
265+ auto dataStream = createDataStream ();
266+ auto dsId = dataStream.getId ().value_or (" " );
267+ csapi.getDataStreamsAPI ().deleteDataStream (dsId, true );
268+ }
258269 };
259270}
0 commit comments