From 47ceff1548a44c4f4412d9fd3371fa0106a9ede3 Mon Sep 17 00:00:00 2001 From: JHipster Bot Date: Sun, 29 Mar 2020 10:27:04 +0000 Subject: [PATCH 1/2] Add JDL Model `admin` See https://start.jhipster.tech/jdl-studio/#!/view/8f023545-1f42-4760-8603-c6cc0054ac9a --- admin.jh | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 admin.jh diff --git a/admin.jh b/admin.jh new file mode 100644 index 0000000..7526631 --- /dev/null +++ b/admin.jh @@ -0,0 +1,35 @@ +entity GameUser { + username String + password String +} + +entity GameCommission { + commission Integer +} + +entity Game { + name String +} + +entity Bet { + chips Integer +} + +entity Hand { + status HandStatus +} + +enum HandStatus { + Begin, End +} + +relationship ManyToOne { + Hand{game} to Game + GameCommission{game} to Game + Bet{user} to GameUser +} + +relationship OneToMany { + GameUser{commission} to GameCommission + Hand{bet} to Bet{hand} +} \ No newline at end of file From 334a719dd3ab721ad36455dea37a11546ca5971c Mon Sep 17 00:00:00 2001 From: JHipster Bot Date: Sun, 29 Mar 2020 10:27:11 +0000 Subject: [PATCH 2/2] Generate entities from JDL Model `admin` See https://start.jhipster.tech/jdl-studio/#!/view/8f023545-1f42-4760-8603-c6cc0054ac9a --- .jhipster/Bet.json | 36 +++ .jhipster/Game.json | 21 ++ .jhipster/GameCommission.json | 36 +++ .jhipster/GameUser.json | 32 +++ .jhipster/Hand.json | 36 +++ .../myapp/config/CacheConfiguration.java | 7 + .../java/com/mycompany/myapp/domain/Bet.java | 109 +++++++++ .../java/com/mycompany/myapp/domain/Game.java | 74 ++++++ .../myapp/domain/GameCommission.java | 109 +++++++++ .../com/mycompany/myapp/domain/GameUser.java | 122 ++++++++++ .../java/com/mycompany/myapp/domain/Hand.java | 126 ++++++++++ .../myapp/domain/enumeration/HandStatus.java | 8 + .../myapp/repository/BetRepository.java | 14 ++ .../repository/GameCommissionRepository.java | 14 ++ .../myapp/repository/GameRepository.java | 14 ++ .../myapp/repository/GameUserRepository.java | 14 ++ .../myapp/repository/HandRepository.java | 14 ++ .../mycompany/myapp/web/rest/BetResource.java | 118 ++++++++++ .../web/rest/GameCommissionResource.java | 118 ++++++++++ .../myapp/web/rest/GameResource.java | 118 ++++++++++ .../myapp/web/rest/GameUserResource.java | 118 ++++++++++ .../myapp/web/rest/HandResource.java | 118 ++++++++++ .../20200329102800_added_entity_GameUser.xml | 54 +++++ ...0329102900_added_entity_GameCommission.xml | 56 +++++ ...dded_entity_constraints_GameCommission.xml | 24 ++ .../20200329103000_added_entity_Game.xml | 50 ++++ .../20200329103100_added_entity_Bet.xml | 56 +++++ ...329103100_added_entity_constraints_Bet.xml | 24 ++ .../20200329103200_added_entity_Hand.xml | 53 +++++ ...29103200_added_entity_constraints_Hand.xml | 18 ++ .../config/liquibase/fake-data/bet.csv | 11 + .../config/liquibase/fake-data/game.csv | 11 + .../liquibase/fake-data/game_commission.csv | 11 + .../config/liquibase/fake-data/game_user.csv | 11 + .../config/liquibase/fake-data/hand.csv | 11 + .../resources/config/liquibase/master.xml | 8 + .../bet/bet-delete-dialog.component.html | 24 ++ .../bet/bet-delete-dialog.component.ts | 26 +++ .../entities/bet/bet-detail.component.html | 42 ++++ .../app/entities/bet/bet-detail.component.ts | 22 ++ .../entities/bet/bet-update.component.html | 48 ++++ .../app/entities/bet/bet-update.component.ts | 103 ++++++++ .../app/entities/bet/bet.component.html | 73 ++++++ .../webapp/app/entities/bet/bet.component.ts | 49 ++++ .../webapp/app/entities/bet/bet.module.ts | 16 ++ src/main/webapp/app/entities/bet/bet.route.ts | 83 +++++++ .../webapp/app/entities/bet/bet.service.ts | 38 +++ src/main/webapp/app/entities/entity.module.ts | 20 ++ ...me-commission-delete-dialog.component.html | 24 ++ ...game-commission-delete-dialog.component.ts | 30 +++ .../game-commission-detail.component.html | 42 ++++ .../game-commission-detail.component.ts | 22 ++ .../game-commission-update.component.html | 48 ++++ .../game-commission-update.component.ts | 103 ++++++++ .../game-commission.component.html | 73 ++++++ .../game-commission.component.ts | 53 +++++ .../game-commission/game-commission.module.ts | 21 ++ .../game-commission/game-commission.route.ts | 83 +++++++ .../game-commission.service.ts | 38 +++ .../game-user-delete-dialog.component.html | 24 ++ .../game-user-delete-dialog.component.ts | 26 +++ .../game-user/game-user-detail.component.html | 34 +++ .../game-user/game-user-detail.component.ts | 22 ++ .../game-user/game-user-update.component.html | 38 +++ .../game-user/game-user-update.component.ts | 78 +++++++ .../game-user/game-user.component.html | 63 +++++ .../entities/game-user/game-user.component.ts | 49 ++++ .../entities/game-user/game-user.module.ts | 16 ++ .../app/entities/game-user/game-user.route.ts | 83 +++++++ .../entities/game-user/game-user.service.ts | 38 +++ .../game/game-delete-dialog.component.html | 24 ++ .../game/game-delete-dialog.component.ts | 26 +++ .../entities/game/game-detail.component.html | 30 +++ .../entities/game/game-detail.component.ts | 22 ++ .../entities/game/game-update.component.html | 32 +++ .../entities/game/game-update.component.ts | 75 ++++++ .../app/entities/game/game.component.html | 61 +++++ .../app/entities/game/game.component.ts | 49 ++++ .../webapp/app/entities/game/game.module.ts | 16 ++ .../webapp/app/entities/game/game.route.ts | 83 +++++++ .../webapp/app/entities/game/game.service.ts | 38 +++ .../hand/hand-delete-dialog.component.html | 24 ++ .../hand/hand-delete-dialog.component.ts | 26 +++ .../entities/hand/hand-detail.component.html | 36 +++ .../entities/hand/hand-detail.component.ts | 22 ++ .../entities/hand/hand-update.component.html | 42 ++++ .../entities/hand/hand-update.component.ts | 92 ++++++++ .../app/entities/hand/hand.component.html | 67 ++++++ .../app/entities/hand/hand.component.ts | 49 ++++ .../webapp/app/entities/hand/hand.module.ts | 16 ++ .../webapp/app/entities/hand/hand.route.ts | 83 +++++++ .../webapp/app/entities/hand/hand.service.ts | 38 +++ .../app/layouts/navbar/navbar.component.html | 30 +++ src/main/webapp/app/shared/model/bet.model.ts | 13 ++ .../model/enumerations/hand-status.model.ts | 4 + .../app/shared/model/game-commission.model.ts | 13 ++ .../app/shared/model/game-user.model.ts | 12 + .../webapp/app/shared/model/game.model.ts | 8 + .../webapp/app/shared/model/hand.model.ts | 14 ++ .../com/mycompany/myapp/domain/BetTest.java | 22 ++ .../myapp/domain/GameCommissionTest.java | 22 ++ .../com/mycompany/myapp/domain/GameTest.java | 22 ++ .../mycompany/myapp/domain/GameUserTest.java | 22 ++ .../com/mycompany/myapp/domain/HandTest.java | 22 ++ .../myapp/web/rest/BetResourceIT.java | 211 +++++++++++++++++ .../web/rest/GameCommissionResourceIT.java | 211 +++++++++++++++++ .../myapp/web/rest/GameResourceIT.java | 211 +++++++++++++++++ .../myapp/web/rest/GameUserResourceIT.java | 221 ++++++++++++++++++ .../myapp/web/rest/HandResourceIT.java | 212 +++++++++++++++++ .../bet/bet-delete-dialog.component.spec.ts | 65 ++++++ .../entities/bet/bet-detail.component.spec.ts | 37 +++ .../entities/bet/bet-update.component.spec.ts | 61 +++++ .../app/entities/bet/bet.component.spec.ts | 49 ++++ .../spec/app/entities/bet/bet.service.spec.ts | 102 ++++++++ ...commission-delete-dialog.component.spec.ts | 65 ++++++ .../game-commission-detail.component.spec.ts | 37 +++ .../game-commission-update.component.spec.ts | 61 +++++ .../game-commission.component.spec.ts | 49 ++++ .../game-commission.service.spec.ts | 102 ++++++++ .../game-user-delete-dialog.component.spec.ts | 65 ++++++ .../game-user-detail.component.spec.ts | 37 +++ .../game-user-update.component.spec.ts | 61 +++++ .../game-user/game-user.component.spec.ts | 49 ++++ .../game-user/game-user.service.spec.ts | 104 +++++++++ .../game/game-delete-dialog.component.spec.ts | 65 ++++++ .../game/game-detail.component.spec.ts | 37 +++ .../game/game-update.component.spec.ts | 61 +++++ .../app/entities/game/game.component.spec.ts | 49 ++++ .../app/entities/game/game.service.spec.ts | 102 ++++++++ .../hand/hand-delete-dialog.component.spec.ts | 65 ++++++ .../hand/hand-detail.component.spec.ts | 37 +++ .../hand/hand-update.component.spec.ts | 61 +++++ .../app/entities/hand/hand.component.spec.ts | 49 ++++ .../app/entities/hand/hand.service.spec.ts | 103 ++++++++ 134 files changed, 7120 insertions(+) create mode 100644 .jhipster/Bet.json create mode 100644 .jhipster/Game.json create mode 100644 .jhipster/GameCommission.json create mode 100644 .jhipster/GameUser.json create mode 100644 .jhipster/Hand.json create mode 100644 src/main/java/com/mycompany/myapp/domain/Bet.java create mode 100644 src/main/java/com/mycompany/myapp/domain/Game.java create mode 100644 src/main/java/com/mycompany/myapp/domain/GameCommission.java create mode 100644 src/main/java/com/mycompany/myapp/domain/GameUser.java create mode 100644 src/main/java/com/mycompany/myapp/domain/Hand.java create mode 100644 src/main/java/com/mycompany/myapp/domain/enumeration/HandStatus.java create mode 100644 src/main/java/com/mycompany/myapp/repository/BetRepository.java create mode 100644 src/main/java/com/mycompany/myapp/repository/GameCommissionRepository.java create mode 100644 src/main/java/com/mycompany/myapp/repository/GameRepository.java create mode 100644 src/main/java/com/mycompany/myapp/repository/GameUserRepository.java create mode 100644 src/main/java/com/mycompany/myapp/repository/HandRepository.java create mode 100644 src/main/java/com/mycompany/myapp/web/rest/BetResource.java create mode 100644 src/main/java/com/mycompany/myapp/web/rest/GameCommissionResource.java create mode 100644 src/main/java/com/mycompany/myapp/web/rest/GameResource.java create mode 100644 src/main/java/com/mycompany/myapp/web/rest/GameUserResource.java create mode 100644 src/main/java/com/mycompany/myapp/web/rest/HandResource.java create mode 100644 src/main/resources/config/liquibase/changelog/20200329102800_added_entity_GameUser.xml create mode 100644 src/main/resources/config/liquibase/changelog/20200329102900_added_entity_GameCommission.xml create mode 100644 src/main/resources/config/liquibase/changelog/20200329102900_added_entity_constraints_GameCommission.xml create mode 100644 src/main/resources/config/liquibase/changelog/20200329103000_added_entity_Game.xml create mode 100644 src/main/resources/config/liquibase/changelog/20200329103100_added_entity_Bet.xml create mode 100644 src/main/resources/config/liquibase/changelog/20200329103100_added_entity_constraints_Bet.xml create mode 100644 src/main/resources/config/liquibase/changelog/20200329103200_added_entity_Hand.xml create mode 100644 src/main/resources/config/liquibase/changelog/20200329103200_added_entity_constraints_Hand.xml create mode 100644 src/main/resources/config/liquibase/fake-data/bet.csv create mode 100644 src/main/resources/config/liquibase/fake-data/game.csv create mode 100644 src/main/resources/config/liquibase/fake-data/game_commission.csv create mode 100644 src/main/resources/config/liquibase/fake-data/game_user.csv create mode 100644 src/main/resources/config/liquibase/fake-data/hand.csv create mode 100644 src/main/webapp/app/entities/bet/bet-delete-dialog.component.html create mode 100644 src/main/webapp/app/entities/bet/bet-delete-dialog.component.ts create mode 100644 src/main/webapp/app/entities/bet/bet-detail.component.html create mode 100644 src/main/webapp/app/entities/bet/bet-detail.component.ts create mode 100644 src/main/webapp/app/entities/bet/bet-update.component.html create mode 100644 src/main/webapp/app/entities/bet/bet-update.component.ts create mode 100644 src/main/webapp/app/entities/bet/bet.component.html create mode 100644 src/main/webapp/app/entities/bet/bet.component.ts create mode 100644 src/main/webapp/app/entities/bet/bet.module.ts create mode 100644 src/main/webapp/app/entities/bet/bet.route.ts create mode 100644 src/main/webapp/app/entities/bet/bet.service.ts create mode 100644 src/main/webapp/app/entities/game-commission/game-commission-delete-dialog.component.html create mode 100644 src/main/webapp/app/entities/game-commission/game-commission-delete-dialog.component.ts create mode 100644 src/main/webapp/app/entities/game-commission/game-commission-detail.component.html create mode 100644 src/main/webapp/app/entities/game-commission/game-commission-detail.component.ts create mode 100644 src/main/webapp/app/entities/game-commission/game-commission-update.component.html create mode 100644 src/main/webapp/app/entities/game-commission/game-commission-update.component.ts create mode 100644 src/main/webapp/app/entities/game-commission/game-commission.component.html create mode 100644 src/main/webapp/app/entities/game-commission/game-commission.component.ts create mode 100644 src/main/webapp/app/entities/game-commission/game-commission.module.ts create mode 100644 src/main/webapp/app/entities/game-commission/game-commission.route.ts create mode 100644 src/main/webapp/app/entities/game-commission/game-commission.service.ts create mode 100644 src/main/webapp/app/entities/game-user/game-user-delete-dialog.component.html create mode 100644 src/main/webapp/app/entities/game-user/game-user-delete-dialog.component.ts create mode 100644 src/main/webapp/app/entities/game-user/game-user-detail.component.html create mode 100644 src/main/webapp/app/entities/game-user/game-user-detail.component.ts create mode 100644 src/main/webapp/app/entities/game-user/game-user-update.component.html create mode 100644 src/main/webapp/app/entities/game-user/game-user-update.component.ts create mode 100644 src/main/webapp/app/entities/game-user/game-user.component.html create mode 100644 src/main/webapp/app/entities/game-user/game-user.component.ts create mode 100644 src/main/webapp/app/entities/game-user/game-user.module.ts create mode 100644 src/main/webapp/app/entities/game-user/game-user.route.ts create mode 100644 src/main/webapp/app/entities/game-user/game-user.service.ts create mode 100644 src/main/webapp/app/entities/game/game-delete-dialog.component.html create mode 100644 src/main/webapp/app/entities/game/game-delete-dialog.component.ts create mode 100644 src/main/webapp/app/entities/game/game-detail.component.html create mode 100644 src/main/webapp/app/entities/game/game-detail.component.ts create mode 100644 src/main/webapp/app/entities/game/game-update.component.html create mode 100644 src/main/webapp/app/entities/game/game-update.component.ts create mode 100644 src/main/webapp/app/entities/game/game.component.html create mode 100644 src/main/webapp/app/entities/game/game.component.ts create mode 100644 src/main/webapp/app/entities/game/game.module.ts create mode 100644 src/main/webapp/app/entities/game/game.route.ts create mode 100644 src/main/webapp/app/entities/game/game.service.ts create mode 100644 src/main/webapp/app/entities/hand/hand-delete-dialog.component.html create mode 100644 src/main/webapp/app/entities/hand/hand-delete-dialog.component.ts create mode 100644 src/main/webapp/app/entities/hand/hand-detail.component.html create mode 100644 src/main/webapp/app/entities/hand/hand-detail.component.ts create mode 100644 src/main/webapp/app/entities/hand/hand-update.component.html create mode 100644 src/main/webapp/app/entities/hand/hand-update.component.ts create mode 100644 src/main/webapp/app/entities/hand/hand.component.html create mode 100644 src/main/webapp/app/entities/hand/hand.component.ts create mode 100644 src/main/webapp/app/entities/hand/hand.module.ts create mode 100644 src/main/webapp/app/entities/hand/hand.route.ts create mode 100644 src/main/webapp/app/entities/hand/hand.service.ts create mode 100644 src/main/webapp/app/shared/model/bet.model.ts create mode 100644 src/main/webapp/app/shared/model/enumerations/hand-status.model.ts create mode 100644 src/main/webapp/app/shared/model/game-commission.model.ts create mode 100644 src/main/webapp/app/shared/model/game-user.model.ts create mode 100644 src/main/webapp/app/shared/model/game.model.ts create mode 100644 src/main/webapp/app/shared/model/hand.model.ts create mode 100644 src/test/java/com/mycompany/myapp/domain/BetTest.java create mode 100644 src/test/java/com/mycompany/myapp/domain/GameCommissionTest.java create mode 100644 src/test/java/com/mycompany/myapp/domain/GameTest.java create mode 100644 src/test/java/com/mycompany/myapp/domain/GameUserTest.java create mode 100644 src/test/java/com/mycompany/myapp/domain/HandTest.java create mode 100644 src/test/java/com/mycompany/myapp/web/rest/BetResourceIT.java create mode 100644 src/test/java/com/mycompany/myapp/web/rest/GameCommissionResourceIT.java create mode 100644 src/test/java/com/mycompany/myapp/web/rest/GameResourceIT.java create mode 100644 src/test/java/com/mycompany/myapp/web/rest/GameUserResourceIT.java create mode 100644 src/test/java/com/mycompany/myapp/web/rest/HandResourceIT.java create mode 100644 src/test/javascript/spec/app/entities/bet/bet-delete-dialog.component.spec.ts create mode 100644 src/test/javascript/spec/app/entities/bet/bet-detail.component.spec.ts create mode 100644 src/test/javascript/spec/app/entities/bet/bet-update.component.spec.ts create mode 100644 src/test/javascript/spec/app/entities/bet/bet.component.spec.ts create mode 100644 src/test/javascript/spec/app/entities/bet/bet.service.spec.ts create mode 100644 src/test/javascript/spec/app/entities/game-commission/game-commission-delete-dialog.component.spec.ts create mode 100644 src/test/javascript/spec/app/entities/game-commission/game-commission-detail.component.spec.ts create mode 100644 src/test/javascript/spec/app/entities/game-commission/game-commission-update.component.spec.ts create mode 100644 src/test/javascript/spec/app/entities/game-commission/game-commission.component.spec.ts create mode 100644 src/test/javascript/spec/app/entities/game-commission/game-commission.service.spec.ts create mode 100644 src/test/javascript/spec/app/entities/game-user/game-user-delete-dialog.component.spec.ts create mode 100644 src/test/javascript/spec/app/entities/game-user/game-user-detail.component.spec.ts create mode 100644 src/test/javascript/spec/app/entities/game-user/game-user-update.component.spec.ts create mode 100644 src/test/javascript/spec/app/entities/game-user/game-user.component.spec.ts create mode 100644 src/test/javascript/spec/app/entities/game-user/game-user.service.spec.ts create mode 100644 src/test/javascript/spec/app/entities/game/game-delete-dialog.component.spec.ts create mode 100644 src/test/javascript/spec/app/entities/game/game-detail.component.spec.ts create mode 100644 src/test/javascript/spec/app/entities/game/game-update.component.spec.ts create mode 100644 src/test/javascript/spec/app/entities/game/game.component.spec.ts create mode 100644 src/test/javascript/spec/app/entities/game/game.service.spec.ts create mode 100644 src/test/javascript/spec/app/entities/hand/hand-delete-dialog.component.spec.ts create mode 100644 src/test/javascript/spec/app/entities/hand/hand-detail.component.spec.ts create mode 100644 src/test/javascript/spec/app/entities/hand/hand-update.component.spec.ts create mode 100644 src/test/javascript/spec/app/entities/hand/hand.component.spec.ts create mode 100644 src/test/javascript/spec/app/entities/hand/hand.service.spec.ts diff --git a/.jhipster/Bet.json b/.jhipster/Bet.json new file mode 100644 index 0000000..5f40d70 --- /dev/null +++ b/.jhipster/Bet.json @@ -0,0 +1,36 @@ +{ + "name": "Bet", + "fields": [ + { + "fieldName": "chips", + "fieldType": "Integer" + } + ], + "relationships": [ + { + "relationshipType": "many-to-one", + "otherEntityName": "gameUser", + "otherEntityRelationshipName": "bet", + "relationshipName": "user", + "otherEntityField": "id" + }, + { + "relationshipType": "many-to-one", + "otherEntityName": "hand", + "otherEntityRelationshipName": "bet", + "relationshipName": "hand", + "otherEntityField": "id" + } + ], + "changelogDate": "20200329103100", + "entityTableName": "bet", + "dto": "no", + "pagination": "no", + "service": "no", + "jpaMetamodelFiltering": false, + "fluentMethods": true, + "readOnly": false, + "embedded": false, + "clientRootFolder": "", + "applications": "*" +} \ No newline at end of file diff --git a/.jhipster/Game.json b/.jhipster/Game.json new file mode 100644 index 0000000..2842a06 --- /dev/null +++ b/.jhipster/Game.json @@ -0,0 +1,21 @@ +{ + "name": "Game", + "fields": [ + { + "fieldName": "name", + "fieldType": "String" + } + ], + "relationships": [], + "changelogDate": "20200329103000", + "entityTableName": "game", + "dto": "no", + "pagination": "no", + "service": "no", + "jpaMetamodelFiltering": false, + "fluentMethods": true, + "readOnly": false, + "embedded": false, + "clientRootFolder": "", + "applications": "*" +} \ No newline at end of file diff --git a/.jhipster/GameCommission.json b/.jhipster/GameCommission.json new file mode 100644 index 0000000..26a5587 --- /dev/null +++ b/.jhipster/GameCommission.json @@ -0,0 +1,36 @@ +{ + "name": "GameCommission", + "fields": [ + { + "fieldName": "commission", + "fieldType": "Integer" + } + ], + "relationships": [ + { + "relationshipType": "many-to-one", + "otherEntityName": "game", + "otherEntityRelationshipName": "gameCommission", + "relationshipName": "game", + "otherEntityField": "id" + }, + { + "relationshipType": "many-to-one", + "otherEntityName": "gameUser", + "otherEntityRelationshipName": "commission", + "relationshipName": "gameUser", + "otherEntityField": "id" + } + ], + "changelogDate": "20200329102900", + "entityTableName": "game_commission", + "dto": "no", + "pagination": "no", + "service": "no", + "jpaMetamodelFiltering": false, + "fluentMethods": true, + "readOnly": false, + "embedded": false, + "clientRootFolder": "", + "applications": "*" +} \ No newline at end of file diff --git a/.jhipster/GameUser.json b/.jhipster/GameUser.json new file mode 100644 index 0000000..17b8a66 --- /dev/null +++ b/.jhipster/GameUser.json @@ -0,0 +1,32 @@ +{ + "name": "GameUser", + "fields": [ + { + "fieldName": "username", + "fieldType": "String" + }, + { + "fieldName": "password", + "fieldType": "String" + } + ], + "relationships": [ + { + "relationshipType": "one-to-many", + "otherEntityName": "gameCommission", + "otherEntityRelationshipName": "gameUser", + "relationshipName": "commission" + } + ], + "changelogDate": "20200329102800", + "entityTableName": "game_user", + "dto": "no", + "pagination": "no", + "service": "no", + "jpaMetamodelFiltering": false, + "fluentMethods": true, + "readOnly": false, + "embedded": false, + "clientRootFolder": "", + "applications": "*" +} \ No newline at end of file diff --git a/.jhipster/Hand.json b/.jhipster/Hand.json new file mode 100644 index 0000000..e95ea5b --- /dev/null +++ b/.jhipster/Hand.json @@ -0,0 +1,36 @@ +{ + "name": "Hand", + "fields": [ + { + "fieldName": "status", + "fieldType": "HandStatus", + "fieldValues": "Begin,End" + } + ], + "relationships": [ + { + "relationshipType": "one-to-many", + "otherEntityName": "bet", + "otherEntityRelationshipName": "hand", + "relationshipName": "bet" + }, + { + "relationshipType": "many-to-one", + "otherEntityName": "game", + "otherEntityRelationshipName": "hand", + "relationshipName": "game", + "otherEntityField": "id" + } + ], + "changelogDate": "20200329103200", + "entityTableName": "hand", + "dto": "no", + "pagination": "no", + "service": "no", + "jpaMetamodelFiltering": false, + "fluentMethods": true, + "readOnly": false, + "embedded": false, + "clientRootFolder": "", + "applications": "*" +} \ No newline at end of file diff --git a/src/main/java/com/mycompany/myapp/config/CacheConfiguration.java b/src/main/java/com/mycompany/myapp/config/CacheConfiguration.java index fd8baed..064224b 100644 --- a/src/main/java/com/mycompany/myapp/config/CacheConfiguration.java +++ b/src/main/java/com/mycompany/myapp/config/CacheConfiguration.java @@ -40,6 +40,13 @@ public JCacheManagerCustomizer cacheManagerCustomizer() { createCache(cm, com.mycompany.myapp.domain.User.class.getName()); createCache(cm, com.mycompany.myapp.domain.Authority.class.getName()); createCache(cm, com.mycompany.myapp.domain.User.class.getName() + ".authorities"); + createCache(cm, com.mycompany.myapp.domain.GameUser.class.getName()); + createCache(cm, com.mycompany.myapp.domain.GameUser.class.getName() + ".commissions"); + createCache(cm, com.mycompany.myapp.domain.GameCommission.class.getName()); + createCache(cm, com.mycompany.myapp.domain.Game.class.getName()); + createCache(cm, com.mycompany.myapp.domain.Bet.class.getName()); + createCache(cm, com.mycompany.myapp.domain.Hand.class.getName()); + createCache(cm, com.mycompany.myapp.domain.Hand.class.getName() + ".bets"); // jhipster-needle-ehcache-add-entry }; } diff --git a/src/main/java/com/mycompany/myapp/domain/Bet.java b/src/main/java/com/mycompany/myapp/domain/Bet.java new file mode 100644 index 0000000..5fcbfbf --- /dev/null +++ b/src/main/java/com/mycompany/myapp/domain/Bet.java @@ -0,0 +1,109 @@ +package com.mycompany.myapp.domain; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import org.hibernate.annotations.Cache; +import org.hibernate.annotations.CacheConcurrencyStrategy; + +import javax.persistence.*; + +import java.io.Serializable; +import java.util.Objects; + +/** + * A Bet. + */ +@Entity +@Table(name = "bet") +@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) +public class Bet implements Serializable { + + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column(name = "chips") + private Integer chips; + + @ManyToOne + @JsonIgnoreProperties("bets") + private GameUser user; + + @ManyToOne + @JsonIgnoreProperties("bets") + private Hand hand; + + // jhipster-needle-entity-add-field - JHipster will add fields here, do not remove + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Integer getChips() { + return chips; + } + + public Bet chips(Integer chips) { + this.chips = chips; + return this; + } + + public void setChips(Integer chips) { + this.chips = chips; + } + + public GameUser getUser() { + return user; + } + + public Bet user(GameUser gameUser) { + this.user = gameUser; + return this; + } + + public void setUser(GameUser gameUser) { + this.user = gameUser; + } + + public Hand getHand() { + return hand; + } + + public Bet hand(Hand hand) { + this.hand = hand; + return this; + } + + public void setHand(Hand hand) { + this.hand = hand; + } + // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof Bet)) { + return false; + } + return id != null && id.equals(((Bet) o).id); + } + + @Override + public int hashCode() { + return 31; + } + + @Override + public String toString() { + return "Bet{" + + "id=" + getId() + + ", chips=" + getChips() + + "}"; + } +} diff --git a/src/main/java/com/mycompany/myapp/domain/Game.java b/src/main/java/com/mycompany/myapp/domain/Game.java new file mode 100644 index 0000000..e3832e5 --- /dev/null +++ b/src/main/java/com/mycompany/myapp/domain/Game.java @@ -0,0 +1,74 @@ +package com.mycompany.myapp.domain; + +import org.hibernate.annotations.Cache; +import org.hibernate.annotations.CacheConcurrencyStrategy; + +import javax.persistence.*; + +import java.io.Serializable; +import java.util.Objects; + +/** + * A Game. + */ +@Entity +@Table(name = "game") +@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) +public class Game implements Serializable { + + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column(name = "name") + private String name; + + // jhipster-needle-entity-add-field - JHipster will add fields here, do not remove + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public Game name(String name) { + this.name = name; + return this; + } + + public void setName(String name) { + this.name = name; + } + // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof Game)) { + return false; + } + return id != null && id.equals(((Game) o).id); + } + + @Override + public int hashCode() { + return 31; + } + + @Override + public String toString() { + return "Game{" + + "id=" + getId() + + ", name='" + getName() + "'" + + "}"; + } +} diff --git a/src/main/java/com/mycompany/myapp/domain/GameCommission.java b/src/main/java/com/mycompany/myapp/domain/GameCommission.java new file mode 100644 index 0000000..4a2f3d9 --- /dev/null +++ b/src/main/java/com/mycompany/myapp/domain/GameCommission.java @@ -0,0 +1,109 @@ +package com.mycompany.myapp.domain; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import org.hibernate.annotations.Cache; +import org.hibernate.annotations.CacheConcurrencyStrategy; + +import javax.persistence.*; + +import java.io.Serializable; +import java.util.Objects; + +/** + * A GameCommission. + */ +@Entity +@Table(name = "game_commission") +@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) +public class GameCommission implements Serializable { + + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column(name = "commission") + private Integer commission; + + @ManyToOne + @JsonIgnoreProperties("gameCommissions") + private Game game; + + @ManyToOne + @JsonIgnoreProperties("commissions") + private GameUser gameUser; + + // jhipster-needle-entity-add-field - JHipster will add fields here, do not remove + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Integer getCommission() { + return commission; + } + + public GameCommission commission(Integer commission) { + this.commission = commission; + return this; + } + + public void setCommission(Integer commission) { + this.commission = commission; + } + + public Game getGame() { + return game; + } + + public GameCommission game(Game game) { + this.game = game; + return this; + } + + public void setGame(Game game) { + this.game = game; + } + + public GameUser getGameUser() { + return gameUser; + } + + public GameCommission gameUser(GameUser gameUser) { + this.gameUser = gameUser; + return this; + } + + public void setGameUser(GameUser gameUser) { + this.gameUser = gameUser; + } + // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof GameCommission)) { + return false; + } + return id != null && id.equals(((GameCommission) o).id); + } + + @Override + public int hashCode() { + return 31; + } + + @Override + public String toString() { + return "GameCommission{" + + "id=" + getId() + + ", commission=" + getCommission() + + "}"; + } +} diff --git a/src/main/java/com/mycompany/myapp/domain/GameUser.java b/src/main/java/com/mycompany/myapp/domain/GameUser.java new file mode 100644 index 0000000..6931d12 --- /dev/null +++ b/src/main/java/com/mycompany/myapp/domain/GameUser.java @@ -0,0 +1,122 @@ +package com.mycompany.myapp.domain; + +import org.hibernate.annotations.Cache; +import org.hibernate.annotations.CacheConcurrencyStrategy; + +import javax.persistence.*; + +import java.io.Serializable; +import java.util.Objects; +import java.util.HashSet; +import java.util.Set; + +/** + * A GameUser. + */ +@Entity +@Table(name = "game_user") +@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) +public class GameUser implements Serializable { + + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column(name = "username") + private String username; + + @Column(name = "password") + private String password; + + @OneToMany(mappedBy = "gameUser") + @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) + private Set commissions = new HashSet<>(); + + // jhipster-needle-entity-add-field - JHipster will add fields here, do not remove + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getUsername() { + return username; + } + + public GameUser username(String username) { + this.username = username; + return this; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public GameUser password(String password) { + this.password = password; + return this; + } + + public void setPassword(String password) { + this.password = password; + } + + public Set getCommissions() { + return commissions; + } + + public GameUser commissions(Set gameCommissions) { + this.commissions = gameCommissions; + return this; + } + + public GameUser addCommission(GameCommission gameCommission) { + this.commissions.add(gameCommission); + gameCommission.setGameUser(this); + return this; + } + + public GameUser removeCommission(GameCommission gameCommission) { + this.commissions.remove(gameCommission); + gameCommission.setGameUser(null); + return this; + } + + public void setCommissions(Set gameCommissions) { + this.commissions = gameCommissions; + } + // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof GameUser)) { + return false; + } + return id != null && id.equals(((GameUser) o).id); + } + + @Override + public int hashCode() { + return 31; + } + + @Override + public String toString() { + return "GameUser{" + + "id=" + getId() + + ", username='" + getUsername() + "'" + + ", password='" + getPassword() + "'" + + "}"; + } +} diff --git a/src/main/java/com/mycompany/myapp/domain/Hand.java b/src/main/java/com/mycompany/myapp/domain/Hand.java new file mode 100644 index 0000000..ed5f4b2 --- /dev/null +++ b/src/main/java/com/mycompany/myapp/domain/Hand.java @@ -0,0 +1,126 @@ +package com.mycompany.myapp.domain; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import org.hibernate.annotations.Cache; +import org.hibernate.annotations.CacheConcurrencyStrategy; + +import javax.persistence.*; + +import java.io.Serializable; +import java.util.Objects; +import java.util.HashSet; +import java.util.Set; + +import com.mycompany.myapp.domain.enumeration.HandStatus; + +/** + * A Hand. + */ +@Entity +@Table(name = "hand") +@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) +public class Hand implements Serializable { + + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Enumerated(EnumType.STRING) + @Column(name = "status") + private HandStatus status; + + @OneToMany(mappedBy = "hand") + @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) + private Set bets = new HashSet<>(); + + @ManyToOne + @JsonIgnoreProperties("hands") + private Game game; + + // jhipster-needle-entity-add-field - JHipster will add fields here, do not remove + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public HandStatus getStatus() { + return status; + } + + public Hand status(HandStatus status) { + this.status = status; + return this; + } + + public void setStatus(HandStatus status) { + this.status = status; + } + + public Set getBets() { + return bets; + } + + public Hand bets(Set bets) { + this.bets = bets; + return this; + } + + public Hand addBet(Bet bet) { + this.bets.add(bet); + bet.setHand(this); + return this; + } + + public Hand removeBet(Bet bet) { + this.bets.remove(bet); + bet.setHand(null); + return this; + } + + public void setBets(Set bets) { + this.bets = bets; + } + + public Game getGame() { + return game; + } + + public Hand game(Game game) { + this.game = game; + return this; + } + + public void setGame(Game game) { + this.game = game; + } + // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof Hand)) { + return false; + } + return id != null && id.equals(((Hand) o).id); + } + + @Override + public int hashCode() { + return 31; + } + + @Override + public String toString() { + return "Hand{" + + "id=" + getId() + + ", status='" + getStatus() + "'" + + "}"; + } +} diff --git a/src/main/java/com/mycompany/myapp/domain/enumeration/HandStatus.java b/src/main/java/com/mycompany/myapp/domain/enumeration/HandStatus.java new file mode 100644 index 0000000..45a5ccd --- /dev/null +++ b/src/main/java/com/mycompany/myapp/domain/enumeration/HandStatus.java @@ -0,0 +1,8 @@ +package com.mycompany.myapp.domain.enumeration; + +/** + * The HandStatus enumeration. + */ +public enum HandStatus { + Begin, End +} diff --git a/src/main/java/com/mycompany/myapp/repository/BetRepository.java b/src/main/java/com/mycompany/myapp/repository/BetRepository.java new file mode 100644 index 0000000..2adfde4 --- /dev/null +++ b/src/main/java/com/mycompany/myapp/repository/BetRepository.java @@ -0,0 +1,14 @@ +package com.mycompany.myapp.repository; + +import com.mycompany.myapp.domain.Bet; + +import org.springframework.data.jpa.repository.*; +import org.springframework.stereotype.Repository; + +/** + * Spring Data repository for the Bet entity. + */ +@SuppressWarnings("unused") +@Repository +public interface BetRepository extends JpaRepository { +} diff --git a/src/main/java/com/mycompany/myapp/repository/GameCommissionRepository.java b/src/main/java/com/mycompany/myapp/repository/GameCommissionRepository.java new file mode 100644 index 0000000..4492fff --- /dev/null +++ b/src/main/java/com/mycompany/myapp/repository/GameCommissionRepository.java @@ -0,0 +1,14 @@ +package com.mycompany.myapp.repository; + +import com.mycompany.myapp.domain.GameCommission; + +import org.springframework.data.jpa.repository.*; +import org.springframework.stereotype.Repository; + +/** + * Spring Data repository for the GameCommission entity. + */ +@SuppressWarnings("unused") +@Repository +public interface GameCommissionRepository extends JpaRepository { +} diff --git a/src/main/java/com/mycompany/myapp/repository/GameRepository.java b/src/main/java/com/mycompany/myapp/repository/GameRepository.java new file mode 100644 index 0000000..d429520 --- /dev/null +++ b/src/main/java/com/mycompany/myapp/repository/GameRepository.java @@ -0,0 +1,14 @@ +package com.mycompany.myapp.repository; + +import com.mycompany.myapp.domain.Game; + +import org.springframework.data.jpa.repository.*; +import org.springframework.stereotype.Repository; + +/** + * Spring Data repository for the Game entity. + */ +@SuppressWarnings("unused") +@Repository +public interface GameRepository extends JpaRepository { +} diff --git a/src/main/java/com/mycompany/myapp/repository/GameUserRepository.java b/src/main/java/com/mycompany/myapp/repository/GameUserRepository.java new file mode 100644 index 0000000..ebb8302 --- /dev/null +++ b/src/main/java/com/mycompany/myapp/repository/GameUserRepository.java @@ -0,0 +1,14 @@ +package com.mycompany.myapp.repository; + +import com.mycompany.myapp.domain.GameUser; + +import org.springframework.data.jpa.repository.*; +import org.springframework.stereotype.Repository; + +/** + * Spring Data repository for the GameUser entity. + */ +@SuppressWarnings("unused") +@Repository +public interface GameUserRepository extends JpaRepository { +} diff --git a/src/main/java/com/mycompany/myapp/repository/HandRepository.java b/src/main/java/com/mycompany/myapp/repository/HandRepository.java new file mode 100644 index 0000000..4b49d73 --- /dev/null +++ b/src/main/java/com/mycompany/myapp/repository/HandRepository.java @@ -0,0 +1,14 @@ +package com.mycompany.myapp.repository; + +import com.mycompany.myapp.domain.Hand; + +import org.springframework.data.jpa.repository.*; +import org.springframework.stereotype.Repository; + +/** + * Spring Data repository for the Hand entity. + */ +@SuppressWarnings("unused") +@Repository +public interface HandRepository extends JpaRepository { +} diff --git a/src/main/java/com/mycompany/myapp/web/rest/BetResource.java b/src/main/java/com/mycompany/myapp/web/rest/BetResource.java new file mode 100644 index 0000000..410808f --- /dev/null +++ b/src/main/java/com/mycompany/myapp/web/rest/BetResource.java @@ -0,0 +1,118 @@ +package com.mycompany.myapp.web.rest; + +import com.mycompany.myapp.domain.Bet; +import com.mycompany.myapp.repository.BetRepository; +import com.mycompany.myapp.web.rest.errors.BadRequestAlertException; + +import io.github.jhipster.web.util.HeaderUtil; +import io.github.jhipster.web.util.ResponseUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.ResponseEntity; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.bind.annotation.*; + +import java.net.URI; +import java.net.URISyntaxException; +import java.util.List; +import java.util.Optional; + +/** + * REST controller for managing {@link com.mycompany.myapp.domain.Bet}. + */ +@RestController +@RequestMapping("/api") +@Transactional +public class BetResource { + + private final Logger log = LoggerFactory.getLogger(BetResource.class); + + private static final String ENTITY_NAME = "bet"; + + @Value("${jhipster.clientApp.name}") + private String applicationName; + + private final BetRepository betRepository; + + public BetResource(BetRepository betRepository) { + this.betRepository = betRepository; + } + + /** + * {@code POST /bets} : Create a new bet. + * + * @param bet the bet to create. + * @return the {@link ResponseEntity} with status {@code 201 (Created)} and with body the new bet, or with status {@code 400 (Bad Request)} if the bet has already an ID. + * @throws URISyntaxException if the Location URI syntax is incorrect. + */ + @PostMapping("/bets") + public ResponseEntity createBet(@RequestBody Bet bet) throws URISyntaxException { + log.debug("REST request to save Bet : {}", bet); + if (bet.getId() != null) { + throw new BadRequestAlertException("A new bet cannot already have an ID", ENTITY_NAME, "idexists"); + } + Bet result = betRepository.save(bet); + return ResponseEntity.created(new URI("/api/bets/" + result.getId())) + .headers(HeaderUtil.createEntityCreationAlert(applicationName, false, ENTITY_NAME, result.getId().toString())) + .body(result); + } + + /** + * {@code PUT /bets} : Updates an existing bet. + * + * @param bet the bet to update. + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body the updated bet, + * or with status {@code 400 (Bad Request)} if the bet is not valid, + * or with status {@code 500 (Internal Server Error)} if the bet couldn't be updated. + * @throws URISyntaxException if the Location URI syntax is incorrect. + */ + @PutMapping("/bets") + public ResponseEntity updateBet(@RequestBody Bet bet) throws URISyntaxException { + log.debug("REST request to update Bet : {}", bet); + if (bet.getId() == null) { + throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull"); + } + Bet result = betRepository.save(bet); + return ResponseEntity.ok() + .headers(HeaderUtil.createEntityUpdateAlert(applicationName, false, ENTITY_NAME, bet.getId().toString())) + .body(result); + } + + /** + * {@code GET /bets} : get all the bets. + * + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and the list of bets in body. + */ + @GetMapping("/bets") + public List getAllBets() { + log.debug("REST request to get all Bets"); + return betRepository.findAll(); + } + + /** + * {@code GET /bets/:id} : get the "id" bet. + * + * @param id the id of the bet to retrieve. + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body the bet, or with status {@code 404 (Not Found)}. + */ + @GetMapping("/bets/{id}") + public ResponseEntity getBet(@PathVariable Long id) { + log.debug("REST request to get Bet : {}", id); + Optional bet = betRepository.findById(id); + return ResponseUtil.wrapOrNotFound(bet); + } + + /** + * {@code DELETE /bets/:id} : delete the "id" bet. + * + * @param id the id of the bet to delete. + * @return the {@link ResponseEntity} with status {@code 204 (NO_CONTENT)}. + */ + @DeleteMapping("/bets/{id}") + public ResponseEntity deleteBet(@PathVariable Long id) { + log.debug("REST request to delete Bet : {}", id); + betRepository.deleteById(id); + return ResponseEntity.noContent().headers(HeaderUtil.createEntityDeletionAlert(applicationName, false, ENTITY_NAME, id.toString())).build(); + } +} diff --git a/src/main/java/com/mycompany/myapp/web/rest/GameCommissionResource.java b/src/main/java/com/mycompany/myapp/web/rest/GameCommissionResource.java new file mode 100644 index 0000000..6def2ef --- /dev/null +++ b/src/main/java/com/mycompany/myapp/web/rest/GameCommissionResource.java @@ -0,0 +1,118 @@ +package com.mycompany.myapp.web.rest; + +import com.mycompany.myapp.domain.GameCommission; +import com.mycompany.myapp.repository.GameCommissionRepository; +import com.mycompany.myapp.web.rest.errors.BadRequestAlertException; + +import io.github.jhipster.web.util.HeaderUtil; +import io.github.jhipster.web.util.ResponseUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.ResponseEntity; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.bind.annotation.*; + +import java.net.URI; +import java.net.URISyntaxException; +import java.util.List; +import java.util.Optional; + +/** + * REST controller for managing {@link com.mycompany.myapp.domain.GameCommission}. + */ +@RestController +@RequestMapping("/api") +@Transactional +public class GameCommissionResource { + + private final Logger log = LoggerFactory.getLogger(GameCommissionResource.class); + + private static final String ENTITY_NAME = "gameCommission"; + + @Value("${jhipster.clientApp.name}") + private String applicationName; + + private final GameCommissionRepository gameCommissionRepository; + + public GameCommissionResource(GameCommissionRepository gameCommissionRepository) { + this.gameCommissionRepository = gameCommissionRepository; + } + + /** + * {@code POST /game-commissions} : Create a new gameCommission. + * + * @param gameCommission the gameCommission to create. + * @return the {@link ResponseEntity} with status {@code 201 (Created)} and with body the new gameCommission, or with status {@code 400 (Bad Request)} if the gameCommission has already an ID. + * @throws URISyntaxException if the Location URI syntax is incorrect. + */ + @PostMapping("/game-commissions") + public ResponseEntity createGameCommission(@RequestBody GameCommission gameCommission) throws URISyntaxException { + log.debug("REST request to save GameCommission : {}", gameCommission); + if (gameCommission.getId() != null) { + throw new BadRequestAlertException("A new gameCommission cannot already have an ID", ENTITY_NAME, "idexists"); + } + GameCommission result = gameCommissionRepository.save(gameCommission); + return ResponseEntity.created(new URI("/api/game-commissions/" + result.getId())) + .headers(HeaderUtil.createEntityCreationAlert(applicationName, false, ENTITY_NAME, result.getId().toString())) + .body(result); + } + + /** + * {@code PUT /game-commissions} : Updates an existing gameCommission. + * + * @param gameCommission the gameCommission to update. + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body the updated gameCommission, + * or with status {@code 400 (Bad Request)} if the gameCommission is not valid, + * or with status {@code 500 (Internal Server Error)} if the gameCommission couldn't be updated. + * @throws URISyntaxException if the Location URI syntax is incorrect. + */ + @PutMapping("/game-commissions") + public ResponseEntity updateGameCommission(@RequestBody GameCommission gameCommission) throws URISyntaxException { + log.debug("REST request to update GameCommission : {}", gameCommission); + if (gameCommission.getId() == null) { + throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull"); + } + GameCommission result = gameCommissionRepository.save(gameCommission); + return ResponseEntity.ok() + .headers(HeaderUtil.createEntityUpdateAlert(applicationName, false, ENTITY_NAME, gameCommission.getId().toString())) + .body(result); + } + + /** + * {@code GET /game-commissions} : get all the gameCommissions. + * + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and the list of gameCommissions in body. + */ + @GetMapping("/game-commissions") + public List getAllGameCommissions() { + log.debug("REST request to get all GameCommissions"); + return gameCommissionRepository.findAll(); + } + + /** + * {@code GET /game-commissions/:id} : get the "id" gameCommission. + * + * @param id the id of the gameCommission to retrieve. + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body the gameCommission, or with status {@code 404 (Not Found)}. + */ + @GetMapping("/game-commissions/{id}") + public ResponseEntity getGameCommission(@PathVariable Long id) { + log.debug("REST request to get GameCommission : {}", id); + Optional gameCommission = gameCommissionRepository.findById(id); + return ResponseUtil.wrapOrNotFound(gameCommission); + } + + /** + * {@code DELETE /game-commissions/:id} : delete the "id" gameCommission. + * + * @param id the id of the gameCommission to delete. + * @return the {@link ResponseEntity} with status {@code 204 (NO_CONTENT)}. + */ + @DeleteMapping("/game-commissions/{id}") + public ResponseEntity deleteGameCommission(@PathVariable Long id) { + log.debug("REST request to delete GameCommission : {}", id); + gameCommissionRepository.deleteById(id); + return ResponseEntity.noContent().headers(HeaderUtil.createEntityDeletionAlert(applicationName, false, ENTITY_NAME, id.toString())).build(); + } +} diff --git a/src/main/java/com/mycompany/myapp/web/rest/GameResource.java b/src/main/java/com/mycompany/myapp/web/rest/GameResource.java new file mode 100644 index 0000000..5d63a02 --- /dev/null +++ b/src/main/java/com/mycompany/myapp/web/rest/GameResource.java @@ -0,0 +1,118 @@ +package com.mycompany.myapp.web.rest; + +import com.mycompany.myapp.domain.Game; +import com.mycompany.myapp.repository.GameRepository; +import com.mycompany.myapp.web.rest.errors.BadRequestAlertException; + +import io.github.jhipster.web.util.HeaderUtil; +import io.github.jhipster.web.util.ResponseUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.ResponseEntity; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.bind.annotation.*; + +import java.net.URI; +import java.net.URISyntaxException; +import java.util.List; +import java.util.Optional; + +/** + * REST controller for managing {@link com.mycompany.myapp.domain.Game}. + */ +@RestController +@RequestMapping("/api") +@Transactional +public class GameResource { + + private final Logger log = LoggerFactory.getLogger(GameResource.class); + + private static final String ENTITY_NAME = "game"; + + @Value("${jhipster.clientApp.name}") + private String applicationName; + + private final GameRepository gameRepository; + + public GameResource(GameRepository gameRepository) { + this.gameRepository = gameRepository; + } + + /** + * {@code POST /games} : Create a new game. + * + * @param game the game to create. + * @return the {@link ResponseEntity} with status {@code 201 (Created)} and with body the new game, or with status {@code 400 (Bad Request)} if the game has already an ID. + * @throws URISyntaxException if the Location URI syntax is incorrect. + */ + @PostMapping("/games") + public ResponseEntity createGame(@RequestBody Game game) throws URISyntaxException { + log.debug("REST request to save Game : {}", game); + if (game.getId() != null) { + throw new BadRequestAlertException("A new game cannot already have an ID", ENTITY_NAME, "idexists"); + } + Game result = gameRepository.save(game); + return ResponseEntity.created(new URI("/api/games/" + result.getId())) + .headers(HeaderUtil.createEntityCreationAlert(applicationName, false, ENTITY_NAME, result.getId().toString())) + .body(result); + } + + /** + * {@code PUT /games} : Updates an existing game. + * + * @param game the game to update. + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body the updated game, + * or with status {@code 400 (Bad Request)} if the game is not valid, + * or with status {@code 500 (Internal Server Error)} if the game couldn't be updated. + * @throws URISyntaxException if the Location URI syntax is incorrect. + */ + @PutMapping("/games") + public ResponseEntity updateGame(@RequestBody Game game) throws URISyntaxException { + log.debug("REST request to update Game : {}", game); + if (game.getId() == null) { + throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull"); + } + Game result = gameRepository.save(game); + return ResponseEntity.ok() + .headers(HeaderUtil.createEntityUpdateAlert(applicationName, false, ENTITY_NAME, game.getId().toString())) + .body(result); + } + + /** + * {@code GET /games} : get all the games. + * + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and the list of games in body. + */ + @GetMapping("/games") + public List getAllGames() { + log.debug("REST request to get all Games"); + return gameRepository.findAll(); + } + + /** + * {@code GET /games/:id} : get the "id" game. + * + * @param id the id of the game to retrieve. + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body the game, or with status {@code 404 (Not Found)}. + */ + @GetMapping("/games/{id}") + public ResponseEntity getGame(@PathVariable Long id) { + log.debug("REST request to get Game : {}", id); + Optional game = gameRepository.findById(id); + return ResponseUtil.wrapOrNotFound(game); + } + + /** + * {@code DELETE /games/:id} : delete the "id" game. + * + * @param id the id of the game to delete. + * @return the {@link ResponseEntity} with status {@code 204 (NO_CONTENT)}. + */ + @DeleteMapping("/games/{id}") + public ResponseEntity deleteGame(@PathVariable Long id) { + log.debug("REST request to delete Game : {}", id); + gameRepository.deleteById(id); + return ResponseEntity.noContent().headers(HeaderUtil.createEntityDeletionAlert(applicationName, false, ENTITY_NAME, id.toString())).build(); + } +} diff --git a/src/main/java/com/mycompany/myapp/web/rest/GameUserResource.java b/src/main/java/com/mycompany/myapp/web/rest/GameUserResource.java new file mode 100644 index 0000000..f06907e --- /dev/null +++ b/src/main/java/com/mycompany/myapp/web/rest/GameUserResource.java @@ -0,0 +1,118 @@ +package com.mycompany.myapp.web.rest; + +import com.mycompany.myapp.domain.GameUser; +import com.mycompany.myapp.repository.GameUserRepository; +import com.mycompany.myapp.web.rest.errors.BadRequestAlertException; + +import io.github.jhipster.web.util.HeaderUtil; +import io.github.jhipster.web.util.ResponseUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.ResponseEntity; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.bind.annotation.*; + +import java.net.URI; +import java.net.URISyntaxException; +import java.util.List; +import java.util.Optional; + +/** + * REST controller for managing {@link com.mycompany.myapp.domain.GameUser}. + */ +@RestController +@RequestMapping("/api") +@Transactional +public class GameUserResource { + + private final Logger log = LoggerFactory.getLogger(GameUserResource.class); + + private static final String ENTITY_NAME = "gameUser"; + + @Value("${jhipster.clientApp.name}") + private String applicationName; + + private final GameUserRepository gameUserRepository; + + public GameUserResource(GameUserRepository gameUserRepository) { + this.gameUserRepository = gameUserRepository; + } + + /** + * {@code POST /game-users} : Create a new gameUser. + * + * @param gameUser the gameUser to create. + * @return the {@link ResponseEntity} with status {@code 201 (Created)} and with body the new gameUser, or with status {@code 400 (Bad Request)} if the gameUser has already an ID. + * @throws URISyntaxException if the Location URI syntax is incorrect. + */ + @PostMapping("/game-users") + public ResponseEntity createGameUser(@RequestBody GameUser gameUser) throws URISyntaxException { + log.debug("REST request to save GameUser : {}", gameUser); + if (gameUser.getId() != null) { + throw new BadRequestAlertException("A new gameUser cannot already have an ID", ENTITY_NAME, "idexists"); + } + GameUser result = gameUserRepository.save(gameUser); + return ResponseEntity.created(new URI("/api/game-users/" + result.getId())) + .headers(HeaderUtil.createEntityCreationAlert(applicationName, false, ENTITY_NAME, result.getId().toString())) + .body(result); + } + + /** + * {@code PUT /game-users} : Updates an existing gameUser. + * + * @param gameUser the gameUser to update. + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body the updated gameUser, + * or with status {@code 400 (Bad Request)} if the gameUser is not valid, + * or with status {@code 500 (Internal Server Error)} if the gameUser couldn't be updated. + * @throws URISyntaxException if the Location URI syntax is incorrect. + */ + @PutMapping("/game-users") + public ResponseEntity updateGameUser(@RequestBody GameUser gameUser) throws URISyntaxException { + log.debug("REST request to update GameUser : {}", gameUser); + if (gameUser.getId() == null) { + throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull"); + } + GameUser result = gameUserRepository.save(gameUser); + return ResponseEntity.ok() + .headers(HeaderUtil.createEntityUpdateAlert(applicationName, false, ENTITY_NAME, gameUser.getId().toString())) + .body(result); + } + + /** + * {@code GET /game-users} : get all the gameUsers. + * + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and the list of gameUsers in body. + */ + @GetMapping("/game-users") + public List getAllGameUsers() { + log.debug("REST request to get all GameUsers"); + return gameUserRepository.findAll(); + } + + /** + * {@code GET /game-users/:id} : get the "id" gameUser. + * + * @param id the id of the gameUser to retrieve. + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body the gameUser, or with status {@code 404 (Not Found)}. + */ + @GetMapping("/game-users/{id}") + public ResponseEntity getGameUser(@PathVariable Long id) { + log.debug("REST request to get GameUser : {}", id); + Optional gameUser = gameUserRepository.findById(id); + return ResponseUtil.wrapOrNotFound(gameUser); + } + + /** + * {@code DELETE /game-users/:id} : delete the "id" gameUser. + * + * @param id the id of the gameUser to delete. + * @return the {@link ResponseEntity} with status {@code 204 (NO_CONTENT)}. + */ + @DeleteMapping("/game-users/{id}") + public ResponseEntity deleteGameUser(@PathVariable Long id) { + log.debug("REST request to delete GameUser : {}", id); + gameUserRepository.deleteById(id); + return ResponseEntity.noContent().headers(HeaderUtil.createEntityDeletionAlert(applicationName, false, ENTITY_NAME, id.toString())).build(); + } +} diff --git a/src/main/java/com/mycompany/myapp/web/rest/HandResource.java b/src/main/java/com/mycompany/myapp/web/rest/HandResource.java new file mode 100644 index 0000000..6aa7e55 --- /dev/null +++ b/src/main/java/com/mycompany/myapp/web/rest/HandResource.java @@ -0,0 +1,118 @@ +package com.mycompany.myapp.web.rest; + +import com.mycompany.myapp.domain.Hand; +import com.mycompany.myapp.repository.HandRepository; +import com.mycompany.myapp.web.rest.errors.BadRequestAlertException; + +import io.github.jhipster.web.util.HeaderUtil; +import io.github.jhipster.web.util.ResponseUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.ResponseEntity; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.bind.annotation.*; + +import java.net.URI; +import java.net.URISyntaxException; +import java.util.List; +import java.util.Optional; + +/** + * REST controller for managing {@link com.mycompany.myapp.domain.Hand}. + */ +@RestController +@RequestMapping("/api") +@Transactional +public class HandResource { + + private final Logger log = LoggerFactory.getLogger(HandResource.class); + + private static final String ENTITY_NAME = "hand"; + + @Value("${jhipster.clientApp.name}") + private String applicationName; + + private final HandRepository handRepository; + + public HandResource(HandRepository handRepository) { + this.handRepository = handRepository; + } + + /** + * {@code POST /hands} : Create a new hand. + * + * @param hand the hand to create. + * @return the {@link ResponseEntity} with status {@code 201 (Created)} and with body the new hand, or with status {@code 400 (Bad Request)} if the hand has already an ID. + * @throws URISyntaxException if the Location URI syntax is incorrect. + */ + @PostMapping("/hands") + public ResponseEntity createHand(@RequestBody Hand hand) throws URISyntaxException { + log.debug("REST request to save Hand : {}", hand); + if (hand.getId() != null) { + throw new BadRequestAlertException("A new hand cannot already have an ID", ENTITY_NAME, "idexists"); + } + Hand result = handRepository.save(hand); + return ResponseEntity.created(new URI("/api/hands/" + result.getId())) + .headers(HeaderUtil.createEntityCreationAlert(applicationName, false, ENTITY_NAME, result.getId().toString())) + .body(result); + } + + /** + * {@code PUT /hands} : Updates an existing hand. + * + * @param hand the hand to update. + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body the updated hand, + * or with status {@code 400 (Bad Request)} if the hand is not valid, + * or with status {@code 500 (Internal Server Error)} if the hand couldn't be updated. + * @throws URISyntaxException if the Location URI syntax is incorrect. + */ + @PutMapping("/hands") + public ResponseEntity updateHand(@RequestBody Hand hand) throws URISyntaxException { + log.debug("REST request to update Hand : {}", hand); + if (hand.getId() == null) { + throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull"); + } + Hand result = handRepository.save(hand); + return ResponseEntity.ok() + .headers(HeaderUtil.createEntityUpdateAlert(applicationName, false, ENTITY_NAME, hand.getId().toString())) + .body(result); + } + + /** + * {@code GET /hands} : get all the hands. + * + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and the list of hands in body. + */ + @GetMapping("/hands") + public List getAllHands() { + log.debug("REST request to get all Hands"); + return handRepository.findAll(); + } + + /** + * {@code GET /hands/:id} : get the "id" hand. + * + * @param id the id of the hand to retrieve. + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body the hand, or with status {@code 404 (Not Found)}. + */ + @GetMapping("/hands/{id}") + public ResponseEntity getHand(@PathVariable Long id) { + log.debug("REST request to get Hand : {}", id); + Optional hand = handRepository.findById(id); + return ResponseUtil.wrapOrNotFound(hand); + } + + /** + * {@code DELETE /hands/:id} : delete the "id" hand. + * + * @param id the id of the hand to delete. + * @return the {@link ResponseEntity} with status {@code 204 (NO_CONTENT)}. + */ + @DeleteMapping("/hands/{id}") + public ResponseEntity deleteHand(@PathVariable Long id) { + log.debug("REST request to delete Hand : {}", id); + handRepository.deleteById(id); + return ResponseEntity.noContent().headers(HeaderUtil.createEntityDeletionAlert(applicationName, false, ENTITY_NAME, id.toString())).build(); + } +} diff --git a/src/main/resources/config/liquibase/changelog/20200329102800_added_entity_GameUser.xml b/src/main/resources/config/liquibase/changelog/20200329102800_added_entity_GameUser.xml new file mode 100644 index 0000000..93bb8b5 --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20200329102800_added_entity_GameUser.xml @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/config/liquibase/changelog/20200329102900_added_entity_GameCommission.xml b/src/main/resources/config/liquibase/changelog/20200329102900_added_entity_GameCommission.xml new file mode 100644 index 0000000..249096f --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20200329102900_added_entity_GameCommission.xml @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/config/liquibase/changelog/20200329102900_added_entity_constraints_GameCommission.xml b/src/main/resources/config/liquibase/changelog/20200329102900_added_entity_constraints_GameCommission.xml new file mode 100644 index 0000000..d5e9bc1 --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20200329102900_added_entity_constraints_GameCommission.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + diff --git a/src/main/resources/config/liquibase/changelog/20200329103000_added_entity_Game.xml b/src/main/resources/config/liquibase/changelog/20200329103000_added_entity_Game.xml new file mode 100644 index 0000000..585d473 --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20200329103000_added_entity_Game.xml @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/config/liquibase/changelog/20200329103100_added_entity_Bet.xml b/src/main/resources/config/liquibase/changelog/20200329103100_added_entity_Bet.xml new file mode 100644 index 0000000..e197f02 --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20200329103100_added_entity_Bet.xml @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/config/liquibase/changelog/20200329103100_added_entity_constraints_Bet.xml b/src/main/resources/config/liquibase/changelog/20200329103100_added_entity_constraints_Bet.xml new file mode 100644 index 0000000..39bd99b --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20200329103100_added_entity_constraints_Bet.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + diff --git a/src/main/resources/config/liquibase/changelog/20200329103200_added_entity_Hand.xml b/src/main/resources/config/liquibase/changelog/20200329103200_added_entity_Hand.xml new file mode 100644 index 0000000..39ea219 --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20200329103200_added_entity_Hand.xml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/config/liquibase/changelog/20200329103200_added_entity_constraints_Hand.xml b/src/main/resources/config/liquibase/changelog/20200329103200_added_entity_constraints_Hand.xml new file mode 100644 index 0000000..4431614 --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20200329103200_added_entity_constraints_Hand.xml @@ -0,0 +1,18 @@ + + + + + + + + + diff --git a/src/main/resources/config/liquibase/fake-data/bet.csv b/src/main/resources/config/liquibase/fake-data/bet.csv new file mode 100644 index 0000000..37a258b --- /dev/null +++ b/src/main/resources/config/liquibase/fake-data/bet.csv @@ -0,0 +1,11 @@ +id;chips +1;25203 +2;19203 +3;31451 +4;8899 +5;1168 +6;32922 +7;28403 +8;78287 +9;17832 +10;47844 diff --git a/src/main/resources/config/liquibase/fake-data/game.csv b/src/main/resources/config/liquibase/fake-data/game.csv new file mode 100644 index 0000000..a6d440f --- /dev/null +++ b/src/main/resources/config/liquibase/fake-data/game.csv @@ -0,0 +1,11 @@ +id;name +1;override calculate connect +2;Dynamic Creative vortals +3;TCP streamline 4th generation +4;bottom-line user-facing Bike +5;Tasty Rubber Fish Borders +6;mint green Marketing Montana +7;JBOD Ghana Niue +8;even-keeled invoice JSON +9;Lock models +10;orchid Cambridgeshire diff --git a/src/main/resources/config/liquibase/fake-data/game_commission.csv b/src/main/resources/config/liquibase/fake-data/game_commission.csv new file mode 100644 index 0000000..110e9c6 --- /dev/null +++ b/src/main/resources/config/liquibase/fake-data/game_commission.csv @@ -0,0 +1,11 @@ +id;commission +1;87478 +2;49175 +3;81846 +4;72354 +5;3005 +6;64675 +7;92359 +8;92285 +9;71424 +10;85739 diff --git a/src/main/resources/config/liquibase/fake-data/game_user.csv b/src/main/resources/config/liquibase/fake-data/game_user.csv new file mode 100644 index 0000000..bd9d860 --- /dev/null +++ b/src/main/resources/config/liquibase/fake-data/game_user.csv @@ -0,0 +1,11 @@ +id;username;password +1;input Square Maryland;vortals Gorgeous indigo +2;niches asynchronous Games;actuating Group +3;Synergistic Managed;Uganda Shilling +4;Director architecture;deposit +5;interfaces Personal Loan Account;invoice Specialist Devolved +6;Plains Paradigm Generic;Libyan Dinar Handmade +7;calculating Cambridgeshire Digitized;application Belarus +8;yellow Rubber seize;leverage Money Market Account hack +9;Cheese;payment South Carolina Checking Account +10;compress;leading-edge Latvian Lats diff --git a/src/main/resources/config/liquibase/fake-data/hand.csv b/src/main/resources/config/liquibase/fake-data/hand.csv new file mode 100644 index 0000000..714040b --- /dev/null +++ b/src/main/resources/config/liquibase/fake-data/hand.csv @@ -0,0 +1,11 @@ +id;status +1;End +2;Begin +3;End +4;End +5;End +6;End +7;Begin +8;Begin +9;Begin +10;End diff --git a/src/main/resources/config/liquibase/master.xml b/src/main/resources/config/liquibase/master.xml index 2ddb55e..7c6ce93 100644 --- a/src/main/resources/config/liquibase/master.xml +++ b/src/main/resources/config/liquibase/master.xml @@ -14,6 +14,14 @@ + + + + + + + + diff --git a/src/main/webapp/app/entities/bet/bet-delete-dialog.component.html b/src/main/webapp/app/entities/bet/bet-delete-dialog.component.html new file mode 100644 index 0000000..30dac14 --- /dev/null +++ b/src/main/webapp/app/entities/bet/bet-delete-dialog.component.html @@ -0,0 +1,24 @@ +
+ + + + + +
diff --git a/src/main/webapp/app/entities/bet/bet-delete-dialog.component.ts b/src/main/webapp/app/entities/bet/bet-delete-dialog.component.ts new file mode 100644 index 0000000..81a79e1 --- /dev/null +++ b/src/main/webapp/app/entities/bet/bet-delete-dialog.component.ts @@ -0,0 +1,26 @@ +import { Component } from '@angular/core'; +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; +import { JhiEventManager } from 'ng-jhipster'; + +import { IBet } from 'app/shared/model/bet.model'; +import { BetService } from './bet.service'; + +@Component({ + templateUrl: './bet-delete-dialog.component.html' +}) +export class BetDeleteDialogComponent { + bet?: IBet; + + constructor(protected betService: BetService, public activeModal: NgbActiveModal, protected eventManager: JhiEventManager) {} + + cancel(): void { + this.activeModal.dismiss(); + } + + confirmDelete(id: number): void { + this.betService.delete(id).subscribe(() => { + this.eventManager.broadcast('betListModification'); + this.activeModal.close(); + }); + } +} diff --git a/src/main/webapp/app/entities/bet/bet-detail.component.html b/src/main/webapp/app/entities/bet/bet-detail.component.html new file mode 100644 index 0000000..2abfbd3 --- /dev/null +++ b/src/main/webapp/app/entities/bet/bet-detail.component.html @@ -0,0 +1,42 @@ +
+
+
+

Bet {{ bet.id }}

+ +
+ + + +
+
Chips
+
+ {{ bet.chips }} +
+
User
+
+ +
+
Hand
+
+ +
+
+ + + + +
+
+
diff --git a/src/main/webapp/app/entities/bet/bet-detail.component.ts b/src/main/webapp/app/entities/bet/bet-detail.component.ts new file mode 100644 index 0000000..b3ee159 --- /dev/null +++ b/src/main/webapp/app/entities/bet/bet-detail.component.ts @@ -0,0 +1,22 @@ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; + +import { IBet } from 'app/shared/model/bet.model'; + +@Component({ + selector: 'jhi-bet-detail', + templateUrl: './bet-detail.component.html' +}) +export class BetDetailComponent implements OnInit { + bet: IBet | null = null; + + constructor(protected activatedRoute: ActivatedRoute) {} + + ngOnInit(): void { + this.activatedRoute.data.subscribe(({ bet }) => (this.bet = bet)); + } + + previousState(): void { + window.history.back(); + } +} diff --git a/src/main/webapp/app/entities/bet/bet-update.component.html b/src/main/webapp/app/entities/bet/bet-update.component.html new file mode 100644 index 0000000..c55bc73 --- /dev/null +++ b/src/main/webapp/app/entities/bet/bet-update.component.html @@ -0,0 +1,48 @@ +
+
+
+

Create or edit a Bet

+ +
+ + +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+
+ +
+ + + +
+
+
+
diff --git a/src/main/webapp/app/entities/bet/bet-update.component.ts b/src/main/webapp/app/entities/bet/bet-update.component.ts new file mode 100644 index 0000000..108cfb3 --- /dev/null +++ b/src/main/webapp/app/entities/bet/bet-update.component.ts @@ -0,0 +1,103 @@ +import { Component, OnInit } from '@angular/core'; +import { HttpResponse } from '@angular/common/http'; +// eslint-disable-next-line @typescript-eslint/no-unused-vars +import { FormBuilder, Validators } from '@angular/forms'; +import { ActivatedRoute } from '@angular/router'; +import { Observable } from 'rxjs'; + +import { IBet, Bet } from 'app/shared/model/bet.model'; +import { BetService } from './bet.service'; +import { IGameUser } from 'app/shared/model/game-user.model'; +import { GameUserService } from 'app/entities/game-user/game-user.service'; +import { IHand } from 'app/shared/model/hand.model'; +import { HandService } from 'app/entities/hand/hand.service'; + +type SelectableEntity = IGameUser | IHand; + +@Component({ + selector: 'jhi-bet-update', + templateUrl: './bet-update.component.html' +}) +export class BetUpdateComponent implements OnInit { + isSaving = false; + gameusers: IGameUser[] = []; + hands: IHand[] = []; + + editForm = this.fb.group({ + id: [], + chips: [], + user: [], + hand: [] + }); + + constructor( + protected betService: BetService, + protected gameUserService: GameUserService, + protected handService: HandService, + protected activatedRoute: ActivatedRoute, + private fb: FormBuilder + ) {} + + ngOnInit(): void { + this.activatedRoute.data.subscribe(({ bet }) => { + this.updateForm(bet); + + this.gameUserService.query().subscribe((res: HttpResponse) => (this.gameusers = res.body || [])); + + this.handService.query().subscribe((res: HttpResponse) => (this.hands = res.body || [])); + }); + } + + updateForm(bet: IBet): void { + this.editForm.patchValue({ + id: bet.id, + chips: bet.chips, + user: bet.user, + hand: bet.hand + }); + } + + previousState(): void { + window.history.back(); + } + + save(): void { + this.isSaving = true; + const bet = this.createFromForm(); + if (bet.id !== undefined) { + this.subscribeToSaveResponse(this.betService.update(bet)); + } else { + this.subscribeToSaveResponse(this.betService.create(bet)); + } + } + + private createFromForm(): IBet { + return { + ...new Bet(), + id: this.editForm.get(['id'])!.value, + chips: this.editForm.get(['chips'])!.value, + user: this.editForm.get(['user'])!.value, + hand: this.editForm.get(['hand'])!.value + }; + } + + protected subscribeToSaveResponse(result: Observable>): void { + result.subscribe( + () => this.onSaveSuccess(), + () => this.onSaveError() + ); + } + + protected onSaveSuccess(): void { + this.isSaving = false; + this.previousState(); + } + + protected onSaveError(): void { + this.isSaving = false; + } + + trackById(index: number, item: SelectableEntity): any { + return item.id; + } +} diff --git a/src/main/webapp/app/entities/bet/bet.component.html b/src/main/webapp/app/entities/bet/bet.component.html new file mode 100644 index 0000000..a8cbcc7 --- /dev/null +++ b/src/main/webapp/app/entities/bet/bet.component.html @@ -0,0 +1,73 @@ +
+

+ Bets + + +

+ + + + + +
+ No bets found +
+ +
+ + + + + + + + + + + + + + + + + + + +
IDChipsUserHand
{{ bet.id }}{{ bet.chips }} + + + + +
+ + + + + +
+
+
+
diff --git a/src/main/webapp/app/entities/bet/bet.component.ts b/src/main/webapp/app/entities/bet/bet.component.ts new file mode 100644 index 0000000..302cb2e --- /dev/null +++ b/src/main/webapp/app/entities/bet/bet.component.ts @@ -0,0 +1,49 @@ +import { Component, OnInit, OnDestroy } from '@angular/core'; +import { HttpResponse } from '@angular/common/http'; +import { Subscription } from 'rxjs'; +import { JhiEventManager } from 'ng-jhipster'; +import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; + +import { IBet } from 'app/shared/model/bet.model'; +import { BetService } from './bet.service'; +import { BetDeleteDialogComponent } from './bet-delete-dialog.component'; + +@Component({ + selector: 'jhi-bet', + templateUrl: './bet.component.html' +}) +export class BetComponent implements OnInit, OnDestroy { + bets?: IBet[]; + eventSubscriber?: Subscription; + + constructor(protected betService: BetService, protected eventManager: JhiEventManager, protected modalService: NgbModal) {} + + loadAll(): void { + this.betService.query().subscribe((res: HttpResponse) => (this.bets = res.body || [])); + } + + ngOnInit(): void { + this.loadAll(); + this.registerChangeInBets(); + } + + ngOnDestroy(): void { + if (this.eventSubscriber) { + this.eventManager.destroy(this.eventSubscriber); + } + } + + trackId(index: number, item: IBet): number { + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + return item.id!; + } + + registerChangeInBets(): void { + this.eventSubscriber = this.eventManager.subscribe('betListModification', () => this.loadAll()); + } + + delete(bet: IBet): void { + const modalRef = this.modalService.open(BetDeleteDialogComponent, { size: 'lg', backdrop: 'static' }); + modalRef.componentInstance.bet = bet; + } +} diff --git a/src/main/webapp/app/entities/bet/bet.module.ts b/src/main/webapp/app/entities/bet/bet.module.ts new file mode 100644 index 0000000..64c6997 --- /dev/null +++ b/src/main/webapp/app/entities/bet/bet.module.ts @@ -0,0 +1,16 @@ +import { NgModule } from '@angular/core'; +import { RouterModule } from '@angular/router'; + +import { AdminSharedModule } from 'app/shared/shared.module'; +import { BetComponent } from './bet.component'; +import { BetDetailComponent } from './bet-detail.component'; +import { BetUpdateComponent } from './bet-update.component'; +import { BetDeleteDialogComponent } from './bet-delete-dialog.component'; +import { betRoute } from './bet.route'; + +@NgModule({ + imports: [AdminSharedModule, RouterModule.forChild(betRoute)], + declarations: [BetComponent, BetDetailComponent, BetUpdateComponent, BetDeleteDialogComponent], + entryComponents: [BetDeleteDialogComponent] +}) +export class AdminBetModule {} diff --git a/src/main/webapp/app/entities/bet/bet.route.ts b/src/main/webapp/app/entities/bet/bet.route.ts new file mode 100644 index 0000000..cc58818 --- /dev/null +++ b/src/main/webapp/app/entities/bet/bet.route.ts @@ -0,0 +1,83 @@ +import { Injectable } from '@angular/core'; +import { HttpResponse } from '@angular/common/http'; +import { Resolve, ActivatedRouteSnapshot, Routes, Router } from '@angular/router'; +import { Observable, of, EMPTY } from 'rxjs'; +import { flatMap } from 'rxjs/operators'; + +import { Authority } from 'app/shared/constants/authority.constants'; +import { UserRouteAccessService } from 'app/core/auth/user-route-access-service'; +import { IBet, Bet } from 'app/shared/model/bet.model'; +import { BetService } from './bet.service'; +import { BetComponent } from './bet.component'; +import { BetDetailComponent } from './bet-detail.component'; +import { BetUpdateComponent } from './bet-update.component'; + +@Injectable({ providedIn: 'root' }) +export class BetResolve implements Resolve { + constructor(private service: BetService, private router: Router) {} + + resolve(route: ActivatedRouteSnapshot): Observable | Observable { + const id = route.params['id']; + if (id) { + return this.service.find(id).pipe( + flatMap((bet: HttpResponse) => { + if (bet.body) { + return of(bet.body); + } else { + this.router.navigate(['404']); + return EMPTY; + } + }) + ); + } + return of(new Bet()); + } +} + +export const betRoute: Routes = [ + { + path: '', + component: BetComponent, + data: { + authorities: [Authority.USER], + pageTitle: 'Bets' + }, + canActivate: [UserRouteAccessService] + }, + { + path: ':id/view', + component: BetDetailComponent, + resolve: { + bet: BetResolve + }, + data: { + authorities: [Authority.USER], + pageTitle: 'Bets' + }, + canActivate: [UserRouteAccessService] + }, + { + path: 'new', + component: BetUpdateComponent, + resolve: { + bet: BetResolve + }, + data: { + authorities: [Authority.USER], + pageTitle: 'Bets' + }, + canActivate: [UserRouteAccessService] + }, + { + path: ':id/edit', + component: BetUpdateComponent, + resolve: { + bet: BetResolve + }, + data: { + authorities: [Authority.USER], + pageTitle: 'Bets' + }, + canActivate: [UserRouteAccessService] + } +]; diff --git a/src/main/webapp/app/entities/bet/bet.service.ts b/src/main/webapp/app/entities/bet/bet.service.ts new file mode 100644 index 0000000..2013242 --- /dev/null +++ b/src/main/webapp/app/entities/bet/bet.service.ts @@ -0,0 +1,38 @@ +import { Injectable } from '@angular/core'; +import { HttpClient, HttpResponse } from '@angular/common/http'; +import { Observable } from 'rxjs'; + +import { SERVER_API_URL } from 'app/app.constants'; +import { createRequestOption } from 'app/shared/util/request-util'; +import { IBet } from 'app/shared/model/bet.model'; + +type EntityResponseType = HttpResponse; +type EntityArrayResponseType = HttpResponse; + +@Injectable({ providedIn: 'root' }) +export class BetService { + public resourceUrl = SERVER_API_URL + 'api/bets'; + + constructor(protected http: HttpClient) {} + + create(bet: IBet): Observable { + return this.http.post(this.resourceUrl, bet, { observe: 'response' }); + } + + update(bet: IBet): Observable { + return this.http.put(this.resourceUrl, bet, { observe: 'response' }); + } + + find(id: number): Observable { + return this.http.get(`${this.resourceUrl}/${id}`, { observe: 'response' }); + } + + query(req?: any): Observable { + const options = createRequestOption(req); + return this.http.get(this.resourceUrl, { params: options, observe: 'response' }); + } + + delete(id: number): Observable> { + return this.http.delete(`${this.resourceUrl}/${id}`, { observe: 'response' }); + } +} diff --git a/src/main/webapp/app/entities/entity.module.ts b/src/main/webapp/app/entities/entity.module.ts index 12af520..56cfa72 100644 --- a/src/main/webapp/app/entities/entity.module.ts +++ b/src/main/webapp/app/entities/entity.module.ts @@ -4,6 +4,26 @@ import { RouterModule } from '@angular/router'; @NgModule({ imports: [ RouterModule.forChild([ + { + path: 'game-user', + loadChildren: () => import('./game-user/game-user.module').then(m => m.AdminGameUserModule) + }, + { + path: 'game-commission', + loadChildren: () => import('./game-commission/game-commission.module').then(m => m.AdminGameCommissionModule) + }, + { + path: 'game', + loadChildren: () => import('./game/game.module').then(m => m.AdminGameModule) + }, + { + path: 'bet', + loadChildren: () => import('./bet/bet.module').then(m => m.AdminBetModule) + }, + { + path: 'hand', + loadChildren: () => import('./hand/hand.module').then(m => m.AdminHandModule) + } /* jhipster-needle-add-entity-route - JHipster will add entity modules routes here */ ]) ] diff --git a/src/main/webapp/app/entities/game-commission/game-commission-delete-dialog.component.html b/src/main/webapp/app/entities/game-commission/game-commission-delete-dialog.component.html new file mode 100644 index 0000000..f7c7732 --- /dev/null +++ b/src/main/webapp/app/entities/game-commission/game-commission-delete-dialog.component.html @@ -0,0 +1,24 @@ +
+ + + + + +
diff --git a/src/main/webapp/app/entities/game-commission/game-commission-delete-dialog.component.ts b/src/main/webapp/app/entities/game-commission/game-commission-delete-dialog.component.ts new file mode 100644 index 0000000..b161baa --- /dev/null +++ b/src/main/webapp/app/entities/game-commission/game-commission-delete-dialog.component.ts @@ -0,0 +1,30 @@ +import { Component } from '@angular/core'; +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; +import { JhiEventManager } from 'ng-jhipster'; + +import { IGameCommission } from 'app/shared/model/game-commission.model'; +import { GameCommissionService } from './game-commission.service'; + +@Component({ + templateUrl: './game-commission-delete-dialog.component.html' +}) +export class GameCommissionDeleteDialogComponent { + gameCommission?: IGameCommission; + + constructor( + protected gameCommissionService: GameCommissionService, + public activeModal: NgbActiveModal, + protected eventManager: JhiEventManager + ) {} + + cancel(): void { + this.activeModal.dismiss(); + } + + confirmDelete(id: number): void { + this.gameCommissionService.delete(id).subscribe(() => { + this.eventManager.broadcast('gameCommissionListModification'); + this.activeModal.close(); + }); + } +} diff --git a/src/main/webapp/app/entities/game-commission/game-commission-detail.component.html b/src/main/webapp/app/entities/game-commission/game-commission-detail.component.html new file mode 100644 index 0000000..ad69aac --- /dev/null +++ b/src/main/webapp/app/entities/game-commission/game-commission-detail.component.html @@ -0,0 +1,42 @@ +
+
+
+

Game Commission {{ gameCommission.id }}

+ +
+ + + +
+
Commission
+
+ {{ gameCommission.commission }} +
+
Game
+
+ +
+
Game User
+
+ +
+
+ + + + +
+
+
diff --git a/src/main/webapp/app/entities/game-commission/game-commission-detail.component.ts b/src/main/webapp/app/entities/game-commission/game-commission-detail.component.ts new file mode 100644 index 0000000..c418393 --- /dev/null +++ b/src/main/webapp/app/entities/game-commission/game-commission-detail.component.ts @@ -0,0 +1,22 @@ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; + +import { IGameCommission } from 'app/shared/model/game-commission.model'; + +@Component({ + selector: 'jhi-game-commission-detail', + templateUrl: './game-commission-detail.component.html' +}) +export class GameCommissionDetailComponent implements OnInit { + gameCommission: IGameCommission | null = null; + + constructor(protected activatedRoute: ActivatedRoute) {} + + ngOnInit(): void { + this.activatedRoute.data.subscribe(({ gameCommission }) => (this.gameCommission = gameCommission)); + } + + previousState(): void { + window.history.back(); + } +} diff --git a/src/main/webapp/app/entities/game-commission/game-commission-update.component.html b/src/main/webapp/app/entities/game-commission/game-commission-update.component.html new file mode 100644 index 0000000..58014eb --- /dev/null +++ b/src/main/webapp/app/entities/game-commission/game-commission-update.component.html @@ -0,0 +1,48 @@ +
+
+
+

Create or edit a Game Commission

+ +
+ + +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+
+ +
+ + + +
+
+
+
diff --git a/src/main/webapp/app/entities/game-commission/game-commission-update.component.ts b/src/main/webapp/app/entities/game-commission/game-commission-update.component.ts new file mode 100644 index 0000000..1fd9b83 --- /dev/null +++ b/src/main/webapp/app/entities/game-commission/game-commission-update.component.ts @@ -0,0 +1,103 @@ +import { Component, OnInit } from '@angular/core'; +import { HttpResponse } from '@angular/common/http'; +// eslint-disable-next-line @typescript-eslint/no-unused-vars +import { FormBuilder, Validators } from '@angular/forms'; +import { ActivatedRoute } from '@angular/router'; +import { Observable } from 'rxjs'; + +import { IGameCommission, GameCommission } from 'app/shared/model/game-commission.model'; +import { GameCommissionService } from './game-commission.service'; +import { IGame } from 'app/shared/model/game.model'; +import { GameService } from 'app/entities/game/game.service'; +import { IGameUser } from 'app/shared/model/game-user.model'; +import { GameUserService } from 'app/entities/game-user/game-user.service'; + +type SelectableEntity = IGame | IGameUser; + +@Component({ + selector: 'jhi-game-commission-update', + templateUrl: './game-commission-update.component.html' +}) +export class GameCommissionUpdateComponent implements OnInit { + isSaving = false; + games: IGame[] = []; + gameusers: IGameUser[] = []; + + editForm = this.fb.group({ + id: [], + commission: [], + game: [], + gameUser: [] + }); + + constructor( + protected gameCommissionService: GameCommissionService, + protected gameService: GameService, + protected gameUserService: GameUserService, + protected activatedRoute: ActivatedRoute, + private fb: FormBuilder + ) {} + + ngOnInit(): void { + this.activatedRoute.data.subscribe(({ gameCommission }) => { + this.updateForm(gameCommission); + + this.gameService.query().subscribe((res: HttpResponse) => (this.games = res.body || [])); + + this.gameUserService.query().subscribe((res: HttpResponse) => (this.gameusers = res.body || [])); + }); + } + + updateForm(gameCommission: IGameCommission): void { + this.editForm.patchValue({ + id: gameCommission.id, + commission: gameCommission.commission, + game: gameCommission.game, + gameUser: gameCommission.gameUser + }); + } + + previousState(): void { + window.history.back(); + } + + save(): void { + this.isSaving = true; + const gameCommission = this.createFromForm(); + if (gameCommission.id !== undefined) { + this.subscribeToSaveResponse(this.gameCommissionService.update(gameCommission)); + } else { + this.subscribeToSaveResponse(this.gameCommissionService.create(gameCommission)); + } + } + + private createFromForm(): IGameCommission { + return { + ...new GameCommission(), + id: this.editForm.get(['id'])!.value, + commission: this.editForm.get(['commission'])!.value, + game: this.editForm.get(['game'])!.value, + gameUser: this.editForm.get(['gameUser'])!.value + }; + } + + protected subscribeToSaveResponse(result: Observable>): void { + result.subscribe( + () => this.onSaveSuccess(), + () => this.onSaveError() + ); + } + + protected onSaveSuccess(): void { + this.isSaving = false; + this.previousState(); + } + + protected onSaveError(): void { + this.isSaving = false; + } + + trackById(index: number, item: SelectableEntity): any { + return item.id; + } +} diff --git a/src/main/webapp/app/entities/game-commission/game-commission.component.html b/src/main/webapp/app/entities/game-commission/game-commission.component.html new file mode 100644 index 0000000..87b657d --- /dev/null +++ b/src/main/webapp/app/entities/game-commission/game-commission.component.html @@ -0,0 +1,73 @@ +
+

+ Game Commissions + + +

+ + + + + +
+ No gameCommissions found +
+ +
+ + + + + + + + + + + + + + + + + + + +
IDCommissionGameGame User
{{ gameCommission.id }}{{ gameCommission.commission }} + + + + +
+ + + + + +
+
+
+
diff --git a/src/main/webapp/app/entities/game-commission/game-commission.component.ts b/src/main/webapp/app/entities/game-commission/game-commission.component.ts new file mode 100644 index 0000000..e4612c3 --- /dev/null +++ b/src/main/webapp/app/entities/game-commission/game-commission.component.ts @@ -0,0 +1,53 @@ +import { Component, OnInit, OnDestroy } from '@angular/core'; +import { HttpResponse } from '@angular/common/http'; +import { Subscription } from 'rxjs'; +import { JhiEventManager } from 'ng-jhipster'; +import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; + +import { IGameCommission } from 'app/shared/model/game-commission.model'; +import { GameCommissionService } from './game-commission.service'; +import { GameCommissionDeleteDialogComponent } from './game-commission-delete-dialog.component'; + +@Component({ + selector: 'jhi-game-commission', + templateUrl: './game-commission.component.html' +}) +export class GameCommissionComponent implements OnInit, OnDestroy { + gameCommissions?: IGameCommission[]; + eventSubscriber?: Subscription; + + constructor( + protected gameCommissionService: GameCommissionService, + protected eventManager: JhiEventManager, + protected modalService: NgbModal + ) {} + + loadAll(): void { + this.gameCommissionService.query().subscribe((res: HttpResponse) => (this.gameCommissions = res.body || [])); + } + + ngOnInit(): void { + this.loadAll(); + this.registerChangeInGameCommissions(); + } + + ngOnDestroy(): void { + if (this.eventSubscriber) { + this.eventManager.destroy(this.eventSubscriber); + } + } + + trackId(index: number, item: IGameCommission): number { + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + return item.id!; + } + + registerChangeInGameCommissions(): void { + this.eventSubscriber = this.eventManager.subscribe('gameCommissionListModification', () => this.loadAll()); + } + + delete(gameCommission: IGameCommission): void { + const modalRef = this.modalService.open(GameCommissionDeleteDialogComponent, { size: 'lg', backdrop: 'static' }); + modalRef.componentInstance.gameCommission = gameCommission; + } +} diff --git a/src/main/webapp/app/entities/game-commission/game-commission.module.ts b/src/main/webapp/app/entities/game-commission/game-commission.module.ts new file mode 100644 index 0000000..ba35609 --- /dev/null +++ b/src/main/webapp/app/entities/game-commission/game-commission.module.ts @@ -0,0 +1,21 @@ +import { NgModule } from '@angular/core'; +import { RouterModule } from '@angular/router'; + +import { AdminSharedModule } from 'app/shared/shared.module'; +import { GameCommissionComponent } from './game-commission.component'; +import { GameCommissionDetailComponent } from './game-commission-detail.component'; +import { GameCommissionUpdateComponent } from './game-commission-update.component'; +import { GameCommissionDeleteDialogComponent } from './game-commission-delete-dialog.component'; +import { gameCommissionRoute } from './game-commission.route'; + +@NgModule({ + imports: [AdminSharedModule, RouterModule.forChild(gameCommissionRoute)], + declarations: [ + GameCommissionComponent, + GameCommissionDetailComponent, + GameCommissionUpdateComponent, + GameCommissionDeleteDialogComponent + ], + entryComponents: [GameCommissionDeleteDialogComponent] +}) +export class AdminGameCommissionModule {} diff --git a/src/main/webapp/app/entities/game-commission/game-commission.route.ts b/src/main/webapp/app/entities/game-commission/game-commission.route.ts new file mode 100644 index 0000000..a3878da --- /dev/null +++ b/src/main/webapp/app/entities/game-commission/game-commission.route.ts @@ -0,0 +1,83 @@ +import { Injectable } from '@angular/core'; +import { HttpResponse } from '@angular/common/http'; +import { Resolve, ActivatedRouteSnapshot, Routes, Router } from '@angular/router'; +import { Observable, of, EMPTY } from 'rxjs'; +import { flatMap } from 'rxjs/operators'; + +import { Authority } from 'app/shared/constants/authority.constants'; +import { UserRouteAccessService } from 'app/core/auth/user-route-access-service'; +import { IGameCommission, GameCommission } from 'app/shared/model/game-commission.model'; +import { GameCommissionService } from './game-commission.service'; +import { GameCommissionComponent } from './game-commission.component'; +import { GameCommissionDetailComponent } from './game-commission-detail.component'; +import { GameCommissionUpdateComponent } from './game-commission-update.component'; + +@Injectable({ providedIn: 'root' }) +export class GameCommissionResolve implements Resolve { + constructor(private service: GameCommissionService, private router: Router) {} + + resolve(route: ActivatedRouteSnapshot): Observable | Observable { + const id = route.params['id']; + if (id) { + return this.service.find(id).pipe( + flatMap((gameCommission: HttpResponse) => { + if (gameCommission.body) { + return of(gameCommission.body); + } else { + this.router.navigate(['404']); + return EMPTY; + } + }) + ); + } + return of(new GameCommission()); + } +} + +export const gameCommissionRoute: Routes = [ + { + path: '', + component: GameCommissionComponent, + data: { + authorities: [Authority.USER], + pageTitle: 'GameCommissions' + }, + canActivate: [UserRouteAccessService] + }, + { + path: ':id/view', + component: GameCommissionDetailComponent, + resolve: { + gameCommission: GameCommissionResolve + }, + data: { + authorities: [Authority.USER], + pageTitle: 'GameCommissions' + }, + canActivate: [UserRouteAccessService] + }, + { + path: 'new', + component: GameCommissionUpdateComponent, + resolve: { + gameCommission: GameCommissionResolve + }, + data: { + authorities: [Authority.USER], + pageTitle: 'GameCommissions' + }, + canActivate: [UserRouteAccessService] + }, + { + path: ':id/edit', + component: GameCommissionUpdateComponent, + resolve: { + gameCommission: GameCommissionResolve + }, + data: { + authorities: [Authority.USER], + pageTitle: 'GameCommissions' + }, + canActivate: [UserRouteAccessService] + } +]; diff --git a/src/main/webapp/app/entities/game-commission/game-commission.service.ts b/src/main/webapp/app/entities/game-commission/game-commission.service.ts new file mode 100644 index 0000000..5d13ab7 --- /dev/null +++ b/src/main/webapp/app/entities/game-commission/game-commission.service.ts @@ -0,0 +1,38 @@ +import { Injectable } from '@angular/core'; +import { HttpClient, HttpResponse } from '@angular/common/http'; +import { Observable } from 'rxjs'; + +import { SERVER_API_URL } from 'app/app.constants'; +import { createRequestOption } from 'app/shared/util/request-util'; +import { IGameCommission } from 'app/shared/model/game-commission.model'; + +type EntityResponseType = HttpResponse; +type EntityArrayResponseType = HttpResponse; + +@Injectable({ providedIn: 'root' }) +export class GameCommissionService { + public resourceUrl = SERVER_API_URL + 'api/game-commissions'; + + constructor(protected http: HttpClient) {} + + create(gameCommission: IGameCommission): Observable { + return this.http.post(this.resourceUrl, gameCommission, { observe: 'response' }); + } + + update(gameCommission: IGameCommission): Observable { + return this.http.put(this.resourceUrl, gameCommission, { observe: 'response' }); + } + + find(id: number): Observable { + return this.http.get(`${this.resourceUrl}/${id}`, { observe: 'response' }); + } + + query(req?: any): Observable { + const options = createRequestOption(req); + return this.http.get(this.resourceUrl, { params: options, observe: 'response' }); + } + + delete(id: number): Observable> { + return this.http.delete(`${this.resourceUrl}/${id}`, { observe: 'response' }); + } +} diff --git a/src/main/webapp/app/entities/game-user/game-user-delete-dialog.component.html b/src/main/webapp/app/entities/game-user/game-user-delete-dialog.component.html new file mode 100644 index 0000000..7ccb2b3 --- /dev/null +++ b/src/main/webapp/app/entities/game-user/game-user-delete-dialog.component.html @@ -0,0 +1,24 @@ +
+ + + + + +
diff --git a/src/main/webapp/app/entities/game-user/game-user-delete-dialog.component.ts b/src/main/webapp/app/entities/game-user/game-user-delete-dialog.component.ts new file mode 100644 index 0000000..4d768e0 --- /dev/null +++ b/src/main/webapp/app/entities/game-user/game-user-delete-dialog.component.ts @@ -0,0 +1,26 @@ +import { Component } from '@angular/core'; +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; +import { JhiEventManager } from 'ng-jhipster'; + +import { IGameUser } from 'app/shared/model/game-user.model'; +import { GameUserService } from './game-user.service'; + +@Component({ + templateUrl: './game-user-delete-dialog.component.html' +}) +export class GameUserDeleteDialogComponent { + gameUser?: IGameUser; + + constructor(protected gameUserService: GameUserService, public activeModal: NgbActiveModal, protected eventManager: JhiEventManager) {} + + cancel(): void { + this.activeModal.dismiss(); + } + + confirmDelete(id: number): void { + this.gameUserService.delete(id).subscribe(() => { + this.eventManager.broadcast('gameUserListModification'); + this.activeModal.close(); + }); + } +} diff --git a/src/main/webapp/app/entities/game-user/game-user-detail.component.html b/src/main/webapp/app/entities/game-user/game-user-detail.component.html new file mode 100644 index 0000000..14f418b --- /dev/null +++ b/src/main/webapp/app/entities/game-user/game-user-detail.component.html @@ -0,0 +1,34 @@ +
+
+
+

Game User {{ gameUser.id }}

+ +
+ + + +
+
Username
+
+ {{ gameUser.username }} +
+
Password
+
+ {{ gameUser.password }} +
+
+ + + + +
+
+
diff --git a/src/main/webapp/app/entities/game-user/game-user-detail.component.ts b/src/main/webapp/app/entities/game-user/game-user-detail.component.ts new file mode 100644 index 0000000..3f68a7b --- /dev/null +++ b/src/main/webapp/app/entities/game-user/game-user-detail.component.ts @@ -0,0 +1,22 @@ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; + +import { IGameUser } from 'app/shared/model/game-user.model'; + +@Component({ + selector: 'jhi-game-user-detail', + templateUrl: './game-user-detail.component.html' +}) +export class GameUserDetailComponent implements OnInit { + gameUser: IGameUser | null = null; + + constructor(protected activatedRoute: ActivatedRoute) {} + + ngOnInit(): void { + this.activatedRoute.data.subscribe(({ gameUser }) => (this.gameUser = gameUser)); + } + + previousState(): void { + window.history.back(); + } +} diff --git a/src/main/webapp/app/entities/game-user/game-user-update.component.html b/src/main/webapp/app/entities/game-user/game-user-update.component.html new file mode 100644 index 0000000..82469b4 --- /dev/null +++ b/src/main/webapp/app/entities/game-user/game-user-update.component.html @@ -0,0 +1,38 @@ +
+
+
+

Create or edit a Game User

+ +
+ + +
+ + +
+ +
+ + +
+ +
+ + +
+
+ +
+ + + +
+
+
+
diff --git a/src/main/webapp/app/entities/game-user/game-user-update.component.ts b/src/main/webapp/app/entities/game-user/game-user-update.component.ts new file mode 100644 index 0000000..e22965f --- /dev/null +++ b/src/main/webapp/app/entities/game-user/game-user-update.component.ts @@ -0,0 +1,78 @@ +import { Component, OnInit } from '@angular/core'; +import { HttpResponse } from '@angular/common/http'; +// eslint-disable-next-line @typescript-eslint/no-unused-vars +import { FormBuilder, Validators } from '@angular/forms'; +import { ActivatedRoute } from '@angular/router'; +import { Observable } from 'rxjs'; + +import { IGameUser, GameUser } from 'app/shared/model/game-user.model'; +import { GameUserService } from './game-user.service'; + +@Component({ + selector: 'jhi-game-user-update', + templateUrl: './game-user-update.component.html' +}) +export class GameUserUpdateComponent implements OnInit { + isSaving = false; + + editForm = this.fb.group({ + id: [], + username: [], + password: [] + }); + + constructor(protected gameUserService: GameUserService, protected activatedRoute: ActivatedRoute, private fb: FormBuilder) {} + + ngOnInit(): void { + this.activatedRoute.data.subscribe(({ gameUser }) => { + this.updateForm(gameUser); + }); + } + + updateForm(gameUser: IGameUser): void { + this.editForm.patchValue({ + id: gameUser.id, + username: gameUser.username, + password: gameUser.password + }); + } + + previousState(): void { + window.history.back(); + } + + save(): void { + this.isSaving = true; + const gameUser = this.createFromForm(); + if (gameUser.id !== undefined) { + this.subscribeToSaveResponse(this.gameUserService.update(gameUser)); + } else { + this.subscribeToSaveResponse(this.gameUserService.create(gameUser)); + } + } + + private createFromForm(): IGameUser { + return { + ...new GameUser(), + id: this.editForm.get(['id'])!.value, + username: this.editForm.get(['username'])!.value, + password: this.editForm.get(['password'])!.value + }; + } + + protected subscribeToSaveResponse(result: Observable>): void { + result.subscribe( + () => this.onSaveSuccess(), + () => this.onSaveError() + ); + } + + protected onSaveSuccess(): void { + this.isSaving = false; + this.previousState(); + } + + protected onSaveError(): void { + this.isSaving = false; + } +} diff --git a/src/main/webapp/app/entities/game-user/game-user.component.html b/src/main/webapp/app/entities/game-user/game-user.component.html new file mode 100644 index 0000000..500121b --- /dev/null +++ b/src/main/webapp/app/entities/game-user/game-user.component.html @@ -0,0 +1,63 @@ +
+

+ Game Users + + +

+ + + + + +
+ No gameUsers found +
+ +
+ + + + + + + + + + + + + + + + + +
IDUsernamePassword
{{ gameUser.id }}{{ gameUser.username }}{{ gameUser.password }} +
+ + + + + +
+
+
+
diff --git a/src/main/webapp/app/entities/game-user/game-user.component.ts b/src/main/webapp/app/entities/game-user/game-user.component.ts new file mode 100644 index 0000000..872b63e --- /dev/null +++ b/src/main/webapp/app/entities/game-user/game-user.component.ts @@ -0,0 +1,49 @@ +import { Component, OnInit, OnDestroy } from '@angular/core'; +import { HttpResponse } from '@angular/common/http'; +import { Subscription } from 'rxjs'; +import { JhiEventManager } from 'ng-jhipster'; +import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; + +import { IGameUser } from 'app/shared/model/game-user.model'; +import { GameUserService } from './game-user.service'; +import { GameUserDeleteDialogComponent } from './game-user-delete-dialog.component'; + +@Component({ + selector: 'jhi-game-user', + templateUrl: './game-user.component.html' +}) +export class GameUserComponent implements OnInit, OnDestroy { + gameUsers?: IGameUser[]; + eventSubscriber?: Subscription; + + constructor(protected gameUserService: GameUserService, protected eventManager: JhiEventManager, protected modalService: NgbModal) {} + + loadAll(): void { + this.gameUserService.query().subscribe((res: HttpResponse) => (this.gameUsers = res.body || [])); + } + + ngOnInit(): void { + this.loadAll(); + this.registerChangeInGameUsers(); + } + + ngOnDestroy(): void { + if (this.eventSubscriber) { + this.eventManager.destroy(this.eventSubscriber); + } + } + + trackId(index: number, item: IGameUser): number { + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + return item.id!; + } + + registerChangeInGameUsers(): void { + this.eventSubscriber = this.eventManager.subscribe('gameUserListModification', () => this.loadAll()); + } + + delete(gameUser: IGameUser): void { + const modalRef = this.modalService.open(GameUserDeleteDialogComponent, { size: 'lg', backdrop: 'static' }); + modalRef.componentInstance.gameUser = gameUser; + } +} diff --git a/src/main/webapp/app/entities/game-user/game-user.module.ts b/src/main/webapp/app/entities/game-user/game-user.module.ts new file mode 100644 index 0000000..e5c1902 --- /dev/null +++ b/src/main/webapp/app/entities/game-user/game-user.module.ts @@ -0,0 +1,16 @@ +import { NgModule } from '@angular/core'; +import { RouterModule } from '@angular/router'; + +import { AdminSharedModule } from 'app/shared/shared.module'; +import { GameUserComponent } from './game-user.component'; +import { GameUserDetailComponent } from './game-user-detail.component'; +import { GameUserUpdateComponent } from './game-user-update.component'; +import { GameUserDeleteDialogComponent } from './game-user-delete-dialog.component'; +import { gameUserRoute } from './game-user.route'; + +@NgModule({ + imports: [AdminSharedModule, RouterModule.forChild(gameUserRoute)], + declarations: [GameUserComponent, GameUserDetailComponent, GameUserUpdateComponent, GameUserDeleteDialogComponent], + entryComponents: [GameUserDeleteDialogComponent] +}) +export class AdminGameUserModule {} diff --git a/src/main/webapp/app/entities/game-user/game-user.route.ts b/src/main/webapp/app/entities/game-user/game-user.route.ts new file mode 100644 index 0000000..4b70389 --- /dev/null +++ b/src/main/webapp/app/entities/game-user/game-user.route.ts @@ -0,0 +1,83 @@ +import { Injectable } from '@angular/core'; +import { HttpResponse } from '@angular/common/http'; +import { Resolve, ActivatedRouteSnapshot, Routes, Router } from '@angular/router'; +import { Observable, of, EMPTY } from 'rxjs'; +import { flatMap } from 'rxjs/operators'; + +import { Authority } from 'app/shared/constants/authority.constants'; +import { UserRouteAccessService } from 'app/core/auth/user-route-access-service'; +import { IGameUser, GameUser } from 'app/shared/model/game-user.model'; +import { GameUserService } from './game-user.service'; +import { GameUserComponent } from './game-user.component'; +import { GameUserDetailComponent } from './game-user-detail.component'; +import { GameUserUpdateComponent } from './game-user-update.component'; + +@Injectable({ providedIn: 'root' }) +export class GameUserResolve implements Resolve { + constructor(private service: GameUserService, private router: Router) {} + + resolve(route: ActivatedRouteSnapshot): Observable | Observable { + const id = route.params['id']; + if (id) { + return this.service.find(id).pipe( + flatMap((gameUser: HttpResponse) => { + if (gameUser.body) { + return of(gameUser.body); + } else { + this.router.navigate(['404']); + return EMPTY; + } + }) + ); + } + return of(new GameUser()); + } +} + +export const gameUserRoute: Routes = [ + { + path: '', + component: GameUserComponent, + data: { + authorities: [Authority.USER], + pageTitle: 'GameUsers' + }, + canActivate: [UserRouteAccessService] + }, + { + path: ':id/view', + component: GameUserDetailComponent, + resolve: { + gameUser: GameUserResolve + }, + data: { + authorities: [Authority.USER], + pageTitle: 'GameUsers' + }, + canActivate: [UserRouteAccessService] + }, + { + path: 'new', + component: GameUserUpdateComponent, + resolve: { + gameUser: GameUserResolve + }, + data: { + authorities: [Authority.USER], + pageTitle: 'GameUsers' + }, + canActivate: [UserRouteAccessService] + }, + { + path: ':id/edit', + component: GameUserUpdateComponent, + resolve: { + gameUser: GameUserResolve + }, + data: { + authorities: [Authority.USER], + pageTitle: 'GameUsers' + }, + canActivate: [UserRouteAccessService] + } +]; diff --git a/src/main/webapp/app/entities/game-user/game-user.service.ts b/src/main/webapp/app/entities/game-user/game-user.service.ts new file mode 100644 index 0000000..a4089e1 --- /dev/null +++ b/src/main/webapp/app/entities/game-user/game-user.service.ts @@ -0,0 +1,38 @@ +import { Injectable } from '@angular/core'; +import { HttpClient, HttpResponse } from '@angular/common/http'; +import { Observable } from 'rxjs'; + +import { SERVER_API_URL } from 'app/app.constants'; +import { createRequestOption } from 'app/shared/util/request-util'; +import { IGameUser } from 'app/shared/model/game-user.model'; + +type EntityResponseType = HttpResponse; +type EntityArrayResponseType = HttpResponse; + +@Injectable({ providedIn: 'root' }) +export class GameUserService { + public resourceUrl = SERVER_API_URL + 'api/game-users'; + + constructor(protected http: HttpClient) {} + + create(gameUser: IGameUser): Observable { + return this.http.post(this.resourceUrl, gameUser, { observe: 'response' }); + } + + update(gameUser: IGameUser): Observable { + return this.http.put(this.resourceUrl, gameUser, { observe: 'response' }); + } + + find(id: number): Observable { + return this.http.get(`${this.resourceUrl}/${id}`, { observe: 'response' }); + } + + query(req?: any): Observable { + const options = createRequestOption(req); + return this.http.get(this.resourceUrl, { params: options, observe: 'response' }); + } + + delete(id: number): Observable> { + return this.http.delete(`${this.resourceUrl}/${id}`, { observe: 'response' }); + } +} diff --git a/src/main/webapp/app/entities/game/game-delete-dialog.component.html b/src/main/webapp/app/entities/game/game-delete-dialog.component.html new file mode 100644 index 0000000..59e1b8a --- /dev/null +++ b/src/main/webapp/app/entities/game/game-delete-dialog.component.html @@ -0,0 +1,24 @@ +
+ + + + + +
diff --git a/src/main/webapp/app/entities/game/game-delete-dialog.component.ts b/src/main/webapp/app/entities/game/game-delete-dialog.component.ts new file mode 100644 index 0000000..0bccb2e --- /dev/null +++ b/src/main/webapp/app/entities/game/game-delete-dialog.component.ts @@ -0,0 +1,26 @@ +import { Component } from '@angular/core'; +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; +import { JhiEventManager } from 'ng-jhipster'; + +import { IGame } from 'app/shared/model/game.model'; +import { GameService } from './game.service'; + +@Component({ + templateUrl: './game-delete-dialog.component.html' +}) +export class GameDeleteDialogComponent { + game?: IGame; + + constructor(protected gameService: GameService, public activeModal: NgbActiveModal, protected eventManager: JhiEventManager) {} + + cancel(): void { + this.activeModal.dismiss(); + } + + confirmDelete(id: number): void { + this.gameService.delete(id).subscribe(() => { + this.eventManager.broadcast('gameListModification'); + this.activeModal.close(); + }); + } +} diff --git a/src/main/webapp/app/entities/game/game-detail.component.html b/src/main/webapp/app/entities/game/game-detail.component.html new file mode 100644 index 0000000..78359b0 --- /dev/null +++ b/src/main/webapp/app/entities/game/game-detail.component.html @@ -0,0 +1,30 @@ +
+
+
+

Game {{ game.id }}

+ +
+ + + +
+
Name
+
+ {{ game.name }} +
+
+ + + + +
+
+
diff --git a/src/main/webapp/app/entities/game/game-detail.component.ts b/src/main/webapp/app/entities/game/game-detail.component.ts new file mode 100644 index 0000000..1ee14ee --- /dev/null +++ b/src/main/webapp/app/entities/game/game-detail.component.ts @@ -0,0 +1,22 @@ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; + +import { IGame } from 'app/shared/model/game.model'; + +@Component({ + selector: 'jhi-game-detail', + templateUrl: './game-detail.component.html' +}) +export class GameDetailComponent implements OnInit { + game: IGame | null = null; + + constructor(protected activatedRoute: ActivatedRoute) {} + + ngOnInit(): void { + this.activatedRoute.data.subscribe(({ game }) => (this.game = game)); + } + + previousState(): void { + window.history.back(); + } +} diff --git a/src/main/webapp/app/entities/game/game-update.component.html b/src/main/webapp/app/entities/game/game-update.component.html new file mode 100644 index 0000000..6361c0e --- /dev/null +++ b/src/main/webapp/app/entities/game/game-update.component.html @@ -0,0 +1,32 @@ +
+
+
+

Create or edit a Game

+ +
+ + +
+ + +
+ +
+ + +
+
+ +
+ + + +
+
+
+
diff --git a/src/main/webapp/app/entities/game/game-update.component.ts b/src/main/webapp/app/entities/game/game-update.component.ts new file mode 100644 index 0000000..d97a1fa --- /dev/null +++ b/src/main/webapp/app/entities/game/game-update.component.ts @@ -0,0 +1,75 @@ +import { Component, OnInit } from '@angular/core'; +import { HttpResponse } from '@angular/common/http'; +// eslint-disable-next-line @typescript-eslint/no-unused-vars +import { FormBuilder, Validators } from '@angular/forms'; +import { ActivatedRoute } from '@angular/router'; +import { Observable } from 'rxjs'; + +import { IGame, Game } from 'app/shared/model/game.model'; +import { GameService } from './game.service'; + +@Component({ + selector: 'jhi-game-update', + templateUrl: './game-update.component.html' +}) +export class GameUpdateComponent implements OnInit { + isSaving = false; + + editForm = this.fb.group({ + id: [], + name: [] + }); + + constructor(protected gameService: GameService, protected activatedRoute: ActivatedRoute, private fb: FormBuilder) {} + + ngOnInit(): void { + this.activatedRoute.data.subscribe(({ game }) => { + this.updateForm(game); + }); + } + + updateForm(game: IGame): void { + this.editForm.patchValue({ + id: game.id, + name: game.name + }); + } + + previousState(): void { + window.history.back(); + } + + save(): void { + this.isSaving = true; + const game = this.createFromForm(); + if (game.id !== undefined) { + this.subscribeToSaveResponse(this.gameService.update(game)); + } else { + this.subscribeToSaveResponse(this.gameService.create(game)); + } + } + + private createFromForm(): IGame { + return { + ...new Game(), + id: this.editForm.get(['id'])!.value, + name: this.editForm.get(['name'])!.value + }; + } + + protected subscribeToSaveResponse(result: Observable>): void { + result.subscribe( + () => this.onSaveSuccess(), + () => this.onSaveError() + ); + } + + protected onSaveSuccess(): void { + this.isSaving = false; + this.previousState(); + } + + protected onSaveError(): void { + this.isSaving = false; + } +} diff --git a/src/main/webapp/app/entities/game/game.component.html b/src/main/webapp/app/entities/game/game.component.html new file mode 100644 index 0000000..d309c29 --- /dev/null +++ b/src/main/webapp/app/entities/game/game.component.html @@ -0,0 +1,61 @@ +
+

+ Games + + +

+ + + + + +
+ No games found +
+ +
+ + + + + + + + + + + + + + + +
IDName
{{ game.id }}{{ game.name }} +
+ + + + + +
+
+
+
diff --git a/src/main/webapp/app/entities/game/game.component.ts b/src/main/webapp/app/entities/game/game.component.ts new file mode 100644 index 0000000..33370fb --- /dev/null +++ b/src/main/webapp/app/entities/game/game.component.ts @@ -0,0 +1,49 @@ +import { Component, OnInit, OnDestroy } from '@angular/core'; +import { HttpResponse } from '@angular/common/http'; +import { Subscription } from 'rxjs'; +import { JhiEventManager } from 'ng-jhipster'; +import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; + +import { IGame } from 'app/shared/model/game.model'; +import { GameService } from './game.service'; +import { GameDeleteDialogComponent } from './game-delete-dialog.component'; + +@Component({ + selector: 'jhi-game', + templateUrl: './game.component.html' +}) +export class GameComponent implements OnInit, OnDestroy { + games?: IGame[]; + eventSubscriber?: Subscription; + + constructor(protected gameService: GameService, protected eventManager: JhiEventManager, protected modalService: NgbModal) {} + + loadAll(): void { + this.gameService.query().subscribe((res: HttpResponse) => (this.games = res.body || [])); + } + + ngOnInit(): void { + this.loadAll(); + this.registerChangeInGames(); + } + + ngOnDestroy(): void { + if (this.eventSubscriber) { + this.eventManager.destroy(this.eventSubscriber); + } + } + + trackId(index: number, item: IGame): number { + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + return item.id!; + } + + registerChangeInGames(): void { + this.eventSubscriber = this.eventManager.subscribe('gameListModification', () => this.loadAll()); + } + + delete(game: IGame): void { + const modalRef = this.modalService.open(GameDeleteDialogComponent, { size: 'lg', backdrop: 'static' }); + modalRef.componentInstance.game = game; + } +} diff --git a/src/main/webapp/app/entities/game/game.module.ts b/src/main/webapp/app/entities/game/game.module.ts new file mode 100644 index 0000000..756441f --- /dev/null +++ b/src/main/webapp/app/entities/game/game.module.ts @@ -0,0 +1,16 @@ +import { NgModule } from '@angular/core'; +import { RouterModule } from '@angular/router'; + +import { AdminSharedModule } from 'app/shared/shared.module'; +import { GameComponent } from './game.component'; +import { GameDetailComponent } from './game-detail.component'; +import { GameUpdateComponent } from './game-update.component'; +import { GameDeleteDialogComponent } from './game-delete-dialog.component'; +import { gameRoute } from './game.route'; + +@NgModule({ + imports: [AdminSharedModule, RouterModule.forChild(gameRoute)], + declarations: [GameComponent, GameDetailComponent, GameUpdateComponent, GameDeleteDialogComponent], + entryComponents: [GameDeleteDialogComponent] +}) +export class AdminGameModule {} diff --git a/src/main/webapp/app/entities/game/game.route.ts b/src/main/webapp/app/entities/game/game.route.ts new file mode 100644 index 0000000..61d2560 --- /dev/null +++ b/src/main/webapp/app/entities/game/game.route.ts @@ -0,0 +1,83 @@ +import { Injectable } from '@angular/core'; +import { HttpResponse } from '@angular/common/http'; +import { Resolve, ActivatedRouteSnapshot, Routes, Router } from '@angular/router'; +import { Observable, of, EMPTY } from 'rxjs'; +import { flatMap } from 'rxjs/operators'; + +import { Authority } from 'app/shared/constants/authority.constants'; +import { UserRouteAccessService } from 'app/core/auth/user-route-access-service'; +import { IGame, Game } from 'app/shared/model/game.model'; +import { GameService } from './game.service'; +import { GameComponent } from './game.component'; +import { GameDetailComponent } from './game-detail.component'; +import { GameUpdateComponent } from './game-update.component'; + +@Injectable({ providedIn: 'root' }) +export class GameResolve implements Resolve { + constructor(private service: GameService, private router: Router) {} + + resolve(route: ActivatedRouteSnapshot): Observable | Observable { + const id = route.params['id']; + if (id) { + return this.service.find(id).pipe( + flatMap((game: HttpResponse) => { + if (game.body) { + return of(game.body); + } else { + this.router.navigate(['404']); + return EMPTY; + } + }) + ); + } + return of(new Game()); + } +} + +export const gameRoute: Routes = [ + { + path: '', + component: GameComponent, + data: { + authorities: [Authority.USER], + pageTitle: 'Games' + }, + canActivate: [UserRouteAccessService] + }, + { + path: ':id/view', + component: GameDetailComponent, + resolve: { + game: GameResolve + }, + data: { + authorities: [Authority.USER], + pageTitle: 'Games' + }, + canActivate: [UserRouteAccessService] + }, + { + path: 'new', + component: GameUpdateComponent, + resolve: { + game: GameResolve + }, + data: { + authorities: [Authority.USER], + pageTitle: 'Games' + }, + canActivate: [UserRouteAccessService] + }, + { + path: ':id/edit', + component: GameUpdateComponent, + resolve: { + game: GameResolve + }, + data: { + authorities: [Authority.USER], + pageTitle: 'Games' + }, + canActivate: [UserRouteAccessService] + } +]; diff --git a/src/main/webapp/app/entities/game/game.service.ts b/src/main/webapp/app/entities/game/game.service.ts new file mode 100644 index 0000000..191c9f3 --- /dev/null +++ b/src/main/webapp/app/entities/game/game.service.ts @@ -0,0 +1,38 @@ +import { Injectable } from '@angular/core'; +import { HttpClient, HttpResponse } from '@angular/common/http'; +import { Observable } from 'rxjs'; + +import { SERVER_API_URL } from 'app/app.constants'; +import { createRequestOption } from 'app/shared/util/request-util'; +import { IGame } from 'app/shared/model/game.model'; + +type EntityResponseType = HttpResponse; +type EntityArrayResponseType = HttpResponse; + +@Injectable({ providedIn: 'root' }) +export class GameService { + public resourceUrl = SERVER_API_URL + 'api/games'; + + constructor(protected http: HttpClient) {} + + create(game: IGame): Observable { + return this.http.post(this.resourceUrl, game, { observe: 'response' }); + } + + update(game: IGame): Observable { + return this.http.put(this.resourceUrl, game, { observe: 'response' }); + } + + find(id: number): Observable { + return this.http.get(`${this.resourceUrl}/${id}`, { observe: 'response' }); + } + + query(req?: any): Observable { + const options = createRequestOption(req); + return this.http.get(this.resourceUrl, { params: options, observe: 'response' }); + } + + delete(id: number): Observable> { + return this.http.delete(`${this.resourceUrl}/${id}`, { observe: 'response' }); + } +} diff --git a/src/main/webapp/app/entities/hand/hand-delete-dialog.component.html b/src/main/webapp/app/entities/hand/hand-delete-dialog.component.html new file mode 100644 index 0000000..135956a --- /dev/null +++ b/src/main/webapp/app/entities/hand/hand-delete-dialog.component.html @@ -0,0 +1,24 @@ +
+ + + + + +
diff --git a/src/main/webapp/app/entities/hand/hand-delete-dialog.component.ts b/src/main/webapp/app/entities/hand/hand-delete-dialog.component.ts new file mode 100644 index 0000000..9b62977 --- /dev/null +++ b/src/main/webapp/app/entities/hand/hand-delete-dialog.component.ts @@ -0,0 +1,26 @@ +import { Component } from '@angular/core'; +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; +import { JhiEventManager } from 'ng-jhipster'; + +import { IHand } from 'app/shared/model/hand.model'; +import { HandService } from './hand.service'; + +@Component({ + templateUrl: './hand-delete-dialog.component.html' +}) +export class HandDeleteDialogComponent { + hand?: IHand; + + constructor(protected handService: HandService, public activeModal: NgbActiveModal, protected eventManager: JhiEventManager) {} + + cancel(): void { + this.activeModal.dismiss(); + } + + confirmDelete(id: number): void { + this.handService.delete(id).subscribe(() => { + this.eventManager.broadcast('handListModification'); + this.activeModal.close(); + }); + } +} diff --git a/src/main/webapp/app/entities/hand/hand-detail.component.html b/src/main/webapp/app/entities/hand/hand-detail.component.html new file mode 100644 index 0000000..d78da15 --- /dev/null +++ b/src/main/webapp/app/entities/hand/hand-detail.component.html @@ -0,0 +1,36 @@ +
+
+
+

Hand {{ hand.id }}

+ +
+ + + +
+
Status
+
+ {{ hand.status }} +
+
Game
+
+ +
+
+ + + + +
+
+
diff --git a/src/main/webapp/app/entities/hand/hand-detail.component.ts b/src/main/webapp/app/entities/hand/hand-detail.component.ts new file mode 100644 index 0000000..c481435 --- /dev/null +++ b/src/main/webapp/app/entities/hand/hand-detail.component.ts @@ -0,0 +1,22 @@ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; + +import { IHand } from 'app/shared/model/hand.model'; + +@Component({ + selector: 'jhi-hand-detail', + templateUrl: './hand-detail.component.html' +}) +export class HandDetailComponent implements OnInit { + hand: IHand | null = null; + + constructor(protected activatedRoute: ActivatedRoute) {} + + ngOnInit(): void { + this.activatedRoute.data.subscribe(({ hand }) => (this.hand = hand)); + } + + previousState(): void { + window.history.back(); + } +} diff --git a/src/main/webapp/app/entities/hand/hand-update.component.html b/src/main/webapp/app/entities/hand/hand-update.component.html new file mode 100644 index 0000000..8d6241f --- /dev/null +++ b/src/main/webapp/app/entities/hand/hand-update.component.html @@ -0,0 +1,42 @@ +
+
+
+

Create or edit a Hand

+ +
+ + +
+ + +
+ +
+ + +
+ +
+ + +
+
+ +
+ + + +
+
+
+
diff --git a/src/main/webapp/app/entities/hand/hand-update.component.ts b/src/main/webapp/app/entities/hand/hand-update.component.ts new file mode 100644 index 0000000..162d833 --- /dev/null +++ b/src/main/webapp/app/entities/hand/hand-update.component.ts @@ -0,0 +1,92 @@ +import { Component, OnInit } from '@angular/core'; +import { HttpResponse } from '@angular/common/http'; +// eslint-disable-next-line @typescript-eslint/no-unused-vars +import { FormBuilder, Validators } from '@angular/forms'; +import { ActivatedRoute } from '@angular/router'; +import { Observable } from 'rxjs'; + +import { IHand, Hand } from 'app/shared/model/hand.model'; +import { HandService } from './hand.service'; +import { IGame } from 'app/shared/model/game.model'; +import { GameService } from 'app/entities/game/game.service'; + +@Component({ + selector: 'jhi-hand-update', + templateUrl: './hand-update.component.html' +}) +export class HandUpdateComponent implements OnInit { + isSaving = false; + games: IGame[] = []; + + editForm = this.fb.group({ + id: [], + status: [], + game: [] + }); + + constructor( + protected handService: HandService, + protected gameService: GameService, + protected activatedRoute: ActivatedRoute, + private fb: FormBuilder + ) {} + + ngOnInit(): void { + this.activatedRoute.data.subscribe(({ hand }) => { + this.updateForm(hand); + + this.gameService.query().subscribe((res: HttpResponse) => (this.games = res.body || [])); + }); + } + + updateForm(hand: IHand): void { + this.editForm.patchValue({ + id: hand.id, + status: hand.status, + game: hand.game + }); + } + + previousState(): void { + window.history.back(); + } + + save(): void { + this.isSaving = true; + const hand = this.createFromForm(); + if (hand.id !== undefined) { + this.subscribeToSaveResponse(this.handService.update(hand)); + } else { + this.subscribeToSaveResponse(this.handService.create(hand)); + } + } + + private createFromForm(): IHand { + return { + ...new Hand(), + id: this.editForm.get(['id'])!.value, + status: this.editForm.get(['status'])!.value, + game: this.editForm.get(['game'])!.value + }; + } + + protected subscribeToSaveResponse(result: Observable>): void { + result.subscribe( + () => this.onSaveSuccess(), + () => this.onSaveError() + ); + } + + protected onSaveSuccess(): void { + this.isSaving = false; + this.previousState(); + } + + protected onSaveError(): void { + this.isSaving = false; + } + + trackById(index: number, item: IGame): any { + return item.id; + } +} diff --git a/src/main/webapp/app/entities/hand/hand.component.html b/src/main/webapp/app/entities/hand/hand.component.html new file mode 100644 index 0000000..0828a2e --- /dev/null +++ b/src/main/webapp/app/entities/hand/hand.component.html @@ -0,0 +1,67 @@ +
+

+ Hands + + +

+ + + + + +
+ No hands found +
+ +
+ + + + + + + + + + + + + + + + + +
IDStatusGame
{{ hand.id }}{{ hand.status }} + + +
+ + + + + +
+
+
+
diff --git a/src/main/webapp/app/entities/hand/hand.component.ts b/src/main/webapp/app/entities/hand/hand.component.ts new file mode 100644 index 0000000..cae3888 --- /dev/null +++ b/src/main/webapp/app/entities/hand/hand.component.ts @@ -0,0 +1,49 @@ +import { Component, OnInit, OnDestroy } from '@angular/core'; +import { HttpResponse } from '@angular/common/http'; +import { Subscription } from 'rxjs'; +import { JhiEventManager } from 'ng-jhipster'; +import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; + +import { IHand } from 'app/shared/model/hand.model'; +import { HandService } from './hand.service'; +import { HandDeleteDialogComponent } from './hand-delete-dialog.component'; + +@Component({ + selector: 'jhi-hand', + templateUrl: './hand.component.html' +}) +export class HandComponent implements OnInit, OnDestroy { + hands?: IHand[]; + eventSubscriber?: Subscription; + + constructor(protected handService: HandService, protected eventManager: JhiEventManager, protected modalService: NgbModal) {} + + loadAll(): void { + this.handService.query().subscribe((res: HttpResponse) => (this.hands = res.body || [])); + } + + ngOnInit(): void { + this.loadAll(); + this.registerChangeInHands(); + } + + ngOnDestroy(): void { + if (this.eventSubscriber) { + this.eventManager.destroy(this.eventSubscriber); + } + } + + trackId(index: number, item: IHand): number { + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + return item.id!; + } + + registerChangeInHands(): void { + this.eventSubscriber = this.eventManager.subscribe('handListModification', () => this.loadAll()); + } + + delete(hand: IHand): void { + const modalRef = this.modalService.open(HandDeleteDialogComponent, { size: 'lg', backdrop: 'static' }); + modalRef.componentInstance.hand = hand; + } +} diff --git a/src/main/webapp/app/entities/hand/hand.module.ts b/src/main/webapp/app/entities/hand/hand.module.ts new file mode 100644 index 0000000..01febc1 --- /dev/null +++ b/src/main/webapp/app/entities/hand/hand.module.ts @@ -0,0 +1,16 @@ +import { NgModule } from '@angular/core'; +import { RouterModule } from '@angular/router'; + +import { AdminSharedModule } from 'app/shared/shared.module'; +import { HandComponent } from './hand.component'; +import { HandDetailComponent } from './hand-detail.component'; +import { HandUpdateComponent } from './hand-update.component'; +import { HandDeleteDialogComponent } from './hand-delete-dialog.component'; +import { handRoute } from './hand.route'; + +@NgModule({ + imports: [AdminSharedModule, RouterModule.forChild(handRoute)], + declarations: [HandComponent, HandDetailComponent, HandUpdateComponent, HandDeleteDialogComponent], + entryComponents: [HandDeleteDialogComponent] +}) +export class AdminHandModule {} diff --git a/src/main/webapp/app/entities/hand/hand.route.ts b/src/main/webapp/app/entities/hand/hand.route.ts new file mode 100644 index 0000000..7848ad0 --- /dev/null +++ b/src/main/webapp/app/entities/hand/hand.route.ts @@ -0,0 +1,83 @@ +import { Injectable } from '@angular/core'; +import { HttpResponse } from '@angular/common/http'; +import { Resolve, ActivatedRouteSnapshot, Routes, Router } from '@angular/router'; +import { Observable, of, EMPTY } from 'rxjs'; +import { flatMap } from 'rxjs/operators'; + +import { Authority } from 'app/shared/constants/authority.constants'; +import { UserRouteAccessService } from 'app/core/auth/user-route-access-service'; +import { IHand, Hand } from 'app/shared/model/hand.model'; +import { HandService } from './hand.service'; +import { HandComponent } from './hand.component'; +import { HandDetailComponent } from './hand-detail.component'; +import { HandUpdateComponent } from './hand-update.component'; + +@Injectable({ providedIn: 'root' }) +export class HandResolve implements Resolve { + constructor(private service: HandService, private router: Router) {} + + resolve(route: ActivatedRouteSnapshot): Observable | Observable { + const id = route.params['id']; + if (id) { + return this.service.find(id).pipe( + flatMap((hand: HttpResponse) => { + if (hand.body) { + return of(hand.body); + } else { + this.router.navigate(['404']); + return EMPTY; + } + }) + ); + } + return of(new Hand()); + } +} + +export const handRoute: Routes = [ + { + path: '', + component: HandComponent, + data: { + authorities: [Authority.USER], + pageTitle: 'Hands' + }, + canActivate: [UserRouteAccessService] + }, + { + path: ':id/view', + component: HandDetailComponent, + resolve: { + hand: HandResolve + }, + data: { + authorities: [Authority.USER], + pageTitle: 'Hands' + }, + canActivate: [UserRouteAccessService] + }, + { + path: 'new', + component: HandUpdateComponent, + resolve: { + hand: HandResolve + }, + data: { + authorities: [Authority.USER], + pageTitle: 'Hands' + }, + canActivate: [UserRouteAccessService] + }, + { + path: ':id/edit', + component: HandUpdateComponent, + resolve: { + hand: HandResolve + }, + data: { + authorities: [Authority.USER], + pageTitle: 'Hands' + }, + canActivate: [UserRouteAccessService] + } +]; diff --git a/src/main/webapp/app/entities/hand/hand.service.ts b/src/main/webapp/app/entities/hand/hand.service.ts new file mode 100644 index 0000000..3342965 --- /dev/null +++ b/src/main/webapp/app/entities/hand/hand.service.ts @@ -0,0 +1,38 @@ +import { Injectable } from '@angular/core'; +import { HttpClient, HttpResponse } from '@angular/common/http'; +import { Observable } from 'rxjs'; + +import { SERVER_API_URL } from 'app/app.constants'; +import { createRequestOption } from 'app/shared/util/request-util'; +import { IHand } from 'app/shared/model/hand.model'; + +type EntityResponseType = HttpResponse; +type EntityArrayResponseType = HttpResponse; + +@Injectable({ providedIn: 'root' }) +export class HandService { + public resourceUrl = SERVER_API_URL + 'api/hands'; + + constructor(protected http: HttpClient) {} + + create(hand: IHand): Observable { + return this.http.post(this.resourceUrl, hand, { observe: 'response' }); + } + + update(hand: IHand): Observable { + return this.http.put(this.resourceUrl, hand, { observe: 'response' }); + } + + find(id: number): Observable { + return this.http.get(`${this.resourceUrl}/${id}`, { observe: 'response' }); + } + + query(req?: any): Observable { + const options = createRequestOption(req); + return this.http.get(this.resourceUrl, { params: options, observe: 'response' }); + } + + delete(id: number): Observable> { + return this.http.delete(`${this.resourceUrl}/${id}`, { observe: 'response' }); + } +} diff --git a/src/main/webapp/app/layouts/navbar/navbar.component.html b/src/main/webapp/app/layouts/navbar/navbar.component.html index ade57c8..8d2b512 100644 --- a/src/main/webapp/app/layouts/navbar/navbar.component.html +++ b/src/main/webapp/app/layouts/navbar/navbar.component.html @@ -27,6 +27,36 @@ diff --git a/src/main/webapp/app/shared/model/bet.model.ts b/src/main/webapp/app/shared/model/bet.model.ts new file mode 100644 index 0000000..2722e38 --- /dev/null +++ b/src/main/webapp/app/shared/model/bet.model.ts @@ -0,0 +1,13 @@ +import { IGameUser } from 'app/shared/model/game-user.model'; +import { IHand } from 'app/shared/model/hand.model'; + +export interface IBet { + id?: number; + chips?: number; + user?: IGameUser; + hand?: IHand; +} + +export class Bet implements IBet { + constructor(public id?: number, public chips?: number, public user?: IGameUser, public hand?: IHand) {} +} diff --git a/src/main/webapp/app/shared/model/enumerations/hand-status.model.ts b/src/main/webapp/app/shared/model/enumerations/hand-status.model.ts new file mode 100644 index 0000000..6ada259 --- /dev/null +++ b/src/main/webapp/app/shared/model/enumerations/hand-status.model.ts @@ -0,0 +1,4 @@ +export const enum HandStatus { + Begin = 'Begin', + End = 'End' +} diff --git a/src/main/webapp/app/shared/model/game-commission.model.ts b/src/main/webapp/app/shared/model/game-commission.model.ts new file mode 100644 index 0000000..529cdd8 --- /dev/null +++ b/src/main/webapp/app/shared/model/game-commission.model.ts @@ -0,0 +1,13 @@ +import { IGame } from 'app/shared/model/game.model'; +import { IGameUser } from 'app/shared/model/game-user.model'; + +export interface IGameCommission { + id?: number; + commission?: number; + game?: IGame; + gameUser?: IGameUser; +} + +export class GameCommission implements IGameCommission { + constructor(public id?: number, public commission?: number, public game?: IGame, public gameUser?: IGameUser) {} +} diff --git a/src/main/webapp/app/shared/model/game-user.model.ts b/src/main/webapp/app/shared/model/game-user.model.ts new file mode 100644 index 0000000..1327a19 --- /dev/null +++ b/src/main/webapp/app/shared/model/game-user.model.ts @@ -0,0 +1,12 @@ +import { IGameCommission } from 'app/shared/model/game-commission.model'; + +export interface IGameUser { + id?: number; + username?: string; + password?: string; + commissions?: IGameCommission[]; +} + +export class GameUser implements IGameUser { + constructor(public id?: number, public username?: string, public password?: string, public commissions?: IGameCommission[]) {} +} diff --git a/src/main/webapp/app/shared/model/game.model.ts b/src/main/webapp/app/shared/model/game.model.ts new file mode 100644 index 0000000..11472e9 --- /dev/null +++ b/src/main/webapp/app/shared/model/game.model.ts @@ -0,0 +1,8 @@ +export interface IGame { + id?: number; + name?: string; +} + +export class Game implements IGame { + constructor(public id?: number, public name?: string) {} +} diff --git a/src/main/webapp/app/shared/model/hand.model.ts b/src/main/webapp/app/shared/model/hand.model.ts new file mode 100644 index 0000000..b7f6f3e --- /dev/null +++ b/src/main/webapp/app/shared/model/hand.model.ts @@ -0,0 +1,14 @@ +import { IBet } from 'app/shared/model/bet.model'; +import { IGame } from 'app/shared/model/game.model'; +import { HandStatus } from 'app/shared/model/enumerations/hand-status.model'; + +export interface IHand { + id?: number; + status?: HandStatus; + bets?: IBet[]; + game?: IGame; +} + +export class Hand implements IHand { + constructor(public id?: number, public status?: HandStatus, public bets?: IBet[], public game?: IGame) {} +} diff --git a/src/test/java/com/mycompany/myapp/domain/BetTest.java b/src/test/java/com/mycompany/myapp/domain/BetTest.java new file mode 100644 index 0000000..42db10e --- /dev/null +++ b/src/test/java/com/mycompany/myapp/domain/BetTest.java @@ -0,0 +1,22 @@ +package com.mycompany.myapp.domain; + +import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.assertThat; +import com.mycompany.myapp.web.rest.TestUtil; + +public class BetTest { + + @Test + public void equalsVerifier() throws Exception { + TestUtil.equalsVerifier(Bet.class); + Bet bet1 = new Bet(); + bet1.setId(1L); + Bet bet2 = new Bet(); + bet2.setId(bet1.getId()); + assertThat(bet1).isEqualTo(bet2); + bet2.setId(2L); + assertThat(bet1).isNotEqualTo(bet2); + bet1.setId(null); + assertThat(bet1).isNotEqualTo(bet2); + } +} diff --git a/src/test/java/com/mycompany/myapp/domain/GameCommissionTest.java b/src/test/java/com/mycompany/myapp/domain/GameCommissionTest.java new file mode 100644 index 0000000..74fdd2d --- /dev/null +++ b/src/test/java/com/mycompany/myapp/domain/GameCommissionTest.java @@ -0,0 +1,22 @@ +package com.mycompany.myapp.domain; + +import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.assertThat; +import com.mycompany.myapp.web.rest.TestUtil; + +public class GameCommissionTest { + + @Test + public void equalsVerifier() throws Exception { + TestUtil.equalsVerifier(GameCommission.class); + GameCommission gameCommission1 = new GameCommission(); + gameCommission1.setId(1L); + GameCommission gameCommission2 = new GameCommission(); + gameCommission2.setId(gameCommission1.getId()); + assertThat(gameCommission1).isEqualTo(gameCommission2); + gameCommission2.setId(2L); + assertThat(gameCommission1).isNotEqualTo(gameCommission2); + gameCommission1.setId(null); + assertThat(gameCommission1).isNotEqualTo(gameCommission2); + } +} diff --git a/src/test/java/com/mycompany/myapp/domain/GameTest.java b/src/test/java/com/mycompany/myapp/domain/GameTest.java new file mode 100644 index 0000000..8bb39b6 --- /dev/null +++ b/src/test/java/com/mycompany/myapp/domain/GameTest.java @@ -0,0 +1,22 @@ +package com.mycompany.myapp.domain; + +import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.assertThat; +import com.mycompany.myapp.web.rest.TestUtil; + +public class GameTest { + + @Test + public void equalsVerifier() throws Exception { + TestUtil.equalsVerifier(Game.class); + Game game1 = new Game(); + game1.setId(1L); + Game game2 = new Game(); + game2.setId(game1.getId()); + assertThat(game1).isEqualTo(game2); + game2.setId(2L); + assertThat(game1).isNotEqualTo(game2); + game1.setId(null); + assertThat(game1).isNotEqualTo(game2); + } +} diff --git a/src/test/java/com/mycompany/myapp/domain/GameUserTest.java b/src/test/java/com/mycompany/myapp/domain/GameUserTest.java new file mode 100644 index 0000000..93c0408 --- /dev/null +++ b/src/test/java/com/mycompany/myapp/domain/GameUserTest.java @@ -0,0 +1,22 @@ +package com.mycompany.myapp.domain; + +import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.assertThat; +import com.mycompany.myapp.web.rest.TestUtil; + +public class GameUserTest { + + @Test + public void equalsVerifier() throws Exception { + TestUtil.equalsVerifier(GameUser.class); + GameUser gameUser1 = new GameUser(); + gameUser1.setId(1L); + GameUser gameUser2 = new GameUser(); + gameUser2.setId(gameUser1.getId()); + assertThat(gameUser1).isEqualTo(gameUser2); + gameUser2.setId(2L); + assertThat(gameUser1).isNotEqualTo(gameUser2); + gameUser1.setId(null); + assertThat(gameUser1).isNotEqualTo(gameUser2); + } +} diff --git a/src/test/java/com/mycompany/myapp/domain/HandTest.java b/src/test/java/com/mycompany/myapp/domain/HandTest.java new file mode 100644 index 0000000..3298d87 --- /dev/null +++ b/src/test/java/com/mycompany/myapp/domain/HandTest.java @@ -0,0 +1,22 @@ +package com.mycompany.myapp.domain; + +import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.assertThat; +import com.mycompany.myapp.web.rest.TestUtil; + +public class HandTest { + + @Test + public void equalsVerifier() throws Exception { + TestUtil.equalsVerifier(Hand.class); + Hand hand1 = new Hand(); + hand1.setId(1L); + Hand hand2 = new Hand(); + hand2.setId(hand1.getId()); + assertThat(hand1).isEqualTo(hand2); + hand2.setId(2L); + assertThat(hand1).isNotEqualTo(hand2); + hand1.setId(null); + assertThat(hand1).isNotEqualTo(hand2); + } +} diff --git a/src/test/java/com/mycompany/myapp/web/rest/BetResourceIT.java b/src/test/java/com/mycompany/myapp/web/rest/BetResourceIT.java new file mode 100644 index 0000000..6658bbf --- /dev/null +++ b/src/test/java/com/mycompany/myapp/web/rest/BetResourceIT.java @@ -0,0 +1,211 @@ +package com.mycompany.myapp.web.rest; + +import com.mycompany.myapp.AdminApp; +import com.mycompany.myapp.domain.Bet; +import com.mycompany.myapp.repository.BetRepository; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.http.MediaType; +import org.springframework.security.test.context.support.WithMockUser; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.transaction.annotation.Transactional; +import javax.persistence.EntityManager; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.hamcrest.Matchers.hasItem; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + +/** + * Integration tests for the {@link BetResource} REST controller. + */ +@SpringBootTest(classes = AdminApp.class) + +@AutoConfigureMockMvc +@WithMockUser +public class BetResourceIT { + + private static final Integer DEFAULT_CHIPS = 1; + private static final Integer UPDATED_CHIPS = 2; + + @Autowired + private BetRepository betRepository; + + @Autowired + private EntityManager em; + + @Autowired + private MockMvc restBetMockMvc; + + private Bet bet; + + /** + * Create an entity for this test. + * + * This is a static method, as tests for other entities might also need it, + * if they test an entity which requires the current entity. + */ + public static Bet createEntity(EntityManager em) { + Bet bet = new Bet() + .chips(DEFAULT_CHIPS); + return bet; + } + /** + * Create an updated entity for this test. + * + * This is a static method, as tests for other entities might also need it, + * if they test an entity which requires the current entity. + */ + public static Bet createUpdatedEntity(EntityManager em) { + Bet bet = new Bet() + .chips(UPDATED_CHIPS); + return bet; + } + + @BeforeEach + public void initTest() { + bet = createEntity(em); + } + + @Test + @Transactional + public void createBet() throws Exception { + int databaseSizeBeforeCreate = betRepository.findAll().size(); + + // Create the Bet + restBetMockMvc.perform(post("/api/bets") + .contentType(MediaType.APPLICATION_JSON) + .content(TestUtil.convertObjectToJsonBytes(bet))) + .andExpect(status().isCreated()); + + // Validate the Bet in the database + List betList = betRepository.findAll(); + assertThat(betList).hasSize(databaseSizeBeforeCreate + 1); + Bet testBet = betList.get(betList.size() - 1); + assertThat(testBet.getChips()).isEqualTo(DEFAULT_CHIPS); + } + + @Test + @Transactional + public void createBetWithExistingId() throws Exception { + int databaseSizeBeforeCreate = betRepository.findAll().size(); + + // Create the Bet with an existing ID + bet.setId(1L); + + // An entity with an existing ID cannot be created, so this API call must fail + restBetMockMvc.perform(post("/api/bets") + .contentType(MediaType.APPLICATION_JSON) + .content(TestUtil.convertObjectToJsonBytes(bet))) + .andExpect(status().isBadRequest()); + + // Validate the Bet in the database + List betList = betRepository.findAll(); + assertThat(betList).hasSize(databaseSizeBeforeCreate); + } + + + @Test + @Transactional + public void getAllBets() throws Exception { + // Initialize the database + betRepository.saveAndFlush(bet); + + // Get all the betList + restBetMockMvc.perform(get("/api/bets?sort=id,desc")) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(jsonPath("$.[*].id").value(hasItem(bet.getId().intValue()))) + .andExpect(jsonPath("$.[*].chips").value(hasItem(DEFAULT_CHIPS))); + } + + @Test + @Transactional + public void getBet() throws Exception { + // Initialize the database + betRepository.saveAndFlush(bet); + + // Get the bet + restBetMockMvc.perform(get("/api/bets/{id}", bet.getId())) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(jsonPath("$.id").value(bet.getId().intValue())) + .andExpect(jsonPath("$.chips").value(DEFAULT_CHIPS)); + } + + @Test + @Transactional + public void getNonExistingBet() throws Exception { + // Get the bet + restBetMockMvc.perform(get("/api/bets/{id}", Long.MAX_VALUE)) + .andExpect(status().isNotFound()); + } + + @Test + @Transactional + public void updateBet() throws Exception { + // Initialize the database + betRepository.saveAndFlush(bet); + + int databaseSizeBeforeUpdate = betRepository.findAll().size(); + + // Update the bet + Bet updatedBet = betRepository.findById(bet.getId()).get(); + // Disconnect from session so that the updates on updatedBet are not directly saved in db + em.detach(updatedBet); + updatedBet + .chips(UPDATED_CHIPS); + + restBetMockMvc.perform(put("/api/bets") + .contentType(MediaType.APPLICATION_JSON) + .content(TestUtil.convertObjectToJsonBytes(updatedBet))) + .andExpect(status().isOk()); + + // Validate the Bet in the database + List betList = betRepository.findAll(); + assertThat(betList).hasSize(databaseSizeBeforeUpdate); + Bet testBet = betList.get(betList.size() - 1); + assertThat(testBet.getChips()).isEqualTo(UPDATED_CHIPS); + } + + @Test + @Transactional + public void updateNonExistingBet() throws Exception { + int databaseSizeBeforeUpdate = betRepository.findAll().size(); + + // Create the Bet + + // If the entity doesn't have an ID, it will throw BadRequestAlertException + restBetMockMvc.perform(put("/api/bets") + .contentType(MediaType.APPLICATION_JSON) + .content(TestUtil.convertObjectToJsonBytes(bet))) + .andExpect(status().isBadRequest()); + + // Validate the Bet in the database + List betList = betRepository.findAll(); + assertThat(betList).hasSize(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + public void deleteBet() throws Exception { + // Initialize the database + betRepository.saveAndFlush(bet); + + int databaseSizeBeforeDelete = betRepository.findAll().size(); + + // Delete the bet + restBetMockMvc.perform(delete("/api/bets/{id}", bet.getId()) + .accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isNoContent()); + + // Validate the database contains one less item + List betList = betRepository.findAll(); + assertThat(betList).hasSize(databaseSizeBeforeDelete - 1); + } +} diff --git a/src/test/java/com/mycompany/myapp/web/rest/GameCommissionResourceIT.java b/src/test/java/com/mycompany/myapp/web/rest/GameCommissionResourceIT.java new file mode 100644 index 0000000..1ac6fea --- /dev/null +++ b/src/test/java/com/mycompany/myapp/web/rest/GameCommissionResourceIT.java @@ -0,0 +1,211 @@ +package com.mycompany.myapp.web.rest; + +import com.mycompany.myapp.AdminApp; +import com.mycompany.myapp.domain.GameCommission; +import com.mycompany.myapp.repository.GameCommissionRepository; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.http.MediaType; +import org.springframework.security.test.context.support.WithMockUser; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.transaction.annotation.Transactional; +import javax.persistence.EntityManager; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.hamcrest.Matchers.hasItem; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + +/** + * Integration tests for the {@link GameCommissionResource} REST controller. + */ +@SpringBootTest(classes = AdminApp.class) + +@AutoConfigureMockMvc +@WithMockUser +public class GameCommissionResourceIT { + + private static final Integer DEFAULT_COMMISSION = 1; + private static final Integer UPDATED_COMMISSION = 2; + + @Autowired + private GameCommissionRepository gameCommissionRepository; + + @Autowired + private EntityManager em; + + @Autowired + private MockMvc restGameCommissionMockMvc; + + private GameCommission gameCommission; + + /** + * Create an entity for this test. + * + * This is a static method, as tests for other entities might also need it, + * if they test an entity which requires the current entity. + */ + public static GameCommission createEntity(EntityManager em) { + GameCommission gameCommission = new GameCommission() + .commission(DEFAULT_COMMISSION); + return gameCommission; + } + /** + * Create an updated entity for this test. + * + * This is a static method, as tests for other entities might also need it, + * if they test an entity which requires the current entity. + */ + public static GameCommission createUpdatedEntity(EntityManager em) { + GameCommission gameCommission = new GameCommission() + .commission(UPDATED_COMMISSION); + return gameCommission; + } + + @BeforeEach + public void initTest() { + gameCommission = createEntity(em); + } + + @Test + @Transactional + public void createGameCommission() throws Exception { + int databaseSizeBeforeCreate = gameCommissionRepository.findAll().size(); + + // Create the GameCommission + restGameCommissionMockMvc.perform(post("/api/game-commissions") + .contentType(MediaType.APPLICATION_JSON) + .content(TestUtil.convertObjectToJsonBytes(gameCommission))) + .andExpect(status().isCreated()); + + // Validate the GameCommission in the database + List gameCommissionList = gameCommissionRepository.findAll(); + assertThat(gameCommissionList).hasSize(databaseSizeBeforeCreate + 1); + GameCommission testGameCommission = gameCommissionList.get(gameCommissionList.size() - 1); + assertThat(testGameCommission.getCommission()).isEqualTo(DEFAULT_COMMISSION); + } + + @Test + @Transactional + public void createGameCommissionWithExistingId() throws Exception { + int databaseSizeBeforeCreate = gameCommissionRepository.findAll().size(); + + // Create the GameCommission with an existing ID + gameCommission.setId(1L); + + // An entity with an existing ID cannot be created, so this API call must fail + restGameCommissionMockMvc.perform(post("/api/game-commissions") + .contentType(MediaType.APPLICATION_JSON) + .content(TestUtil.convertObjectToJsonBytes(gameCommission))) + .andExpect(status().isBadRequest()); + + // Validate the GameCommission in the database + List gameCommissionList = gameCommissionRepository.findAll(); + assertThat(gameCommissionList).hasSize(databaseSizeBeforeCreate); + } + + + @Test + @Transactional + public void getAllGameCommissions() throws Exception { + // Initialize the database + gameCommissionRepository.saveAndFlush(gameCommission); + + // Get all the gameCommissionList + restGameCommissionMockMvc.perform(get("/api/game-commissions?sort=id,desc")) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(jsonPath("$.[*].id").value(hasItem(gameCommission.getId().intValue()))) + .andExpect(jsonPath("$.[*].commission").value(hasItem(DEFAULT_COMMISSION))); + } + + @Test + @Transactional + public void getGameCommission() throws Exception { + // Initialize the database + gameCommissionRepository.saveAndFlush(gameCommission); + + // Get the gameCommission + restGameCommissionMockMvc.perform(get("/api/game-commissions/{id}", gameCommission.getId())) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(jsonPath("$.id").value(gameCommission.getId().intValue())) + .andExpect(jsonPath("$.commission").value(DEFAULT_COMMISSION)); + } + + @Test + @Transactional + public void getNonExistingGameCommission() throws Exception { + // Get the gameCommission + restGameCommissionMockMvc.perform(get("/api/game-commissions/{id}", Long.MAX_VALUE)) + .andExpect(status().isNotFound()); + } + + @Test + @Transactional + public void updateGameCommission() throws Exception { + // Initialize the database + gameCommissionRepository.saveAndFlush(gameCommission); + + int databaseSizeBeforeUpdate = gameCommissionRepository.findAll().size(); + + // Update the gameCommission + GameCommission updatedGameCommission = gameCommissionRepository.findById(gameCommission.getId()).get(); + // Disconnect from session so that the updates on updatedGameCommission are not directly saved in db + em.detach(updatedGameCommission); + updatedGameCommission + .commission(UPDATED_COMMISSION); + + restGameCommissionMockMvc.perform(put("/api/game-commissions") + .contentType(MediaType.APPLICATION_JSON) + .content(TestUtil.convertObjectToJsonBytes(updatedGameCommission))) + .andExpect(status().isOk()); + + // Validate the GameCommission in the database + List gameCommissionList = gameCommissionRepository.findAll(); + assertThat(gameCommissionList).hasSize(databaseSizeBeforeUpdate); + GameCommission testGameCommission = gameCommissionList.get(gameCommissionList.size() - 1); + assertThat(testGameCommission.getCommission()).isEqualTo(UPDATED_COMMISSION); + } + + @Test + @Transactional + public void updateNonExistingGameCommission() throws Exception { + int databaseSizeBeforeUpdate = gameCommissionRepository.findAll().size(); + + // Create the GameCommission + + // If the entity doesn't have an ID, it will throw BadRequestAlertException + restGameCommissionMockMvc.perform(put("/api/game-commissions") + .contentType(MediaType.APPLICATION_JSON) + .content(TestUtil.convertObjectToJsonBytes(gameCommission))) + .andExpect(status().isBadRequest()); + + // Validate the GameCommission in the database + List gameCommissionList = gameCommissionRepository.findAll(); + assertThat(gameCommissionList).hasSize(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + public void deleteGameCommission() throws Exception { + // Initialize the database + gameCommissionRepository.saveAndFlush(gameCommission); + + int databaseSizeBeforeDelete = gameCommissionRepository.findAll().size(); + + // Delete the gameCommission + restGameCommissionMockMvc.perform(delete("/api/game-commissions/{id}", gameCommission.getId()) + .accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isNoContent()); + + // Validate the database contains one less item + List gameCommissionList = gameCommissionRepository.findAll(); + assertThat(gameCommissionList).hasSize(databaseSizeBeforeDelete - 1); + } +} diff --git a/src/test/java/com/mycompany/myapp/web/rest/GameResourceIT.java b/src/test/java/com/mycompany/myapp/web/rest/GameResourceIT.java new file mode 100644 index 0000000..dc02669 --- /dev/null +++ b/src/test/java/com/mycompany/myapp/web/rest/GameResourceIT.java @@ -0,0 +1,211 @@ +package com.mycompany.myapp.web.rest; + +import com.mycompany.myapp.AdminApp; +import com.mycompany.myapp.domain.Game; +import com.mycompany.myapp.repository.GameRepository; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.http.MediaType; +import org.springframework.security.test.context.support.WithMockUser; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.transaction.annotation.Transactional; +import javax.persistence.EntityManager; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.hamcrest.Matchers.hasItem; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + +/** + * Integration tests for the {@link GameResource} REST controller. + */ +@SpringBootTest(classes = AdminApp.class) + +@AutoConfigureMockMvc +@WithMockUser +public class GameResourceIT { + + private static final String DEFAULT_NAME = "AAAAAAAAAA"; + private static final String UPDATED_NAME = "BBBBBBBBBB"; + + @Autowired + private GameRepository gameRepository; + + @Autowired + private EntityManager em; + + @Autowired + private MockMvc restGameMockMvc; + + private Game game; + + /** + * Create an entity for this test. + * + * This is a static method, as tests for other entities might also need it, + * if they test an entity which requires the current entity. + */ + public static Game createEntity(EntityManager em) { + Game game = new Game() + .name(DEFAULT_NAME); + return game; + } + /** + * Create an updated entity for this test. + * + * This is a static method, as tests for other entities might also need it, + * if they test an entity which requires the current entity. + */ + public static Game createUpdatedEntity(EntityManager em) { + Game game = new Game() + .name(UPDATED_NAME); + return game; + } + + @BeforeEach + public void initTest() { + game = createEntity(em); + } + + @Test + @Transactional + public void createGame() throws Exception { + int databaseSizeBeforeCreate = gameRepository.findAll().size(); + + // Create the Game + restGameMockMvc.perform(post("/api/games") + .contentType(MediaType.APPLICATION_JSON) + .content(TestUtil.convertObjectToJsonBytes(game))) + .andExpect(status().isCreated()); + + // Validate the Game in the database + List gameList = gameRepository.findAll(); + assertThat(gameList).hasSize(databaseSizeBeforeCreate + 1); + Game testGame = gameList.get(gameList.size() - 1); + assertThat(testGame.getName()).isEqualTo(DEFAULT_NAME); + } + + @Test + @Transactional + public void createGameWithExistingId() throws Exception { + int databaseSizeBeforeCreate = gameRepository.findAll().size(); + + // Create the Game with an existing ID + game.setId(1L); + + // An entity with an existing ID cannot be created, so this API call must fail + restGameMockMvc.perform(post("/api/games") + .contentType(MediaType.APPLICATION_JSON) + .content(TestUtil.convertObjectToJsonBytes(game))) + .andExpect(status().isBadRequest()); + + // Validate the Game in the database + List gameList = gameRepository.findAll(); + assertThat(gameList).hasSize(databaseSizeBeforeCreate); + } + + + @Test + @Transactional + public void getAllGames() throws Exception { + // Initialize the database + gameRepository.saveAndFlush(game); + + // Get all the gameList + restGameMockMvc.perform(get("/api/games?sort=id,desc")) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(jsonPath("$.[*].id").value(hasItem(game.getId().intValue()))) + .andExpect(jsonPath("$.[*].name").value(hasItem(DEFAULT_NAME))); + } + + @Test + @Transactional + public void getGame() throws Exception { + // Initialize the database + gameRepository.saveAndFlush(game); + + // Get the game + restGameMockMvc.perform(get("/api/games/{id}", game.getId())) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(jsonPath("$.id").value(game.getId().intValue())) + .andExpect(jsonPath("$.name").value(DEFAULT_NAME)); + } + + @Test + @Transactional + public void getNonExistingGame() throws Exception { + // Get the game + restGameMockMvc.perform(get("/api/games/{id}", Long.MAX_VALUE)) + .andExpect(status().isNotFound()); + } + + @Test + @Transactional + public void updateGame() throws Exception { + // Initialize the database + gameRepository.saveAndFlush(game); + + int databaseSizeBeforeUpdate = gameRepository.findAll().size(); + + // Update the game + Game updatedGame = gameRepository.findById(game.getId()).get(); + // Disconnect from session so that the updates on updatedGame are not directly saved in db + em.detach(updatedGame); + updatedGame + .name(UPDATED_NAME); + + restGameMockMvc.perform(put("/api/games") + .contentType(MediaType.APPLICATION_JSON) + .content(TestUtil.convertObjectToJsonBytes(updatedGame))) + .andExpect(status().isOk()); + + // Validate the Game in the database + List gameList = gameRepository.findAll(); + assertThat(gameList).hasSize(databaseSizeBeforeUpdate); + Game testGame = gameList.get(gameList.size() - 1); + assertThat(testGame.getName()).isEqualTo(UPDATED_NAME); + } + + @Test + @Transactional + public void updateNonExistingGame() throws Exception { + int databaseSizeBeforeUpdate = gameRepository.findAll().size(); + + // Create the Game + + // If the entity doesn't have an ID, it will throw BadRequestAlertException + restGameMockMvc.perform(put("/api/games") + .contentType(MediaType.APPLICATION_JSON) + .content(TestUtil.convertObjectToJsonBytes(game))) + .andExpect(status().isBadRequest()); + + // Validate the Game in the database + List gameList = gameRepository.findAll(); + assertThat(gameList).hasSize(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + public void deleteGame() throws Exception { + // Initialize the database + gameRepository.saveAndFlush(game); + + int databaseSizeBeforeDelete = gameRepository.findAll().size(); + + // Delete the game + restGameMockMvc.perform(delete("/api/games/{id}", game.getId()) + .accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isNoContent()); + + // Validate the database contains one less item + List gameList = gameRepository.findAll(); + assertThat(gameList).hasSize(databaseSizeBeforeDelete - 1); + } +} diff --git a/src/test/java/com/mycompany/myapp/web/rest/GameUserResourceIT.java b/src/test/java/com/mycompany/myapp/web/rest/GameUserResourceIT.java new file mode 100644 index 0000000..e49b2ee --- /dev/null +++ b/src/test/java/com/mycompany/myapp/web/rest/GameUserResourceIT.java @@ -0,0 +1,221 @@ +package com.mycompany.myapp.web.rest; + +import com.mycompany.myapp.AdminApp; +import com.mycompany.myapp.domain.GameUser; +import com.mycompany.myapp.repository.GameUserRepository; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.http.MediaType; +import org.springframework.security.test.context.support.WithMockUser; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.transaction.annotation.Transactional; +import javax.persistence.EntityManager; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.hamcrest.Matchers.hasItem; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + +/** + * Integration tests for the {@link GameUserResource} REST controller. + */ +@SpringBootTest(classes = AdminApp.class) + +@AutoConfigureMockMvc +@WithMockUser +public class GameUserResourceIT { + + private static final String DEFAULT_USERNAME = "AAAAAAAAAA"; + private static final String UPDATED_USERNAME = "BBBBBBBBBB"; + + private static final String DEFAULT_PASSWORD = "AAAAAAAAAA"; + private static final String UPDATED_PASSWORD = "BBBBBBBBBB"; + + @Autowired + private GameUserRepository gameUserRepository; + + @Autowired + private EntityManager em; + + @Autowired + private MockMvc restGameUserMockMvc; + + private GameUser gameUser; + + /** + * Create an entity for this test. + * + * This is a static method, as tests for other entities might also need it, + * if they test an entity which requires the current entity. + */ + public static GameUser createEntity(EntityManager em) { + GameUser gameUser = new GameUser() + .username(DEFAULT_USERNAME) + .password(DEFAULT_PASSWORD); + return gameUser; + } + /** + * Create an updated entity for this test. + * + * This is a static method, as tests for other entities might also need it, + * if they test an entity which requires the current entity. + */ + public static GameUser createUpdatedEntity(EntityManager em) { + GameUser gameUser = new GameUser() + .username(UPDATED_USERNAME) + .password(UPDATED_PASSWORD); + return gameUser; + } + + @BeforeEach + public void initTest() { + gameUser = createEntity(em); + } + + @Test + @Transactional + public void createGameUser() throws Exception { + int databaseSizeBeforeCreate = gameUserRepository.findAll().size(); + + // Create the GameUser + restGameUserMockMvc.perform(post("/api/game-users") + .contentType(MediaType.APPLICATION_JSON) + .content(TestUtil.convertObjectToJsonBytes(gameUser))) + .andExpect(status().isCreated()); + + // Validate the GameUser in the database + List gameUserList = gameUserRepository.findAll(); + assertThat(gameUserList).hasSize(databaseSizeBeforeCreate + 1); + GameUser testGameUser = gameUserList.get(gameUserList.size() - 1); + assertThat(testGameUser.getUsername()).isEqualTo(DEFAULT_USERNAME); + assertThat(testGameUser.getPassword()).isEqualTo(DEFAULT_PASSWORD); + } + + @Test + @Transactional + public void createGameUserWithExistingId() throws Exception { + int databaseSizeBeforeCreate = gameUserRepository.findAll().size(); + + // Create the GameUser with an existing ID + gameUser.setId(1L); + + // An entity with an existing ID cannot be created, so this API call must fail + restGameUserMockMvc.perform(post("/api/game-users") + .contentType(MediaType.APPLICATION_JSON) + .content(TestUtil.convertObjectToJsonBytes(gameUser))) + .andExpect(status().isBadRequest()); + + // Validate the GameUser in the database + List gameUserList = gameUserRepository.findAll(); + assertThat(gameUserList).hasSize(databaseSizeBeforeCreate); + } + + + @Test + @Transactional + public void getAllGameUsers() throws Exception { + // Initialize the database + gameUserRepository.saveAndFlush(gameUser); + + // Get all the gameUserList + restGameUserMockMvc.perform(get("/api/game-users?sort=id,desc")) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(jsonPath("$.[*].id").value(hasItem(gameUser.getId().intValue()))) + .andExpect(jsonPath("$.[*].username").value(hasItem(DEFAULT_USERNAME))) + .andExpect(jsonPath("$.[*].password").value(hasItem(DEFAULT_PASSWORD))); + } + + @Test + @Transactional + public void getGameUser() throws Exception { + // Initialize the database + gameUserRepository.saveAndFlush(gameUser); + + // Get the gameUser + restGameUserMockMvc.perform(get("/api/game-users/{id}", gameUser.getId())) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(jsonPath("$.id").value(gameUser.getId().intValue())) + .andExpect(jsonPath("$.username").value(DEFAULT_USERNAME)) + .andExpect(jsonPath("$.password").value(DEFAULT_PASSWORD)); + } + + @Test + @Transactional + public void getNonExistingGameUser() throws Exception { + // Get the gameUser + restGameUserMockMvc.perform(get("/api/game-users/{id}", Long.MAX_VALUE)) + .andExpect(status().isNotFound()); + } + + @Test + @Transactional + public void updateGameUser() throws Exception { + // Initialize the database + gameUserRepository.saveAndFlush(gameUser); + + int databaseSizeBeforeUpdate = gameUserRepository.findAll().size(); + + // Update the gameUser + GameUser updatedGameUser = gameUserRepository.findById(gameUser.getId()).get(); + // Disconnect from session so that the updates on updatedGameUser are not directly saved in db + em.detach(updatedGameUser); + updatedGameUser + .username(UPDATED_USERNAME) + .password(UPDATED_PASSWORD); + + restGameUserMockMvc.perform(put("/api/game-users") + .contentType(MediaType.APPLICATION_JSON) + .content(TestUtil.convertObjectToJsonBytes(updatedGameUser))) + .andExpect(status().isOk()); + + // Validate the GameUser in the database + List gameUserList = gameUserRepository.findAll(); + assertThat(gameUserList).hasSize(databaseSizeBeforeUpdate); + GameUser testGameUser = gameUserList.get(gameUserList.size() - 1); + assertThat(testGameUser.getUsername()).isEqualTo(UPDATED_USERNAME); + assertThat(testGameUser.getPassword()).isEqualTo(UPDATED_PASSWORD); + } + + @Test + @Transactional + public void updateNonExistingGameUser() throws Exception { + int databaseSizeBeforeUpdate = gameUserRepository.findAll().size(); + + // Create the GameUser + + // If the entity doesn't have an ID, it will throw BadRequestAlertException + restGameUserMockMvc.perform(put("/api/game-users") + .contentType(MediaType.APPLICATION_JSON) + .content(TestUtil.convertObjectToJsonBytes(gameUser))) + .andExpect(status().isBadRequest()); + + // Validate the GameUser in the database + List gameUserList = gameUserRepository.findAll(); + assertThat(gameUserList).hasSize(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + public void deleteGameUser() throws Exception { + // Initialize the database + gameUserRepository.saveAndFlush(gameUser); + + int databaseSizeBeforeDelete = gameUserRepository.findAll().size(); + + // Delete the gameUser + restGameUserMockMvc.perform(delete("/api/game-users/{id}", gameUser.getId()) + .accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isNoContent()); + + // Validate the database contains one less item + List gameUserList = gameUserRepository.findAll(); + assertThat(gameUserList).hasSize(databaseSizeBeforeDelete - 1); + } +} diff --git a/src/test/java/com/mycompany/myapp/web/rest/HandResourceIT.java b/src/test/java/com/mycompany/myapp/web/rest/HandResourceIT.java new file mode 100644 index 0000000..8f8f31d --- /dev/null +++ b/src/test/java/com/mycompany/myapp/web/rest/HandResourceIT.java @@ -0,0 +1,212 @@ +package com.mycompany.myapp.web.rest; + +import com.mycompany.myapp.AdminApp; +import com.mycompany.myapp.domain.Hand; +import com.mycompany.myapp.repository.HandRepository; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.http.MediaType; +import org.springframework.security.test.context.support.WithMockUser; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.transaction.annotation.Transactional; +import javax.persistence.EntityManager; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.hamcrest.Matchers.hasItem; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + +import com.mycompany.myapp.domain.enumeration.HandStatus; +/** + * Integration tests for the {@link HandResource} REST controller. + */ +@SpringBootTest(classes = AdminApp.class) + +@AutoConfigureMockMvc +@WithMockUser +public class HandResourceIT { + + private static final HandStatus DEFAULT_STATUS = HandStatus.Begin; + private static final HandStatus UPDATED_STATUS = HandStatus.End; + + @Autowired + private HandRepository handRepository; + + @Autowired + private EntityManager em; + + @Autowired + private MockMvc restHandMockMvc; + + private Hand hand; + + /** + * Create an entity for this test. + * + * This is a static method, as tests for other entities might also need it, + * if they test an entity which requires the current entity. + */ + public static Hand createEntity(EntityManager em) { + Hand hand = new Hand() + .status(DEFAULT_STATUS); + return hand; + } + /** + * Create an updated entity for this test. + * + * This is a static method, as tests for other entities might also need it, + * if they test an entity which requires the current entity. + */ + public static Hand createUpdatedEntity(EntityManager em) { + Hand hand = new Hand() + .status(UPDATED_STATUS); + return hand; + } + + @BeforeEach + public void initTest() { + hand = createEntity(em); + } + + @Test + @Transactional + public void createHand() throws Exception { + int databaseSizeBeforeCreate = handRepository.findAll().size(); + + // Create the Hand + restHandMockMvc.perform(post("/api/hands") + .contentType(MediaType.APPLICATION_JSON) + .content(TestUtil.convertObjectToJsonBytes(hand))) + .andExpect(status().isCreated()); + + // Validate the Hand in the database + List handList = handRepository.findAll(); + assertThat(handList).hasSize(databaseSizeBeforeCreate + 1); + Hand testHand = handList.get(handList.size() - 1); + assertThat(testHand.getStatus()).isEqualTo(DEFAULT_STATUS); + } + + @Test + @Transactional + public void createHandWithExistingId() throws Exception { + int databaseSizeBeforeCreate = handRepository.findAll().size(); + + // Create the Hand with an existing ID + hand.setId(1L); + + // An entity with an existing ID cannot be created, so this API call must fail + restHandMockMvc.perform(post("/api/hands") + .contentType(MediaType.APPLICATION_JSON) + .content(TestUtil.convertObjectToJsonBytes(hand))) + .andExpect(status().isBadRequest()); + + // Validate the Hand in the database + List handList = handRepository.findAll(); + assertThat(handList).hasSize(databaseSizeBeforeCreate); + } + + + @Test + @Transactional + public void getAllHands() throws Exception { + // Initialize the database + handRepository.saveAndFlush(hand); + + // Get all the handList + restHandMockMvc.perform(get("/api/hands?sort=id,desc")) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(jsonPath("$.[*].id").value(hasItem(hand.getId().intValue()))) + .andExpect(jsonPath("$.[*].status").value(hasItem(DEFAULT_STATUS.toString()))); + } + + @Test + @Transactional + public void getHand() throws Exception { + // Initialize the database + handRepository.saveAndFlush(hand); + + // Get the hand + restHandMockMvc.perform(get("/api/hands/{id}", hand.getId())) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(jsonPath("$.id").value(hand.getId().intValue())) + .andExpect(jsonPath("$.status").value(DEFAULT_STATUS.toString())); + } + + @Test + @Transactional + public void getNonExistingHand() throws Exception { + // Get the hand + restHandMockMvc.perform(get("/api/hands/{id}", Long.MAX_VALUE)) + .andExpect(status().isNotFound()); + } + + @Test + @Transactional + public void updateHand() throws Exception { + // Initialize the database + handRepository.saveAndFlush(hand); + + int databaseSizeBeforeUpdate = handRepository.findAll().size(); + + // Update the hand + Hand updatedHand = handRepository.findById(hand.getId()).get(); + // Disconnect from session so that the updates on updatedHand are not directly saved in db + em.detach(updatedHand); + updatedHand + .status(UPDATED_STATUS); + + restHandMockMvc.perform(put("/api/hands") + .contentType(MediaType.APPLICATION_JSON) + .content(TestUtil.convertObjectToJsonBytes(updatedHand))) + .andExpect(status().isOk()); + + // Validate the Hand in the database + List handList = handRepository.findAll(); + assertThat(handList).hasSize(databaseSizeBeforeUpdate); + Hand testHand = handList.get(handList.size() - 1); + assertThat(testHand.getStatus()).isEqualTo(UPDATED_STATUS); + } + + @Test + @Transactional + public void updateNonExistingHand() throws Exception { + int databaseSizeBeforeUpdate = handRepository.findAll().size(); + + // Create the Hand + + // If the entity doesn't have an ID, it will throw BadRequestAlertException + restHandMockMvc.perform(put("/api/hands") + .contentType(MediaType.APPLICATION_JSON) + .content(TestUtil.convertObjectToJsonBytes(hand))) + .andExpect(status().isBadRequest()); + + // Validate the Hand in the database + List handList = handRepository.findAll(); + assertThat(handList).hasSize(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + public void deleteHand() throws Exception { + // Initialize the database + handRepository.saveAndFlush(hand); + + int databaseSizeBeforeDelete = handRepository.findAll().size(); + + // Delete the hand + restHandMockMvc.perform(delete("/api/hands/{id}", hand.getId()) + .accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isNoContent()); + + // Validate the database contains one less item + List handList = handRepository.findAll(); + assertThat(handList).hasSize(databaseSizeBeforeDelete - 1); + } +} diff --git a/src/test/javascript/spec/app/entities/bet/bet-delete-dialog.component.spec.ts b/src/test/javascript/spec/app/entities/bet/bet-delete-dialog.component.spec.ts new file mode 100644 index 0000000..a776466 --- /dev/null +++ b/src/test/javascript/spec/app/entities/bet/bet-delete-dialog.component.spec.ts @@ -0,0 +1,65 @@ +import { ComponentFixture, TestBed, inject, fakeAsync, tick } from '@angular/core/testing'; +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; +import { of } from 'rxjs'; +import { JhiEventManager } from 'ng-jhipster'; + +import { AdminTestModule } from '../../../test.module'; +import { MockEventManager } from '../../../helpers/mock-event-manager.service'; +import { MockActiveModal } from '../../../helpers/mock-active-modal.service'; +import { BetDeleteDialogComponent } from 'app/entities/bet/bet-delete-dialog.component'; +import { BetService } from 'app/entities/bet/bet.service'; + +describe('Component Tests', () => { + describe('Bet Management Delete Component', () => { + let comp: BetDeleteDialogComponent; + let fixture: ComponentFixture; + let service: BetService; + let mockEventManager: MockEventManager; + let mockActiveModal: MockActiveModal; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [AdminTestModule], + declarations: [BetDeleteDialogComponent] + }) + .overrideTemplate(BetDeleteDialogComponent, '') + .compileComponents(); + fixture = TestBed.createComponent(BetDeleteDialogComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(BetService); + mockEventManager = TestBed.get(JhiEventManager); + mockActiveModal = TestBed.get(NgbActiveModal); + }); + + describe('confirmDelete', () => { + it('Should call delete service on confirmDelete', inject( + [], + fakeAsync(() => { + // GIVEN + spyOn(service, 'delete').and.returnValue(of({})); + + // WHEN + comp.confirmDelete(123); + tick(); + + // THEN + expect(service.delete).toHaveBeenCalledWith(123); + expect(mockActiveModal.closeSpy).toHaveBeenCalled(); + expect(mockEventManager.broadcastSpy).toHaveBeenCalled(); + }) + )); + + it('Should not call delete service on clear', () => { + // GIVEN + spyOn(service, 'delete'); + + // WHEN + comp.cancel(); + + // THEN + expect(service.delete).not.toHaveBeenCalled(); + expect(mockActiveModal.dismissSpy).toHaveBeenCalled(); + }); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/bet/bet-detail.component.spec.ts b/src/test/javascript/spec/app/entities/bet/bet-detail.component.spec.ts new file mode 100644 index 0000000..3c50242 --- /dev/null +++ b/src/test/javascript/spec/app/entities/bet/bet-detail.component.spec.ts @@ -0,0 +1,37 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { ActivatedRoute } from '@angular/router'; +import { of } from 'rxjs'; + +import { AdminTestModule } from '../../../test.module'; +import { BetDetailComponent } from 'app/entities/bet/bet-detail.component'; +import { Bet } from 'app/shared/model/bet.model'; + +describe('Component Tests', () => { + describe('Bet Management Detail Component', () => { + let comp: BetDetailComponent; + let fixture: ComponentFixture; + const route = ({ data: of({ bet: new Bet(123) }) } as any) as ActivatedRoute; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [AdminTestModule], + declarations: [BetDetailComponent], + providers: [{ provide: ActivatedRoute, useValue: route }] + }) + .overrideTemplate(BetDetailComponent, '') + .compileComponents(); + fixture = TestBed.createComponent(BetDetailComponent); + comp = fixture.componentInstance; + }); + + describe('OnInit', () => { + it('Should load bet on init', () => { + // WHEN + comp.ngOnInit(); + + // THEN + expect(comp.bet).toEqual(jasmine.objectContaining({ id: 123 })); + }); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/bet/bet-update.component.spec.ts b/src/test/javascript/spec/app/entities/bet/bet-update.component.spec.ts new file mode 100644 index 0000000..2368e70 --- /dev/null +++ b/src/test/javascript/spec/app/entities/bet/bet-update.component.spec.ts @@ -0,0 +1,61 @@ +import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing'; +import { HttpResponse } from '@angular/common/http'; +import { FormBuilder } from '@angular/forms'; +import { of } from 'rxjs'; + +import { AdminTestModule } from '../../../test.module'; +import { BetUpdateComponent } from 'app/entities/bet/bet-update.component'; +import { BetService } from 'app/entities/bet/bet.service'; +import { Bet } from 'app/shared/model/bet.model'; + +describe('Component Tests', () => { + describe('Bet Management Update Component', () => { + let comp: BetUpdateComponent; + let fixture: ComponentFixture; + let service: BetService; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [AdminTestModule], + declarations: [BetUpdateComponent], + providers: [FormBuilder] + }) + .overrideTemplate(BetUpdateComponent, '') + .compileComponents(); + + fixture = TestBed.createComponent(BetUpdateComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(BetService); + }); + + describe('save', () => { + it('Should call update service on save for existing entity', fakeAsync(() => { + // GIVEN + const entity = new Bet(123); + spyOn(service, 'update').and.returnValue(of(new HttpResponse({ body: entity }))); + comp.updateForm(entity); + // WHEN + comp.save(); + tick(); // simulate async + + // THEN + expect(service.update).toHaveBeenCalledWith(entity); + expect(comp.isSaving).toEqual(false); + })); + + it('Should call create service on save for new entity', fakeAsync(() => { + // GIVEN + const entity = new Bet(); + spyOn(service, 'create').and.returnValue(of(new HttpResponse({ body: entity }))); + comp.updateForm(entity); + // WHEN + comp.save(); + tick(); // simulate async + + // THEN + expect(service.create).toHaveBeenCalledWith(entity); + expect(comp.isSaving).toEqual(false); + })); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/bet/bet.component.spec.ts b/src/test/javascript/spec/app/entities/bet/bet.component.spec.ts new file mode 100644 index 0000000..045631d --- /dev/null +++ b/src/test/javascript/spec/app/entities/bet/bet.component.spec.ts @@ -0,0 +1,49 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { of } from 'rxjs'; +import { HttpHeaders, HttpResponse } from '@angular/common/http'; + +import { AdminTestModule } from '../../../test.module'; +import { BetComponent } from 'app/entities/bet/bet.component'; +import { BetService } from 'app/entities/bet/bet.service'; +import { Bet } from 'app/shared/model/bet.model'; + +describe('Component Tests', () => { + describe('Bet Management Component', () => { + let comp: BetComponent; + let fixture: ComponentFixture; + let service: BetService; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [AdminTestModule], + declarations: [BetComponent] + }) + .overrideTemplate(BetComponent, '') + .compileComponents(); + + fixture = TestBed.createComponent(BetComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(BetService); + }); + + it('Should call load all on init', () => { + // GIVEN + const headers = new HttpHeaders().append('link', 'link;link'); + spyOn(service, 'query').and.returnValue( + of( + new HttpResponse({ + body: [new Bet(123)], + headers + }) + ) + ); + + // WHEN + comp.ngOnInit(); + + // THEN + expect(service.query).toHaveBeenCalled(); + expect(comp.bets && comp.bets[0]).toEqual(jasmine.objectContaining({ id: 123 })); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/bet/bet.service.spec.ts b/src/test/javascript/spec/app/entities/bet/bet.service.spec.ts new file mode 100644 index 0000000..89d5418 --- /dev/null +++ b/src/test/javascript/spec/app/entities/bet/bet.service.spec.ts @@ -0,0 +1,102 @@ +import { TestBed, getTestBed } from '@angular/core/testing'; +import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; +import { BetService } from 'app/entities/bet/bet.service'; +import { IBet, Bet } from 'app/shared/model/bet.model'; + +describe('Service Tests', () => { + describe('Bet Service', () => { + let injector: TestBed; + let service: BetService; + let httpMock: HttpTestingController; + let elemDefault: IBet; + let expectedResult: IBet | IBet[] | boolean | null; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HttpClientTestingModule] + }); + expectedResult = null; + injector = getTestBed(); + service = injector.get(BetService); + httpMock = injector.get(HttpTestingController); + + elemDefault = new Bet(0, 0); + }); + + describe('Service methods', () => { + it('should find an element', () => { + const returnedFromService = Object.assign({}, elemDefault); + + service.find(123).subscribe(resp => (expectedResult = resp.body)); + + const req = httpMock.expectOne({ method: 'GET' }); + req.flush(returnedFromService); + expect(expectedResult).toMatchObject(elemDefault); + }); + + it('should create a Bet', () => { + const returnedFromService = Object.assign( + { + id: 0 + }, + elemDefault + ); + + const expected = Object.assign({}, returnedFromService); + + service.create(new Bet()).subscribe(resp => (expectedResult = resp.body)); + + const req = httpMock.expectOne({ method: 'POST' }); + req.flush(returnedFromService); + expect(expectedResult).toMatchObject(expected); + }); + + it('should update a Bet', () => { + const returnedFromService = Object.assign( + { + chips: 1 + }, + elemDefault + ); + + const expected = Object.assign({}, returnedFromService); + + service.update(expected).subscribe(resp => (expectedResult = resp.body)); + + const req = httpMock.expectOne({ method: 'PUT' }); + req.flush(returnedFromService); + expect(expectedResult).toMatchObject(expected); + }); + + it('should return a list of Bet', () => { + const returnedFromService = Object.assign( + { + chips: 1 + }, + elemDefault + ); + + const expected = Object.assign({}, returnedFromService); + + service.query().subscribe(resp => (expectedResult = resp.body)); + + const req = httpMock.expectOne({ method: 'GET' }); + req.flush([returnedFromService]); + httpMock.verify(); + expect(expectedResult).toContainEqual(expected); + }); + + it('should delete a Bet', () => { + service.delete(123).subscribe(resp => (expectedResult = resp.ok)); + + const req = httpMock.expectOne({ method: 'DELETE' }); + req.flush({ status: 200 }); + expect(expectedResult); + }); + }); + + afterEach(() => { + httpMock.verify(); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/game-commission/game-commission-delete-dialog.component.spec.ts b/src/test/javascript/spec/app/entities/game-commission/game-commission-delete-dialog.component.spec.ts new file mode 100644 index 0000000..54e43e1 --- /dev/null +++ b/src/test/javascript/spec/app/entities/game-commission/game-commission-delete-dialog.component.spec.ts @@ -0,0 +1,65 @@ +import { ComponentFixture, TestBed, inject, fakeAsync, tick } from '@angular/core/testing'; +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; +import { of } from 'rxjs'; +import { JhiEventManager } from 'ng-jhipster'; + +import { AdminTestModule } from '../../../test.module'; +import { MockEventManager } from '../../../helpers/mock-event-manager.service'; +import { MockActiveModal } from '../../../helpers/mock-active-modal.service'; +import { GameCommissionDeleteDialogComponent } from 'app/entities/game-commission/game-commission-delete-dialog.component'; +import { GameCommissionService } from 'app/entities/game-commission/game-commission.service'; + +describe('Component Tests', () => { + describe('GameCommission Management Delete Component', () => { + let comp: GameCommissionDeleteDialogComponent; + let fixture: ComponentFixture; + let service: GameCommissionService; + let mockEventManager: MockEventManager; + let mockActiveModal: MockActiveModal; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [AdminTestModule], + declarations: [GameCommissionDeleteDialogComponent] + }) + .overrideTemplate(GameCommissionDeleteDialogComponent, '') + .compileComponents(); + fixture = TestBed.createComponent(GameCommissionDeleteDialogComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(GameCommissionService); + mockEventManager = TestBed.get(JhiEventManager); + mockActiveModal = TestBed.get(NgbActiveModal); + }); + + describe('confirmDelete', () => { + it('Should call delete service on confirmDelete', inject( + [], + fakeAsync(() => { + // GIVEN + spyOn(service, 'delete').and.returnValue(of({})); + + // WHEN + comp.confirmDelete(123); + tick(); + + // THEN + expect(service.delete).toHaveBeenCalledWith(123); + expect(mockActiveModal.closeSpy).toHaveBeenCalled(); + expect(mockEventManager.broadcastSpy).toHaveBeenCalled(); + }) + )); + + it('Should not call delete service on clear', () => { + // GIVEN + spyOn(service, 'delete'); + + // WHEN + comp.cancel(); + + // THEN + expect(service.delete).not.toHaveBeenCalled(); + expect(mockActiveModal.dismissSpy).toHaveBeenCalled(); + }); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/game-commission/game-commission-detail.component.spec.ts b/src/test/javascript/spec/app/entities/game-commission/game-commission-detail.component.spec.ts new file mode 100644 index 0000000..d9e3389 --- /dev/null +++ b/src/test/javascript/spec/app/entities/game-commission/game-commission-detail.component.spec.ts @@ -0,0 +1,37 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { ActivatedRoute } from '@angular/router'; +import { of } from 'rxjs'; + +import { AdminTestModule } from '../../../test.module'; +import { GameCommissionDetailComponent } from 'app/entities/game-commission/game-commission-detail.component'; +import { GameCommission } from 'app/shared/model/game-commission.model'; + +describe('Component Tests', () => { + describe('GameCommission Management Detail Component', () => { + let comp: GameCommissionDetailComponent; + let fixture: ComponentFixture; + const route = ({ data: of({ gameCommission: new GameCommission(123) }) } as any) as ActivatedRoute; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [AdminTestModule], + declarations: [GameCommissionDetailComponent], + providers: [{ provide: ActivatedRoute, useValue: route }] + }) + .overrideTemplate(GameCommissionDetailComponent, '') + .compileComponents(); + fixture = TestBed.createComponent(GameCommissionDetailComponent); + comp = fixture.componentInstance; + }); + + describe('OnInit', () => { + it('Should load gameCommission on init', () => { + // WHEN + comp.ngOnInit(); + + // THEN + expect(comp.gameCommission).toEqual(jasmine.objectContaining({ id: 123 })); + }); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/game-commission/game-commission-update.component.spec.ts b/src/test/javascript/spec/app/entities/game-commission/game-commission-update.component.spec.ts new file mode 100644 index 0000000..0ac7062 --- /dev/null +++ b/src/test/javascript/spec/app/entities/game-commission/game-commission-update.component.spec.ts @@ -0,0 +1,61 @@ +import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing'; +import { HttpResponse } from '@angular/common/http'; +import { FormBuilder } from '@angular/forms'; +import { of } from 'rxjs'; + +import { AdminTestModule } from '../../../test.module'; +import { GameCommissionUpdateComponent } from 'app/entities/game-commission/game-commission-update.component'; +import { GameCommissionService } from 'app/entities/game-commission/game-commission.service'; +import { GameCommission } from 'app/shared/model/game-commission.model'; + +describe('Component Tests', () => { + describe('GameCommission Management Update Component', () => { + let comp: GameCommissionUpdateComponent; + let fixture: ComponentFixture; + let service: GameCommissionService; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [AdminTestModule], + declarations: [GameCommissionUpdateComponent], + providers: [FormBuilder] + }) + .overrideTemplate(GameCommissionUpdateComponent, '') + .compileComponents(); + + fixture = TestBed.createComponent(GameCommissionUpdateComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(GameCommissionService); + }); + + describe('save', () => { + it('Should call update service on save for existing entity', fakeAsync(() => { + // GIVEN + const entity = new GameCommission(123); + spyOn(service, 'update').and.returnValue(of(new HttpResponse({ body: entity }))); + comp.updateForm(entity); + // WHEN + comp.save(); + tick(); // simulate async + + // THEN + expect(service.update).toHaveBeenCalledWith(entity); + expect(comp.isSaving).toEqual(false); + })); + + it('Should call create service on save for new entity', fakeAsync(() => { + // GIVEN + const entity = new GameCommission(); + spyOn(service, 'create').and.returnValue(of(new HttpResponse({ body: entity }))); + comp.updateForm(entity); + // WHEN + comp.save(); + tick(); // simulate async + + // THEN + expect(service.create).toHaveBeenCalledWith(entity); + expect(comp.isSaving).toEqual(false); + })); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/game-commission/game-commission.component.spec.ts b/src/test/javascript/spec/app/entities/game-commission/game-commission.component.spec.ts new file mode 100644 index 0000000..6d1d005 --- /dev/null +++ b/src/test/javascript/spec/app/entities/game-commission/game-commission.component.spec.ts @@ -0,0 +1,49 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { of } from 'rxjs'; +import { HttpHeaders, HttpResponse } from '@angular/common/http'; + +import { AdminTestModule } from '../../../test.module'; +import { GameCommissionComponent } from 'app/entities/game-commission/game-commission.component'; +import { GameCommissionService } from 'app/entities/game-commission/game-commission.service'; +import { GameCommission } from 'app/shared/model/game-commission.model'; + +describe('Component Tests', () => { + describe('GameCommission Management Component', () => { + let comp: GameCommissionComponent; + let fixture: ComponentFixture; + let service: GameCommissionService; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [AdminTestModule], + declarations: [GameCommissionComponent] + }) + .overrideTemplate(GameCommissionComponent, '') + .compileComponents(); + + fixture = TestBed.createComponent(GameCommissionComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(GameCommissionService); + }); + + it('Should call load all on init', () => { + // GIVEN + const headers = new HttpHeaders().append('link', 'link;link'); + spyOn(service, 'query').and.returnValue( + of( + new HttpResponse({ + body: [new GameCommission(123)], + headers + }) + ) + ); + + // WHEN + comp.ngOnInit(); + + // THEN + expect(service.query).toHaveBeenCalled(); + expect(comp.gameCommissions && comp.gameCommissions[0]).toEqual(jasmine.objectContaining({ id: 123 })); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/game-commission/game-commission.service.spec.ts b/src/test/javascript/spec/app/entities/game-commission/game-commission.service.spec.ts new file mode 100644 index 0000000..e7b5e85 --- /dev/null +++ b/src/test/javascript/spec/app/entities/game-commission/game-commission.service.spec.ts @@ -0,0 +1,102 @@ +import { TestBed, getTestBed } from '@angular/core/testing'; +import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; +import { GameCommissionService } from 'app/entities/game-commission/game-commission.service'; +import { IGameCommission, GameCommission } from 'app/shared/model/game-commission.model'; + +describe('Service Tests', () => { + describe('GameCommission Service', () => { + let injector: TestBed; + let service: GameCommissionService; + let httpMock: HttpTestingController; + let elemDefault: IGameCommission; + let expectedResult: IGameCommission | IGameCommission[] | boolean | null; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HttpClientTestingModule] + }); + expectedResult = null; + injector = getTestBed(); + service = injector.get(GameCommissionService); + httpMock = injector.get(HttpTestingController); + + elemDefault = new GameCommission(0, 0); + }); + + describe('Service methods', () => { + it('should find an element', () => { + const returnedFromService = Object.assign({}, elemDefault); + + service.find(123).subscribe(resp => (expectedResult = resp.body)); + + const req = httpMock.expectOne({ method: 'GET' }); + req.flush(returnedFromService); + expect(expectedResult).toMatchObject(elemDefault); + }); + + it('should create a GameCommission', () => { + const returnedFromService = Object.assign( + { + id: 0 + }, + elemDefault + ); + + const expected = Object.assign({}, returnedFromService); + + service.create(new GameCommission()).subscribe(resp => (expectedResult = resp.body)); + + const req = httpMock.expectOne({ method: 'POST' }); + req.flush(returnedFromService); + expect(expectedResult).toMatchObject(expected); + }); + + it('should update a GameCommission', () => { + const returnedFromService = Object.assign( + { + commission: 1 + }, + elemDefault + ); + + const expected = Object.assign({}, returnedFromService); + + service.update(expected).subscribe(resp => (expectedResult = resp.body)); + + const req = httpMock.expectOne({ method: 'PUT' }); + req.flush(returnedFromService); + expect(expectedResult).toMatchObject(expected); + }); + + it('should return a list of GameCommission', () => { + const returnedFromService = Object.assign( + { + commission: 1 + }, + elemDefault + ); + + const expected = Object.assign({}, returnedFromService); + + service.query().subscribe(resp => (expectedResult = resp.body)); + + const req = httpMock.expectOne({ method: 'GET' }); + req.flush([returnedFromService]); + httpMock.verify(); + expect(expectedResult).toContainEqual(expected); + }); + + it('should delete a GameCommission', () => { + service.delete(123).subscribe(resp => (expectedResult = resp.ok)); + + const req = httpMock.expectOne({ method: 'DELETE' }); + req.flush({ status: 200 }); + expect(expectedResult); + }); + }); + + afterEach(() => { + httpMock.verify(); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/game-user/game-user-delete-dialog.component.spec.ts b/src/test/javascript/spec/app/entities/game-user/game-user-delete-dialog.component.spec.ts new file mode 100644 index 0000000..8db17bf --- /dev/null +++ b/src/test/javascript/spec/app/entities/game-user/game-user-delete-dialog.component.spec.ts @@ -0,0 +1,65 @@ +import { ComponentFixture, TestBed, inject, fakeAsync, tick } from '@angular/core/testing'; +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; +import { of } from 'rxjs'; +import { JhiEventManager } from 'ng-jhipster'; + +import { AdminTestModule } from '../../../test.module'; +import { MockEventManager } from '../../../helpers/mock-event-manager.service'; +import { MockActiveModal } from '../../../helpers/mock-active-modal.service'; +import { GameUserDeleteDialogComponent } from 'app/entities/game-user/game-user-delete-dialog.component'; +import { GameUserService } from 'app/entities/game-user/game-user.service'; + +describe('Component Tests', () => { + describe('GameUser Management Delete Component', () => { + let comp: GameUserDeleteDialogComponent; + let fixture: ComponentFixture; + let service: GameUserService; + let mockEventManager: MockEventManager; + let mockActiveModal: MockActiveModal; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [AdminTestModule], + declarations: [GameUserDeleteDialogComponent] + }) + .overrideTemplate(GameUserDeleteDialogComponent, '') + .compileComponents(); + fixture = TestBed.createComponent(GameUserDeleteDialogComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(GameUserService); + mockEventManager = TestBed.get(JhiEventManager); + mockActiveModal = TestBed.get(NgbActiveModal); + }); + + describe('confirmDelete', () => { + it('Should call delete service on confirmDelete', inject( + [], + fakeAsync(() => { + // GIVEN + spyOn(service, 'delete').and.returnValue(of({})); + + // WHEN + comp.confirmDelete(123); + tick(); + + // THEN + expect(service.delete).toHaveBeenCalledWith(123); + expect(mockActiveModal.closeSpy).toHaveBeenCalled(); + expect(mockEventManager.broadcastSpy).toHaveBeenCalled(); + }) + )); + + it('Should not call delete service on clear', () => { + // GIVEN + spyOn(service, 'delete'); + + // WHEN + comp.cancel(); + + // THEN + expect(service.delete).not.toHaveBeenCalled(); + expect(mockActiveModal.dismissSpy).toHaveBeenCalled(); + }); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/game-user/game-user-detail.component.spec.ts b/src/test/javascript/spec/app/entities/game-user/game-user-detail.component.spec.ts new file mode 100644 index 0000000..c3e3878 --- /dev/null +++ b/src/test/javascript/spec/app/entities/game-user/game-user-detail.component.spec.ts @@ -0,0 +1,37 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { ActivatedRoute } from '@angular/router'; +import { of } from 'rxjs'; + +import { AdminTestModule } from '../../../test.module'; +import { GameUserDetailComponent } from 'app/entities/game-user/game-user-detail.component'; +import { GameUser } from 'app/shared/model/game-user.model'; + +describe('Component Tests', () => { + describe('GameUser Management Detail Component', () => { + let comp: GameUserDetailComponent; + let fixture: ComponentFixture; + const route = ({ data: of({ gameUser: new GameUser(123) }) } as any) as ActivatedRoute; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [AdminTestModule], + declarations: [GameUserDetailComponent], + providers: [{ provide: ActivatedRoute, useValue: route }] + }) + .overrideTemplate(GameUserDetailComponent, '') + .compileComponents(); + fixture = TestBed.createComponent(GameUserDetailComponent); + comp = fixture.componentInstance; + }); + + describe('OnInit', () => { + it('Should load gameUser on init', () => { + // WHEN + comp.ngOnInit(); + + // THEN + expect(comp.gameUser).toEqual(jasmine.objectContaining({ id: 123 })); + }); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/game-user/game-user-update.component.spec.ts b/src/test/javascript/spec/app/entities/game-user/game-user-update.component.spec.ts new file mode 100644 index 0000000..0937c2b --- /dev/null +++ b/src/test/javascript/spec/app/entities/game-user/game-user-update.component.spec.ts @@ -0,0 +1,61 @@ +import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing'; +import { HttpResponse } from '@angular/common/http'; +import { FormBuilder } from '@angular/forms'; +import { of } from 'rxjs'; + +import { AdminTestModule } from '../../../test.module'; +import { GameUserUpdateComponent } from 'app/entities/game-user/game-user-update.component'; +import { GameUserService } from 'app/entities/game-user/game-user.service'; +import { GameUser } from 'app/shared/model/game-user.model'; + +describe('Component Tests', () => { + describe('GameUser Management Update Component', () => { + let comp: GameUserUpdateComponent; + let fixture: ComponentFixture; + let service: GameUserService; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [AdminTestModule], + declarations: [GameUserUpdateComponent], + providers: [FormBuilder] + }) + .overrideTemplate(GameUserUpdateComponent, '') + .compileComponents(); + + fixture = TestBed.createComponent(GameUserUpdateComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(GameUserService); + }); + + describe('save', () => { + it('Should call update service on save for existing entity', fakeAsync(() => { + // GIVEN + const entity = new GameUser(123); + spyOn(service, 'update').and.returnValue(of(new HttpResponse({ body: entity }))); + comp.updateForm(entity); + // WHEN + comp.save(); + tick(); // simulate async + + // THEN + expect(service.update).toHaveBeenCalledWith(entity); + expect(comp.isSaving).toEqual(false); + })); + + it('Should call create service on save for new entity', fakeAsync(() => { + // GIVEN + const entity = new GameUser(); + spyOn(service, 'create').and.returnValue(of(new HttpResponse({ body: entity }))); + comp.updateForm(entity); + // WHEN + comp.save(); + tick(); // simulate async + + // THEN + expect(service.create).toHaveBeenCalledWith(entity); + expect(comp.isSaving).toEqual(false); + })); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/game-user/game-user.component.spec.ts b/src/test/javascript/spec/app/entities/game-user/game-user.component.spec.ts new file mode 100644 index 0000000..a0823e2 --- /dev/null +++ b/src/test/javascript/spec/app/entities/game-user/game-user.component.spec.ts @@ -0,0 +1,49 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { of } from 'rxjs'; +import { HttpHeaders, HttpResponse } from '@angular/common/http'; + +import { AdminTestModule } from '../../../test.module'; +import { GameUserComponent } from 'app/entities/game-user/game-user.component'; +import { GameUserService } from 'app/entities/game-user/game-user.service'; +import { GameUser } from 'app/shared/model/game-user.model'; + +describe('Component Tests', () => { + describe('GameUser Management Component', () => { + let comp: GameUserComponent; + let fixture: ComponentFixture; + let service: GameUserService; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [AdminTestModule], + declarations: [GameUserComponent] + }) + .overrideTemplate(GameUserComponent, '') + .compileComponents(); + + fixture = TestBed.createComponent(GameUserComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(GameUserService); + }); + + it('Should call load all on init', () => { + // GIVEN + const headers = new HttpHeaders().append('link', 'link;link'); + spyOn(service, 'query').and.returnValue( + of( + new HttpResponse({ + body: [new GameUser(123)], + headers + }) + ) + ); + + // WHEN + comp.ngOnInit(); + + // THEN + expect(service.query).toHaveBeenCalled(); + expect(comp.gameUsers && comp.gameUsers[0]).toEqual(jasmine.objectContaining({ id: 123 })); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/game-user/game-user.service.spec.ts b/src/test/javascript/spec/app/entities/game-user/game-user.service.spec.ts new file mode 100644 index 0000000..cfd0bd8 --- /dev/null +++ b/src/test/javascript/spec/app/entities/game-user/game-user.service.spec.ts @@ -0,0 +1,104 @@ +import { TestBed, getTestBed } from '@angular/core/testing'; +import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; +import { GameUserService } from 'app/entities/game-user/game-user.service'; +import { IGameUser, GameUser } from 'app/shared/model/game-user.model'; + +describe('Service Tests', () => { + describe('GameUser Service', () => { + let injector: TestBed; + let service: GameUserService; + let httpMock: HttpTestingController; + let elemDefault: IGameUser; + let expectedResult: IGameUser | IGameUser[] | boolean | null; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HttpClientTestingModule] + }); + expectedResult = null; + injector = getTestBed(); + service = injector.get(GameUserService); + httpMock = injector.get(HttpTestingController); + + elemDefault = new GameUser(0, 'AAAAAAA', 'AAAAAAA'); + }); + + describe('Service methods', () => { + it('should find an element', () => { + const returnedFromService = Object.assign({}, elemDefault); + + service.find(123).subscribe(resp => (expectedResult = resp.body)); + + const req = httpMock.expectOne({ method: 'GET' }); + req.flush(returnedFromService); + expect(expectedResult).toMatchObject(elemDefault); + }); + + it('should create a GameUser', () => { + const returnedFromService = Object.assign( + { + id: 0 + }, + elemDefault + ); + + const expected = Object.assign({}, returnedFromService); + + service.create(new GameUser()).subscribe(resp => (expectedResult = resp.body)); + + const req = httpMock.expectOne({ method: 'POST' }); + req.flush(returnedFromService); + expect(expectedResult).toMatchObject(expected); + }); + + it('should update a GameUser', () => { + const returnedFromService = Object.assign( + { + username: 'BBBBBB', + password: 'BBBBBB' + }, + elemDefault + ); + + const expected = Object.assign({}, returnedFromService); + + service.update(expected).subscribe(resp => (expectedResult = resp.body)); + + const req = httpMock.expectOne({ method: 'PUT' }); + req.flush(returnedFromService); + expect(expectedResult).toMatchObject(expected); + }); + + it('should return a list of GameUser', () => { + const returnedFromService = Object.assign( + { + username: 'BBBBBB', + password: 'BBBBBB' + }, + elemDefault + ); + + const expected = Object.assign({}, returnedFromService); + + service.query().subscribe(resp => (expectedResult = resp.body)); + + const req = httpMock.expectOne({ method: 'GET' }); + req.flush([returnedFromService]); + httpMock.verify(); + expect(expectedResult).toContainEqual(expected); + }); + + it('should delete a GameUser', () => { + service.delete(123).subscribe(resp => (expectedResult = resp.ok)); + + const req = httpMock.expectOne({ method: 'DELETE' }); + req.flush({ status: 200 }); + expect(expectedResult); + }); + }); + + afterEach(() => { + httpMock.verify(); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/game/game-delete-dialog.component.spec.ts b/src/test/javascript/spec/app/entities/game/game-delete-dialog.component.spec.ts new file mode 100644 index 0000000..d847d07 --- /dev/null +++ b/src/test/javascript/spec/app/entities/game/game-delete-dialog.component.spec.ts @@ -0,0 +1,65 @@ +import { ComponentFixture, TestBed, inject, fakeAsync, tick } from '@angular/core/testing'; +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; +import { of } from 'rxjs'; +import { JhiEventManager } from 'ng-jhipster'; + +import { AdminTestModule } from '../../../test.module'; +import { MockEventManager } from '../../../helpers/mock-event-manager.service'; +import { MockActiveModal } from '../../../helpers/mock-active-modal.service'; +import { GameDeleteDialogComponent } from 'app/entities/game/game-delete-dialog.component'; +import { GameService } from 'app/entities/game/game.service'; + +describe('Component Tests', () => { + describe('Game Management Delete Component', () => { + let comp: GameDeleteDialogComponent; + let fixture: ComponentFixture; + let service: GameService; + let mockEventManager: MockEventManager; + let mockActiveModal: MockActiveModal; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [AdminTestModule], + declarations: [GameDeleteDialogComponent] + }) + .overrideTemplate(GameDeleteDialogComponent, '') + .compileComponents(); + fixture = TestBed.createComponent(GameDeleteDialogComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(GameService); + mockEventManager = TestBed.get(JhiEventManager); + mockActiveModal = TestBed.get(NgbActiveModal); + }); + + describe('confirmDelete', () => { + it('Should call delete service on confirmDelete', inject( + [], + fakeAsync(() => { + // GIVEN + spyOn(service, 'delete').and.returnValue(of({})); + + // WHEN + comp.confirmDelete(123); + tick(); + + // THEN + expect(service.delete).toHaveBeenCalledWith(123); + expect(mockActiveModal.closeSpy).toHaveBeenCalled(); + expect(mockEventManager.broadcastSpy).toHaveBeenCalled(); + }) + )); + + it('Should not call delete service on clear', () => { + // GIVEN + spyOn(service, 'delete'); + + // WHEN + comp.cancel(); + + // THEN + expect(service.delete).not.toHaveBeenCalled(); + expect(mockActiveModal.dismissSpy).toHaveBeenCalled(); + }); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/game/game-detail.component.spec.ts b/src/test/javascript/spec/app/entities/game/game-detail.component.spec.ts new file mode 100644 index 0000000..f32cdd9 --- /dev/null +++ b/src/test/javascript/spec/app/entities/game/game-detail.component.spec.ts @@ -0,0 +1,37 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { ActivatedRoute } from '@angular/router'; +import { of } from 'rxjs'; + +import { AdminTestModule } from '../../../test.module'; +import { GameDetailComponent } from 'app/entities/game/game-detail.component'; +import { Game } from 'app/shared/model/game.model'; + +describe('Component Tests', () => { + describe('Game Management Detail Component', () => { + let comp: GameDetailComponent; + let fixture: ComponentFixture; + const route = ({ data: of({ game: new Game(123) }) } as any) as ActivatedRoute; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [AdminTestModule], + declarations: [GameDetailComponent], + providers: [{ provide: ActivatedRoute, useValue: route }] + }) + .overrideTemplate(GameDetailComponent, '') + .compileComponents(); + fixture = TestBed.createComponent(GameDetailComponent); + comp = fixture.componentInstance; + }); + + describe('OnInit', () => { + it('Should load game on init', () => { + // WHEN + comp.ngOnInit(); + + // THEN + expect(comp.game).toEqual(jasmine.objectContaining({ id: 123 })); + }); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/game/game-update.component.spec.ts b/src/test/javascript/spec/app/entities/game/game-update.component.spec.ts new file mode 100644 index 0000000..790d93a --- /dev/null +++ b/src/test/javascript/spec/app/entities/game/game-update.component.spec.ts @@ -0,0 +1,61 @@ +import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing'; +import { HttpResponse } from '@angular/common/http'; +import { FormBuilder } from '@angular/forms'; +import { of } from 'rxjs'; + +import { AdminTestModule } from '../../../test.module'; +import { GameUpdateComponent } from 'app/entities/game/game-update.component'; +import { GameService } from 'app/entities/game/game.service'; +import { Game } from 'app/shared/model/game.model'; + +describe('Component Tests', () => { + describe('Game Management Update Component', () => { + let comp: GameUpdateComponent; + let fixture: ComponentFixture; + let service: GameService; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [AdminTestModule], + declarations: [GameUpdateComponent], + providers: [FormBuilder] + }) + .overrideTemplate(GameUpdateComponent, '') + .compileComponents(); + + fixture = TestBed.createComponent(GameUpdateComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(GameService); + }); + + describe('save', () => { + it('Should call update service on save for existing entity', fakeAsync(() => { + // GIVEN + const entity = new Game(123); + spyOn(service, 'update').and.returnValue(of(new HttpResponse({ body: entity }))); + comp.updateForm(entity); + // WHEN + comp.save(); + tick(); // simulate async + + // THEN + expect(service.update).toHaveBeenCalledWith(entity); + expect(comp.isSaving).toEqual(false); + })); + + it('Should call create service on save for new entity', fakeAsync(() => { + // GIVEN + const entity = new Game(); + spyOn(service, 'create').and.returnValue(of(new HttpResponse({ body: entity }))); + comp.updateForm(entity); + // WHEN + comp.save(); + tick(); // simulate async + + // THEN + expect(service.create).toHaveBeenCalledWith(entity); + expect(comp.isSaving).toEqual(false); + })); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/game/game.component.spec.ts b/src/test/javascript/spec/app/entities/game/game.component.spec.ts new file mode 100644 index 0000000..bfa6dca --- /dev/null +++ b/src/test/javascript/spec/app/entities/game/game.component.spec.ts @@ -0,0 +1,49 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { of } from 'rxjs'; +import { HttpHeaders, HttpResponse } from '@angular/common/http'; + +import { AdminTestModule } from '../../../test.module'; +import { GameComponent } from 'app/entities/game/game.component'; +import { GameService } from 'app/entities/game/game.service'; +import { Game } from 'app/shared/model/game.model'; + +describe('Component Tests', () => { + describe('Game Management Component', () => { + let comp: GameComponent; + let fixture: ComponentFixture; + let service: GameService; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [AdminTestModule], + declarations: [GameComponent] + }) + .overrideTemplate(GameComponent, '') + .compileComponents(); + + fixture = TestBed.createComponent(GameComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(GameService); + }); + + it('Should call load all on init', () => { + // GIVEN + const headers = new HttpHeaders().append('link', 'link;link'); + spyOn(service, 'query').and.returnValue( + of( + new HttpResponse({ + body: [new Game(123)], + headers + }) + ) + ); + + // WHEN + comp.ngOnInit(); + + // THEN + expect(service.query).toHaveBeenCalled(); + expect(comp.games && comp.games[0]).toEqual(jasmine.objectContaining({ id: 123 })); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/game/game.service.spec.ts b/src/test/javascript/spec/app/entities/game/game.service.spec.ts new file mode 100644 index 0000000..8210173 --- /dev/null +++ b/src/test/javascript/spec/app/entities/game/game.service.spec.ts @@ -0,0 +1,102 @@ +import { TestBed, getTestBed } from '@angular/core/testing'; +import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; +import { GameService } from 'app/entities/game/game.service'; +import { IGame, Game } from 'app/shared/model/game.model'; + +describe('Service Tests', () => { + describe('Game Service', () => { + let injector: TestBed; + let service: GameService; + let httpMock: HttpTestingController; + let elemDefault: IGame; + let expectedResult: IGame | IGame[] | boolean | null; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HttpClientTestingModule] + }); + expectedResult = null; + injector = getTestBed(); + service = injector.get(GameService); + httpMock = injector.get(HttpTestingController); + + elemDefault = new Game(0, 'AAAAAAA'); + }); + + describe('Service methods', () => { + it('should find an element', () => { + const returnedFromService = Object.assign({}, elemDefault); + + service.find(123).subscribe(resp => (expectedResult = resp.body)); + + const req = httpMock.expectOne({ method: 'GET' }); + req.flush(returnedFromService); + expect(expectedResult).toMatchObject(elemDefault); + }); + + it('should create a Game', () => { + const returnedFromService = Object.assign( + { + id: 0 + }, + elemDefault + ); + + const expected = Object.assign({}, returnedFromService); + + service.create(new Game()).subscribe(resp => (expectedResult = resp.body)); + + const req = httpMock.expectOne({ method: 'POST' }); + req.flush(returnedFromService); + expect(expectedResult).toMatchObject(expected); + }); + + it('should update a Game', () => { + const returnedFromService = Object.assign( + { + name: 'BBBBBB' + }, + elemDefault + ); + + const expected = Object.assign({}, returnedFromService); + + service.update(expected).subscribe(resp => (expectedResult = resp.body)); + + const req = httpMock.expectOne({ method: 'PUT' }); + req.flush(returnedFromService); + expect(expectedResult).toMatchObject(expected); + }); + + it('should return a list of Game', () => { + const returnedFromService = Object.assign( + { + name: 'BBBBBB' + }, + elemDefault + ); + + const expected = Object.assign({}, returnedFromService); + + service.query().subscribe(resp => (expectedResult = resp.body)); + + const req = httpMock.expectOne({ method: 'GET' }); + req.flush([returnedFromService]); + httpMock.verify(); + expect(expectedResult).toContainEqual(expected); + }); + + it('should delete a Game', () => { + service.delete(123).subscribe(resp => (expectedResult = resp.ok)); + + const req = httpMock.expectOne({ method: 'DELETE' }); + req.flush({ status: 200 }); + expect(expectedResult); + }); + }); + + afterEach(() => { + httpMock.verify(); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/hand/hand-delete-dialog.component.spec.ts b/src/test/javascript/spec/app/entities/hand/hand-delete-dialog.component.spec.ts new file mode 100644 index 0000000..fa3dbd6 --- /dev/null +++ b/src/test/javascript/spec/app/entities/hand/hand-delete-dialog.component.spec.ts @@ -0,0 +1,65 @@ +import { ComponentFixture, TestBed, inject, fakeAsync, tick } from '@angular/core/testing'; +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; +import { of } from 'rxjs'; +import { JhiEventManager } from 'ng-jhipster'; + +import { AdminTestModule } from '../../../test.module'; +import { MockEventManager } from '../../../helpers/mock-event-manager.service'; +import { MockActiveModal } from '../../../helpers/mock-active-modal.service'; +import { HandDeleteDialogComponent } from 'app/entities/hand/hand-delete-dialog.component'; +import { HandService } from 'app/entities/hand/hand.service'; + +describe('Component Tests', () => { + describe('Hand Management Delete Component', () => { + let comp: HandDeleteDialogComponent; + let fixture: ComponentFixture; + let service: HandService; + let mockEventManager: MockEventManager; + let mockActiveModal: MockActiveModal; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [AdminTestModule], + declarations: [HandDeleteDialogComponent] + }) + .overrideTemplate(HandDeleteDialogComponent, '') + .compileComponents(); + fixture = TestBed.createComponent(HandDeleteDialogComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(HandService); + mockEventManager = TestBed.get(JhiEventManager); + mockActiveModal = TestBed.get(NgbActiveModal); + }); + + describe('confirmDelete', () => { + it('Should call delete service on confirmDelete', inject( + [], + fakeAsync(() => { + // GIVEN + spyOn(service, 'delete').and.returnValue(of({})); + + // WHEN + comp.confirmDelete(123); + tick(); + + // THEN + expect(service.delete).toHaveBeenCalledWith(123); + expect(mockActiveModal.closeSpy).toHaveBeenCalled(); + expect(mockEventManager.broadcastSpy).toHaveBeenCalled(); + }) + )); + + it('Should not call delete service on clear', () => { + // GIVEN + spyOn(service, 'delete'); + + // WHEN + comp.cancel(); + + // THEN + expect(service.delete).not.toHaveBeenCalled(); + expect(mockActiveModal.dismissSpy).toHaveBeenCalled(); + }); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/hand/hand-detail.component.spec.ts b/src/test/javascript/spec/app/entities/hand/hand-detail.component.spec.ts new file mode 100644 index 0000000..8f2f493 --- /dev/null +++ b/src/test/javascript/spec/app/entities/hand/hand-detail.component.spec.ts @@ -0,0 +1,37 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { ActivatedRoute } from '@angular/router'; +import { of } from 'rxjs'; + +import { AdminTestModule } from '../../../test.module'; +import { HandDetailComponent } from 'app/entities/hand/hand-detail.component'; +import { Hand } from 'app/shared/model/hand.model'; + +describe('Component Tests', () => { + describe('Hand Management Detail Component', () => { + let comp: HandDetailComponent; + let fixture: ComponentFixture; + const route = ({ data: of({ hand: new Hand(123) }) } as any) as ActivatedRoute; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [AdminTestModule], + declarations: [HandDetailComponent], + providers: [{ provide: ActivatedRoute, useValue: route }] + }) + .overrideTemplate(HandDetailComponent, '') + .compileComponents(); + fixture = TestBed.createComponent(HandDetailComponent); + comp = fixture.componentInstance; + }); + + describe('OnInit', () => { + it('Should load hand on init', () => { + // WHEN + comp.ngOnInit(); + + // THEN + expect(comp.hand).toEqual(jasmine.objectContaining({ id: 123 })); + }); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/hand/hand-update.component.spec.ts b/src/test/javascript/spec/app/entities/hand/hand-update.component.spec.ts new file mode 100644 index 0000000..042a295 --- /dev/null +++ b/src/test/javascript/spec/app/entities/hand/hand-update.component.spec.ts @@ -0,0 +1,61 @@ +import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing'; +import { HttpResponse } from '@angular/common/http'; +import { FormBuilder } from '@angular/forms'; +import { of } from 'rxjs'; + +import { AdminTestModule } from '../../../test.module'; +import { HandUpdateComponent } from 'app/entities/hand/hand-update.component'; +import { HandService } from 'app/entities/hand/hand.service'; +import { Hand } from 'app/shared/model/hand.model'; + +describe('Component Tests', () => { + describe('Hand Management Update Component', () => { + let comp: HandUpdateComponent; + let fixture: ComponentFixture; + let service: HandService; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [AdminTestModule], + declarations: [HandUpdateComponent], + providers: [FormBuilder] + }) + .overrideTemplate(HandUpdateComponent, '') + .compileComponents(); + + fixture = TestBed.createComponent(HandUpdateComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(HandService); + }); + + describe('save', () => { + it('Should call update service on save for existing entity', fakeAsync(() => { + // GIVEN + const entity = new Hand(123); + spyOn(service, 'update').and.returnValue(of(new HttpResponse({ body: entity }))); + comp.updateForm(entity); + // WHEN + comp.save(); + tick(); // simulate async + + // THEN + expect(service.update).toHaveBeenCalledWith(entity); + expect(comp.isSaving).toEqual(false); + })); + + it('Should call create service on save for new entity', fakeAsync(() => { + // GIVEN + const entity = new Hand(); + spyOn(service, 'create').and.returnValue(of(new HttpResponse({ body: entity }))); + comp.updateForm(entity); + // WHEN + comp.save(); + tick(); // simulate async + + // THEN + expect(service.create).toHaveBeenCalledWith(entity); + expect(comp.isSaving).toEqual(false); + })); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/hand/hand.component.spec.ts b/src/test/javascript/spec/app/entities/hand/hand.component.spec.ts new file mode 100644 index 0000000..4ef9bcf --- /dev/null +++ b/src/test/javascript/spec/app/entities/hand/hand.component.spec.ts @@ -0,0 +1,49 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { of } from 'rxjs'; +import { HttpHeaders, HttpResponse } from '@angular/common/http'; + +import { AdminTestModule } from '../../../test.module'; +import { HandComponent } from 'app/entities/hand/hand.component'; +import { HandService } from 'app/entities/hand/hand.service'; +import { Hand } from 'app/shared/model/hand.model'; + +describe('Component Tests', () => { + describe('Hand Management Component', () => { + let comp: HandComponent; + let fixture: ComponentFixture; + let service: HandService; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [AdminTestModule], + declarations: [HandComponent] + }) + .overrideTemplate(HandComponent, '') + .compileComponents(); + + fixture = TestBed.createComponent(HandComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(HandService); + }); + + it('Should call load all on init', () => { + // GIVEN + const headers = new HttpHeaders().append('link', 'link;link'); + spyOn(service, 'query').and.returnValue( + of( + new HttpResponse({ + body: [new Hand(123)], + headers + }) + ) + ); + + // WHEN + comp.ngOnInit(); + + // THEN + expect(service.query).toHaveBeenCalled(); + expect(comp.hands && comp.hands[0]).toEqual(jasmine.objectContaining({ id: 123 })); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/hand/hand.service.spec.ts b/src/test/javascript/spec/app/entities/hand/hand.service.spec.ts new file mode 100644 index 0000000..24a39ff --- /dev/null +++ b/src/test/javascript/spec/app/entities/hand/hand.service.spec.ts @@ -0,0 +1,103 @@ +import { TestBed, getTestBed } from '@angular/core/testing'; +import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; +import { HandService } from 'app/entities/hand/hand.service'; +import { IHand, Hand } from 'app/shared/model/hand.model'; +import { HandStatus } from 'app/shared/model/enumerations/hand-status.model'; + +describe('Service Tests', () => { + describe('Hand Service', () => { + let injector: TestBed; + let service: HandService; + let httpMock: HttpTestingController; + let elemDefault: IHand; + let expectedResult: IHand | IHand[] | boolean | null; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HttpClientTestingModule] + }); + expectedResult = null; + injector = getTestBed(); + service = injector.get(HandService); + httpMock = injector.get(HttpTestingController); + + elemDefault = new Hand(0, HandStatus.Begin); + }); + + describe('Service methods', () => { + it('should find an element', () => { + const returnedFromService = Object.assign({}, elemDefault); + + service.find(123).subscribe(resp => (expectedResult = resp.body)); + + const req = httpMock.expectOne({ method: 'GET' }); + req.flush(returnedFromService); + expect(expectedResult).toMatchObject(elemDefault); + }); + + it('should create a Hand', () => { + const returnedFromService = Object.assign( + { + id: 0 + }, + elemDefault + ); + + const expected = Object.assign({}, returnedFromService); + + service.create(new Hand()).subscribe(resp => (expectedResult = resp.body)); + + const req = httpMock.expectOne({ method: 'POST' }); + req.flush(returnedFromService); + expect(expectedResult).toMatchObject(expected); + }); + + it('should update a Hand', () => { + const returnedFromService = Object.assign( + { + status: 'BBBBBB' + }, + elemDefault + ); + + const expected = Object.assign({}, returnedFromService); + + service.update(expected).subscribe(resp => (expectedResult = resp.body)); + + const req = httpMock.expectOne({ method: 'PUT' }); + req.flush(returnedFromService); + expect(expectedResult).toMatchObject(expected); + }); + + it('should return a list of Hand', () => { + const returnedFromService = Object.assign( + { + status: 'BBBBBB' + }, + elemDefault + ); + + const expected = Object.assign({}, returnedFromService); + + service.query().subscribe(resp => (expectedResult = resp.body)); + + const req = httpMock.expectOne({ method: 'GET' }); + req.flush([returnedFromService]); + httpMock.verify(); + expect(expectedResult).toContainEqual(expected); + }); + + it('should delete a Hand', () => { + service.delete(123).subscribe(resp => (expectedResult = resp.ok)); + + const req = httpMock.expectOne({ method: 'DELETE' }); + req.flush({ status: 200 }); + expect(expectedResult); + }); + }); + + afterEach(() => { + httpMock.verify(); + }); + }); +});