Java API of Repository Service to Suspend Process Definition

I am trying to use process engine’s repository service to suspend process definition
engine.getRepositoryService().suspendProcessDefinitionById(definition.getId(), true, null);

However, after executing such code, the process definition is not suspended in Camunda Web Application UI. I also wrote some Java Code to check whether it is suspended, still not suspended.
engine.getRepositoryService().createProcessDefinitionQuery().list()

But when I tried suspending the process definition with Rest Call, it worked:
curl -v "http://localhost:8454/engine/api/engine/process-definition/test:1:4879531/suspended" --data '{"suspended": true, "includeProcessInstances": true}' -H "Content-type: application/json" -X PUT
I can see the process definition suspended in Camunda Web Application UI.

Did I use the wrong Java API?

Thanks