나이스 피처 API 테스트 방법

임기준·2025년 4월 10일
0

default data

  • player (2건) : player_id => 1(홍길동), 2(이순신)

참고사항

  • 게임방(room), 게임(game), 피칭보드(pitching_board), 피칭(pitching) 테이블은 생성될 때마다 id 값이 하나씩(+1) 증가한다.
  • 피칭은 홈팀 -> 원정팀 -> 홈팀 -> 원정팀 -> ... 교대로 한번씩 호출한다.
  • 홈팀이 피칭에서 3S를 취득하더라도 원정팀의 피칭까지 마무리 해야 게임이 종료된다.
  • Rest API는 호출한 사람에게만 응답이 전달되고, websocket은 구독이 동일한 모두에게 전달된다.

테스트 시나리오

  1. 게임방 생성

    • curl : Rest API
    # 명령프롬프트
    curl -X POST -H "Content-Type: application/json" -d "name=한판하자" http://localhost:8070/room
    # return 1 (1씩 증가하는 값)
  2. 홍길동(senderId = 1) 게임방입장

    • 소켓연결 : ws://localhost:8070/ws-stomp
    • 구독 : /sub/room/1
    • DESTINATION PATH : /pub/room/enter
    • message(JSON) : { "roomId":1, "senderId":1 }
    • => 응답 : {"command":"WAITING","gameId":null,"receiverId":null,"ballCount":null}
  3. 이순신(senderId = 1) 게임방입장 (브라우저 새창)

    • 소켓연결 : ws://localhost:8070/ws-stomp
    • 구독 : /sub/room/1
    • DESTINATION PATH : /pub/room/enter
    • message(JSON) : { "roomId":1, "senderId":2 }
    • => 응답 : {"command":"SET_HIDDEN","gameId":1,"receiverId":null,"ballCount":null}
  4. 홍길동(senderId = 1) 히든숫자 설정

    • curl : Rest API
    # 명령프롬프트
    curl -X POST -H "Content-Type: application/json" -d "{\"senderId\":1,\"hiddenNumber\":135}" http://localhost:8070/game/1/ready
    
    # return {"boardId": 1, "ready": false }
  5. 이순신(senderId = 2) 히든숫자 설정

    • curl : Rest API
    # 명령프롬프트
    curl -X POST -H "Content-Type: application/json" -d "{\"senderId\":2,\"hiddenNumber\":975}" http://localhost:8070/game/1/ready
    
    # return {"boardId": 2, "ready": true }
  6. 이순신(senderId = 2) 게임시작 호출(ready:true를 받은 쪽에서 호출한다.)

    • DESTINATION PATH : /pub/game/start
    • message(JSON) : { "roomId":1, "gameId":1, "senderId":2 }
    • => 응답 : {"command":"GAME_START","gameId":1,"receiverId":1,"ballCount":null}
  7. 홍길동(senderId = 1) 피칭 시작 (홈팀)

    • DESTINATION PATH : /pub/game/pitching
    • message(JSON) : {"roomId":1, "gameId":1, "boardId": 1, "senderId":1, "pitching": "123"}
    • => 응답 : {"command":"BALL_COUNT","gameId":1,"receiverId":2,"ballCount":{"pitching":"123","strike":1,"ball":1,"pitchClock":0}}
  8. 이순신(senderId = 2) 피칭 (원정팀)

    • DESTINATION PATH : /pub/game/pitching
    • message(JSON) : {"roomId":1, "gameId":1, "boardId": 2, "senderId":2, "pitching": "789"}
    • => 응답 : {"command":"BALL_COUNT","gameId":1,"receiverId":1,"ballCount":{"pitching":"789","strike":0,"ball":0,"pitchClock":0}}

8.~ 6.7을 반복하며 피칭

profile
openerzone

0개의 댓글