#!/bin/bash # Test script for Table Management API # Make sure the server is running on localhost:8080 BASE_URL="http://localhost:8080/api/v1" TOKEN="your_jwt_token_here" # Replace with actual JWT token echo "Testing Table Management API" echo "==========================" # Test 1: Create a table echo -e "\n1. Creating a table..." CREATE_RESPONSE=$(curl -s -X POST "$BASE_URL/tables" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $TOKEN" \ -d '{ "outlet_id": "your_outlet_id_here", "table_name": "Table 1", "position_x": 100.0, "position_y": 200.0, "capacity": 4, "metadata": { "description": "Window table" } }') echo "Create Response: $CREATE_RESPONSE" # Extract table ID from response (you'll need to parse this) TABLE_ID=$(echo $CREATE_RESPONSE | grep -o '"id":"[^"]*"' | cut -d'"' -f4) if [ -n "$TABLE_ID" ]; then echo "Created table with ID: $TABLE_ID" # Test 2: Get table by ID echo -e "\n2. Getting table by ID..." GET_RESPONSE=$(curl -s -X GET "$BASE_URL/tables/$TABLE_ID" \ -H "Authorization: Bearer $TOKEN") echo "Get Response: $GET_RESPONSE" # Test 3: Update table echo -e "\n3. Updating table..." UPDATE_RESPONSE=$(curl -s -X PUT "$BASE_URL/tables/$TABLE_ID" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $TOKEN" \ -d '{ "table_name": "Table 1 Updated", "capacity": 6, "position_x": 150.0, "position_y": 250.0 }') echo "Update Response: $UPDATE_RESPONSE" # Test 4: List tables echo -e "\n4. Listing tables..." LIST_RESPONSE=$(curl -s -X GET "$BASE_URL/tables?page=1&limit=10" \ -H "Authorization: Bearer $TOKEN") echo "List Response: $LIST_RESPONSE" # Test 5: Get available tables for outlet echo -e "\n5. Getting available tables..." AVAILABLE_RESPONSE=$(curl -s -X GET "$BASE_URL/outlets/your_outlet_id_here/tables/available" \ -H "Authorization: Bearer $TOKEN") echo "Available Tables Response: $AVAILABLE_RESPONSE" # Test 6: Delete table echo -e "\n6. Deleting table..." DELETE_RESPONSE=$(curl -s -X DELETE "$BASE_URL/tables/$TABLE_ID" \ -H "Authorization: Bearer $TOKEN") echo "Delete Response: $DELETE_RESPONSE" else echo "Failed to create table or extract table ID" fi echo -e "\nAPI Testing completed!"