otrosien / spring-statemachine-jpa-and-rest

Sample project using Spring-Statemachine, JPA and Spring Data REST
https://otrosien.github.io/spring-statemachine-jpa-and-rest/html5/api-guide.html
91 stars 44 forks source link

it cant work #4

Closed SuperNoobTao closed 6 years ago

SuperNoobTao commented 6 years ago

Hello : I run it and use 'postman' to test it with "http://localhost:8080/orders/1/receive/Cancel" , But it throw a expection with 500(nullPointExceptioon).I don't know why? Can you help me ? image

otrosien commented 6 years ago

Hey @SuperNoobTao,

sorry for getting back to you so late, but this project was for my own entertainment only when I created it. I think I know what happened in your case. You tried to cancel an order that you didn't create yet. So the order of steps should be the following:

curl -XPOST http://localhost:8080/orders -H 'Accept: application/hal+json' -H 'Content-Type: application/json; charset=UTF-8' -d '{}'
{
  "currentState" : "Open",
  "_links" : {
    "self" : {
      "href" : "http://localhost:8080/orders/2"
    },
    "order" : {
      "href" : "http://localhost:8080/orders/2"
    },
    "receive-payment" : {
      "href" : "http://localhost:8080/orders/2/receive/ReceivePayment"
    },
    "cancel" : {
      "href" : "http://localhost:8080/orders/2/receive/Cancel"
    },
    "unlock-delivery" : {
      "href" : "http://localhost:8080/orders/2/receive/UnlockDelivery"
    }
  }
}

$ curl -XPOST http://localhost:8080/orders/2/receive/Cancel