@@ -124,4 +124,55 @@ public function testGetListRaisesServerExceptions()
124124
125125 $ this ->client ->insightsAnnotation ->getList ();
126126 }
127+
128+ public function testCreate ()
129+ {
130+ $ annotationData = [
131+ 'name ' => 'Deployed release 1.2.3 ' ,
132+ 'x_axis ' => 1756384957 ,
133+ 'app ' => 'johndoe ' ,
134+ 'metrics ' => 'memory_usage ' ,
135+ ];
136+ $ createdAnnotation = array_merge ($ annotationData , [
137+ 'id ' => 123 ,
138+ 'created ' => '2026-07-15T12:00:00Z ' ,
139+ 'modified ' => '2026-07-15T12:00:00Z ' ,
140+ ]);
141+ $ this ->responses ->append (
142+ new Response (201 , [], json_encode ($ createdAnnotation )),
143+ );
144+
145+ $ result = $ this ->client ->insightsAnnotation ->create ($ annotationData );
146+
147+ $ request = $ this ->responses ->getLastRequest ();
148+ $ this ->assertEquals ('POST ' , $ request ->getMethod ());
149+ $ this ->assertEquals ('/v2/insights-annotation/create/ ' , $ request ->getUri ());
150+ $ this ->assertJson ((string )$ request ->getBody ());
151+ $ this ->assertEquals ($ annotationData , json_decode ((string )$ request ->getBody (), true ));
152+ $ this ->assertEquals ($ createdAnnotation , $ result );
153+ }
154+
155+ public function testCreateRaisesClientExceptions ()
156+ {
157+ $ badRequestResponse = new Response (400 , [], json_encode ([
158+ 'non_field_errors ' => ['Your request was invalid. ' ]
159+ ]));
160+ $ this ->responses ->append ($ badRequestResponse );
161+
162+ $ this ->expectExceptionObject (new HypernodeApiClientException ($ badRequestResponse ));
163+
164+ $ this ->client ->insightsAnnotation ->create (['name ' => 'Deployed release 1.2.3 ' ]);
165+ }
166+
167+ public function testCreateRaisesServerExceptions ()
168+ {
169+ $ badRequestResponse = new Response (500 , [], json_encode ([
170+ 'non_field_errors ' => ['Something went wrong processing your request. ' ]
171+ ]));
172+ $ this ->responses ->append ($ badRequestResponse );
173+
174+ $ this ->expectExceptionObject (new HypernodeApiServerException ($ badRequestResponse ));
175+
176+ $ this ->client ->insightsAnnotation ->create (['name ' => 'Deployed release 1.2.3 ' ]);
177+ }
127178}
0 commit comments