1818import static junit .framework .TestCase .fail ;
1919
2020import com .flow .platform .api .domain .Webhook ;
21+ import com .flow .platform .api .domain .job .Job ;
22+ import com .flow .platform .api .domain .job .NodeResult ;
2123import com .flow .platform .api .domain .node .Node ;
2224import com .flow .platform .api .domain .node .Yml ;
2325import com .flow .platform .api .envs .EnvUtil ;
3032import com .flow .platform .api .test .TestBase ;
3133import com .flow .platform .api .util .NodeUtil ;
3234import com .flow .platform .core .exception .IllegalParameterException ;
35+ import com .flow .platform .core .exception .NotFoundException ;
3336import com .flow .platform .util .http .HttpURL ;
3437import java .nio .file .Files ;
3538import java .util .HashMap ;
@@ -255,8 +258,10 @@ public void should_error_if_node_path_is_not_for_flow() throws Throwable {
255258 ymlService .get (root );
256259 }
257260
258- @ Test
261+ @ Test ( expected = NotFoundException . class )
259262 public void should_delete_flow () throws Throwable {
263+ stubDemo ();
264+
260265 Node emptyFlow = nodeService .createEmptyFlow ("flow1" );
261266 setFlowToReady (emptyFlow );
262267
@@ -266,6 +271,12 @@ public void should_delete_flow() throws Throwable {
266271 Assert .assertNotNull (nodeService .find (root .getPath ()));
267272 Assert .assertNotNull (ymlService .get (root ).getFile ());
268273
274+ setRequiredJobEnvsForFlow (root );
275+ Job job = createMockJob (root .getPath ());
276+
277+ Assert .assertNotNull (jobService .find (job .getId ()));
278+ Assert .assertEquals (2 , nodeResultService .list (job , true ).size ());
279+
269280 // when: delete flow
270281 nodeService .delete (root .getPath ());
271282
@@ -275,6 +286,13 @@ public void should_delete_flow() throws Throwable {
275286
276287 // then: should return null if root node is not existed
277288 Assert .assertNull (ymlService .get (root ));
289+
290+ // then: node result should be null
291+ List <NodeResult > nodeResults = nodeResultService .list (job , true );
292+ Assert .assertEquals (0 , nodeResults .size ());
293+
294+ // then: job should be null
295+ jobService .find (job .getId ());
278296 }
279297
280298 @ Test
0 commit comments