Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fight microservice website information is outdated #362

Closed
galderz opened this issue Sep 18, 2023 · 0 comments
Closed

Fight microservice website information is outdated #362

galderz opened this issue Sep 18, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@galderz
Copy link
Member

galderz commented Sep 18, 2023

Fight microservice website is outdated, e.g. here.

diff --git a/super-heroes/fights/FightResourceTest.java b/super-heroes/fights/FightResourceTest.java
index 9ed454b..8228b1f 100644
--- a/super-heroes/fights/FightResourceTest.java
+++ b/super-heroes/fights/FightResourceTest.java
@@ -99,10 +99,12 @@ public class FightResourceTest {
         hero.name = DEFAULT_WINNER_NAME;
         hero.picture = DEFAULT_WINNER_PICTURE;
         hero.level = DEFAULT_WINNER_LEVEL;
+        hero.powers = DEFAULT_WINNER_POWERS;
         Villain villain = new Villain();
         villain.name = DEFAULT_LOSER_NAME;
         villain.picture = DEFAULT_LOSER_PICTURE;
         villain.level = DEFAULT_LOSER_LEVEL;
+        villain.powers = DEFAULT_LOSER_POWERS;
         Fighters fighters = new Fighters();
         fighters.hero = hero;
         fighters.villain = villain;
@@ -115,28 +117,36 @@ public class FightResourceTest {
             .post("/api/fights")
             .then()
             .statusCode(OK.getStatusCode())
-            .body(containsString("winner"), containsString("loser"))
-            .extract().body().jsonPath().getString("id");
+            .body(containsString("winner"),
+                containsString("loser"))
+            .extract()
+            .body()
+            .jsonPath()
+            .getString("id");

         assertNotNull(fightId);

-        given()
-            .pathParam("id", fightId)
-            .when().get("/api/fights/{id}")
+        given().pathParam("id", fightId)
+            .when()
+            .get("/api/fights/{id}")
             .then()
             .statusCode(OK.getStatusCode())
             .contentType(APPLICATION_JSON)
             .body("winnerName", Is.is(DEFAULT_WINNER_NAME))
             .body("winnerPicture", Is.is(DEFAULT_WINNER_PICTURE))
             .body("winnerLevel", Is.is(DEFAULT_WINNER_LEVEL))
+            .body("winnerPowers", Is.is(DEFAULT_WINNER_POWERS))
             .body("loserName", Is.is(DEFAULT_LOSER_NAME))
             .body("loserPicture", Is.is(DEFAULT_LOSER_PICTURE))
             .body("loserLevel", Is.is(DEFAULT_LOSER_LEVEL))
+            .body("loserPowers", Is.is(DEFAULT_LOSER_POWERS))
             .body("fightDate", Is.is(notNullValue()));

         List<Fight> fights = get("/api/fights").then()
             .statusCode(OK.getStatusCode())
-            .extract().body().as(getFightTypeRef());
+            .extract()
+            .body()
+            .as(getFightTypeRef());
         assertEquals(NB_FIGHTS + 1, fights.size());
     }

And for import.sql:

diff --git a/super-heroes/fights/import.sql b/super-heroes/fights/import.sql
index a9187f4..0b97d45 100644
--- a/super-heroes/fights/import.sql
+++ b/super-heroes/fights/import.sql
@@ -1,17 +1,17 @@
 ALTER SEQUENCE fight_seq RESTART WITH 50;

-INSERT INTO fight(id, fightDate, winnerName, winnerLevel, winnerPicture, loserName, loserLevel, loserPicture,
-                  winnerTeam, loserTeam)
-VALUES (nextval('fight_seq'), current_timestamp, 'Chewbacca', 5,
-        'https://www.superherodb.com/pictures2/portraits/10/050/10466.jpg', 'Buuccolo', 3,
-        'https://www.superherodb.com/pictures2/portraits/10/050/15355.jpg', 'heroes', 'villains');
-INSERT INTO fight(id, fightDate, winnerName, winnerLevel, winnerPicture, loserName, loserLevel, loserPicture,
-                  winnerTeam, loserTeam)
-VALUES (nextval('fight_seq'), current_timestamp, 'Galadriel', 10,
-        'https://www.superherodb.com/pictures2/portraits/10/050/11796.jpg', 'Darth Vader', 8,
-        'https://www.superherodb.com/pictures2/portraits/10/050/10444.jpg', 'heroes', 'villains');
-INSERT INTO fight(id, fightDate, winnerName, winnerLevel, winnerPicture, loserName, loserLevel, loserPicture,
-                  winnerTeam, loserTeam)
-VALUES (nextval('fight_seq'), current_timestamp, 'Annihilus', 23,
-        'https://www.superherodb.com/pictures2/portraits/10/050/1307.jpg', 'Shikamaru', 1,
-        'https://www.superherodb.com/pictures2/portraits/10/050/11742.jpg', 'villains', 'heroes');
+INSERT INTO fight(id, fightDate, winnerName, winnerLevel, winnerPicture, winnerPowers, loserName, loserLevel, loserPicture, loserPowers, winnerTeam, loserTeam)
+VALUES (nextval('fight_seq'), current_timestamp,
+        'Chewbacca', 5, 'https://www.superherodb.com/pictures2/portraits/10/050/10466.jpg', 'Agility, Longevity, Marksmanship, Natural Weapons, Stealth, Super Strength, Weapons Master',
+        'Buuccolo', 3, 'https://www.superherodb.com/pictures2/portraits/10/050/15355.jpg', 'Accelerated Healing, Adaptation, Agility, Flight, Immortality, Intelligence, Invulnerability, Reflexes, Self-Sustenance, Size Changing, Spatial Awareness, Stamina, Stealth, Super Breath, Super Speed, Super Strength, Telepo>
+        'heroes', 'villains');
+INSERT INTO fight(id, fightDate, winnerName, winnerLevel, winnerPicture, winnerPowers, loserName, loserLevel, loserPicture, loserPowers, winnerTeam, loserTeam)
+VALUES (nextval('fight_seq'), current_timestamp,
+        'Galadriel', 10, 'https://www.superherodb.com/pictures2/portraits/10/050/11796.jpg', 'Danger Sense, Immortality, Intelligence, Invisibility, Magic, Precognition, Telekinesis, Telepathy',
+        'Darth Vader', 8, 'https://www.superherodb.com/pictures2/portraits/10/050/10444.jpg', 'Accelerated Healing, Agility, Astral Projection, Cloaking, Danger Sense, Durability, Electrokinesis, Energy Blasts, Enhanced Hearing, Enhanced Senses, Force Fields, Hypnokinesis, Illusions, Intelligence, Jump, Light Con>
+        'heroes', 'villains');
+INSERT INTO fight(id, fightDate, winnerName, winnerLevel, winnerPicture, winnerPowers, loserName, loserLevel, loserPicture, loserPowers, winnerTeam, loserTeam)
+VALUES (nextval('fight_seq'), current_timestamp,
+        'Annihilus', 23, 'https://www.superherodb.com/pictures2/portraits/10/050/1307.jpg', 'Agility, Durability, Flight, Reflexes, Stamina, Super Speed, Super Strength',
+        'Shikamaru', 1, 'https://www.superherodb.com/pictures2/portraits/10/050/11742.jpg', 'Adaptation, Agility, Element Control, Fire Control, Intelligence, Jump, Marksmanship, Possession, Reflexes, Shapeshifting, Stamina, Stealth, Telekinesis, Wallcrawling, Weapon-based Powers, Weapons Master',
+        'villains', 'heroes');

This leads to test errors like:

List of constraint violations:[
	ConstraintViolationImpl{interpolatedMessage='must not be null', propertyPath=loserPowers, rootBeanClass=class io.quarkus.workshop.superheroes.fight.Fight, messageTemplate='{jakarta.validation.constraints.NotNull.message}'}
	ConstraintViolationImpl{interpolatedMessage='must not be null', propertyPath=winnerPowers, rootBeanClass=class io.quarkus.workshop.superheroes.fight.Fight, messageTemplate='{jakarta.validation.constraints.NotNull.message}'}
]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant