@@ -302,6 +302,60 @@ public void scheduleOperationByAdminWorks() throws Exception
302302 assertEquals (Status .BAD_REQUEST .getStatusCode (), response .getCode ());
303303 }
304304 }
305+
306+ @ Test
307+ public void shouldClearScheduledOperation () throws Exception
308+ {
309+ HttpPost addEntity = new HttpPost ("/restadm/v1/entity/identity/userName/userA?credentialRequirement=cr-pass" );
310+ String contents = executeQuery (addEntity );
311+ ObjectNode root = (ObjectNode ) m .readTree (contents );
312+ long entityId = root .get ("entityId" ).asLong ();
313+ assertTrue (checkIdentity ("userA" ));
314+ System .out .println ("Added entity:\n " + contents );
315+
316+ long time = System .currentTimeMillis () + 20000 ;
317+ HttpPut scheduleRemoval = new HttpPut ("/restadm/v1/entity/" + entityId + "/admin-schedule?when=" +
318+ time + "&operation=REMOVE" );
319+ try (ClassicHttpResponse response = client .executeOpen (host , scheduleRemoval , getClientContext (host ))){
320+ assertEquals (Status .NO_CONTENT .getStatusCode (), response .getCode ());
321+ }
322+
323+ HttpDelete clearSchedule = new HttpDelete ("/restadm/v1/entity/" + entityId + "/admin-schedule" );
324+ try (ClassicHttpResponse response = client .executeOpen (host , clearSchedule , getClientContext (host ))){
325+ assertEquals (Status .NO_CONTENT .getStatusCode (), response .getCode ());
326+ }
327+
328+ Entity entity = idsMan .getEntity (new EntityParam (entityId ));
329+ assertEquals (null , entity .getEntityInformation ().getScheduledOperationTime ());
330+ assertEquals (null , entity .getEntityInformation ().getScheduledOperation ());
331+ }
332+
333+ @ Test
334+ public void shouldClearRemovalByUserTime () throws Exception
335+ {
336+ HttpPost addEntity = new HttpPost ("/restadm/v1/entity/identity/userName/userA?credentialRequirement=cr-pass" );
337+ String contents = executeQuery (addEntity );
338+ ObjectNode root = (ObjectNode ) m .readTree (contents );
339+ long entityId = root .get ("entityId" ).asLong ();
340+ assertTrue (checkIdentity ("userA" ));
341+ System .out .println ("Added entity:\n " + contents );
342+
343+ long time = System .currentTimeMillis () + 20000 ;
344+ HttpPut removalSchedule = new HttpPut ("/restadm/v1/entity/" + entityId + "/removal-schedule?when=" +
345+ time );
346+ try (ClassicHttpResponse response = client .executeOpen (host , removalSchedule , getClientContext (host ))){
347+ assertEquals (Status .NO_CONTENT .getStatusCode (), response .getCode ());
348+ }
349+
350+ HttpDelete clearSchedule = new HttpDelete ("/restadm/v1/entity/" + entityId + "/admin-schedule" );
351+ try (ClassicHttpResponse response = client .executeOpen (host , clearSchedule , getClientContext (host ))){
352+ assertEquals (Status .NO_CONTENT .getStatusCode (), response .getCode ());
353+ }
354+
355+ Entity entity = idsMan .getEntity (new EntityParam (entityId ));
356+ assertEquals (EntityState .valid , entity .getEntityInformation ().getState ());
357+ assertEquals (null , entity .getEntityInformation ().getRemovalByUserTime ());
358+ }
305359
306360 @ Test
307361 public void scheduleRemovalByUserWorks () throws Exception
0 commit comments