Skip to content

Commit

Permalink
1.4.0 (#25)
Browse files Browse the repository at this point in the history
* starting new development iteration

* working on upload functionality

* Jdk8 build not necessary

* Working on the edit article feature (work in progress).

* Being able to modify achievements. Reuse one main objectmapper. Removed some unnecessary code.

* Expanding JsonFactory to support serialisation of books as well. Other types are work in progress.

* Support serialisation of buildings.

* Support serialisation of corpses.

* Attempt to add integration tests..

* Working on creatures.

* Fixing remaining objects with constructors and builders. Adding Missile.

* Working on unit tests for jsonfactory, small fixes in wikiobject classes.

* Working further on unit tests for jsonfactory, with small fixes in other classes.

* Reworking dependency injection in constructors instead of fields. Adding Missiles resource.

* Adding PUT methods to all resources.

* Fix in resource paths.

* Fixing constructing of json for locations and streets which don't have list and getvalue params anymore. Fix datatype of position parameters of npcs.

* Also support hunting place modifications.

* Removing CORS headers and adding one global filter.
  • Loading branch information
benjaminkomen authored Dec 8, 2018
1 parent 122a8e8 commit 907cac1
Show file tree
Hide file tree
Showing 83 changed files with 4,624 additions and 1,104 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
language: java

jdk:
- openjdk8
- openjdk11


Expand Down
94 changes: 51 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ environment such as Git Bash. Now you can start the application by typing the fo
Alternatively and maybe easier, you can also execute: `mvn spring-boot:run` in your command line.

You can now access the REST resources using your browser or any REST client such as Postman or curl from your command line.
E.g. navigating to http://localhost:8080/corpses should give you a list of corpses.
E.g. navigating to http://localhost:8080/api/corpses should give you a list of corpses.

## API documentation
Navigate to http://localhost:8080/ for automatically generated api documentation provided by Swagger.
Expand All @@ -26,135 +26,143 @@ For all resources the query parameter ?expand=true can be appended to get a full
## Achievements

A list of all achievements:
http://localhost:8080/achievements
http://localhost:8080/api/achievements

An achievement by achievement name, e.g. "Goo Goo Dancer":
http://localhost:8080/achievements/Goo_Goo_Dancer
http://localhost:8080/api/achievements/Goo_Goo_Dancer

## Books

A list of all books:
http://localhost:8080/books
http://localhost:8080/api/books

A book by book name, e.g. "Dungeon Survival Guide (Book)":
http://localhost:8080/books/Dungeon_Survival_Guide_%28Book%29
http://localhost:8080/api/books/Dungeon_Survival_Guide_%28Book%29

## Buildings

A list of all buildings:
http://localhost:8080/buildings
http://localhost:8080/api/buildings

A building by building name, e.g. "Theater Avenue 8b":
http://localhost:8080/buildings/Theater_Avenue_8b
http://localhost:8080/api/buildings/Theater_Avenue_8b

## Corpses

A list of all corpses:
http://localhost:8080/corpses
http://localhost:8080/api/corpses

A corpse by corpse name, e.g. "Dead Rat":
http://localhost:8080/corpses/Dead_Rat
http://localhost:8080/api/corpses/Dead_Rat

## Creatures

A list of all creatures:
http://localhost:8080/creatures
http://localhost:8080/api/creatures

A creature by creature name, e.g. "Dragon":
http://localhost:8080/creatures/Dragon
http://localhost:8080/api/creatures/Dragon

## Effects

A list of all effects:
http://localhost:8080/effects
http://localhost:8080/api/effects

An effect by effect name, e.g. "Throwing Cake Effect":
http://localhost:8080/effects/Throwing_Cake_Effect
An effect by effect name, e.g. "Blue Electricity Effect":
http://localhost:8080/api/effects/Blue_Electricity_Effect

## Locations (Geography)

A list of all locations:
http://localhost:8080/locations

A location by location name, e.g. "Thais":
http://localhost:8080/locations/Thais

## Hunting Places (in progress)
## Hunting Places

A list of all hunting places:
http://localhost:8080/huntingplaces
http://localhost:8080/api/huntingplaces

A location by location name, e.g. "Hero Cave":
http://localhost:8080/huntingplaces/Hero_Cave
http://localhost:8080/api/huntingplaces/Hero_Cave

## Items

A list of all items:
http://localhost:8080/items
http://localhost:8080/api/items

An item by item name, e.g. "Carlin Sword":
http://localhost:8080/items/Carlin_Sword
http://localhost:8080/api/items/Carlin_Sword

## Keys

A list of all keys:
http://localhost:8080/keys
http://localhost:8080/api/keys

A key by key name (not only the number but the full wiki pagename), e.g. "Key 4055":
http://localhost:8080/keys/Key_4055
http://localhost:8080/api/keys/Key_4055

## Locations (Geography)

A list of all locations:
http://localhost:8080/api/locations

A location by location name, e.g. "Thais":
http://localhost:8080/api/locations/Thais

## Missiles

A list of all missiles:
http://localhost:8080/api/missiles

A missile by name, e.g. "Throwing Cake Missile":
http://localhost:8080/api/missiles/Throwing_Cake_Missile

## Mounts

A list of all mounts:
http://localhost:8080/mounts
http://localhost:8080/api/mounts

A mount by mount name, e.g. "Donkey":
http://localhost:8080/mounts/Donkey
http://localhost:8080/api/mounts/Donkey

## NPCs

A list of all NPCs:
http://localhost:8080/npcs
http://localhost:8080/api/npcs

An NPC by NPC name, e.g. "Sam":
http://localhost:8080/npcs/Sam
http://localhost:8080/api/npcs/Sam

## Objects

A list of all objects:
http://localhost:8080/objects
http://localhost:8080/api/objects

An object by object name, e.g. "Blueberry Bush":
http://localhost:8080/objects/Blueberry_Bush
http://localhost:8080/api/objects/Blueberry_Bush

## Outfits

A list of all outfits:
http://localhost:8080/outfits
http://localhost:8080/api/outfits

An outfit by outfit name, e.g. "Pirate Outfits":
http://localhost:8080/outfits/Pirate_Outfits
http://localhost:8080/api/outfits/Pirate_Outfits

## Quests

A list of all quests:
http://localhost:8080/quests
http://localhost:8080/api/quests

A quest by quest name, e.g. "The Paradox Tower Quest":
http://localhost:8080/quests/The_Paradox_Tower_Quest
http://localhost:8080/api/quests/The_Paradox_Tower_Quest

## Spells

A list of all spells:
http://localhost:8080/spells
http://localhost:8080/api/spells

A spell by spell name, e.g. "Light Healing":
http://localhost:8080/spells/Light_Healing
http://localhost:8080/api/spells/Light_Healing

## Streets

A list of all streets:
http://localhost:8080/streets
http://localhost:8080/api/streets

A street by street name, e.g. "Sugar Street":
http://localhost:8080/streets/Sugar_Street
http://localhost:8080/api/streets/Sugar_Street
56 changes: 54 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>com.tibiawiki</groupId>
<artifactId>TibiaWikiApi</artifactId>
<version>1.3.1</version>
<version>1.4.0</version>
<packaging>jar</packaging>
<name>TibiaWikiApi</name>
<url>https://github.com/benjaminkomen/TibiaWikiApi</url>
Expand All @@ -27,14 +27,17 @@
<junit.jupiter.version>5.3.1</junit.jupiter.version>
<mockito.version>2.0.2-beta</mockito.version>
<hamcrest.version>1.3</hamcrest.version>
<maven.surefire.plugin.version>2.22.0</maven.surefire.plugin.version>
<maven.surefire.plugin.version>2.22.1</maven.surefire.plugin.version>
<maven.failsafe.plugin.version>2.22.1</maven.failsafe.plugin.version>
<maven.compiler.plugin.version>3.8.0</maven.compiler.plugin.version>
<build.helper.maven.plugin.version>3.0.0</build.helper.maven.plugin.version>
<junit.platform.surefire.provider.version>1.2.0</junit.platform.surefire.provider.version>
<jwiki.version>2.0.1</jwiki.version>
<guava.version>26.0-jre</guava.version>
<ow2.asm.version>6.2.1</ow2.asm.version>
<swagger.jersey2.jaxrs.version>1.5.21</swagger.jersey2.jaxrs.version>
<javax.activation.version>1.1.1</javax.activation.version>
<vavr.version>0.9.2</vavr.version>
</properties>

<repositories>
Expand Down Expand Up @@ -147,6 +150,14 @@
<version>${swagger.jersey2.jaxrs.version}</version>
</dependency>

<!-- Vavr - functional language features -->
<dependency>
<groupId>io.vavr</groupId>
<artifactId>vavr</artifactId>
<version>${vavr.version}</version>
</dependency>


<!-- Test -->

<!-- To write unit tests -->
Expand Down Expand Up @@ -243,6 +254,47 @@
</dependency>
</dependencies>
</plugin>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>${build.helper.maven.plugin.version}</version>
<executions>
<execution>
<id>add-test-source</id>
<phase>process-resources</phase>
<goals>
<goal>add-test-source</goal>
</goals>
<configuration>
<sources>
<source>src/it/java</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${maven.failsafe.plugin.version}</version>
<executions>
<execution>
<id>integration-test</id>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
<execution>
<id>verify</id>
<goals>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>

</plugins>
</build>
</project>
66 changes: 66 additions & 0 deletions src/it/java/com/tibiawiki/domain/factories/JsonFactoryIT.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package com.tibiawiki.domain.factories;

import com.tibiawiki.domain.enums.Grade;
import com.tibiawiki.domain.enums.YesNo;
import com.tibiawiki.domain.objects.Achievement;
import org.json.JSONObject;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;

/**
* We want to be sure that the deserialization of a wiki article to a java object,
* and serialisation back to the wiki article, do not cause unwanted side-effects in the article's content. Some effects
* are however not side-effects, but completely legit:
* - removal of undocumentend parameters;
* - removal of empty parameters;
* - ...
*/
public class JsonFactoryIT {

private JsonFactory target;

@BeforeEach
void setup() {
target = new JsonFactory();
}

@Test
void testDeserializeAndSerialiseSomeAchievement() {
JSONObject achievementAsJson = target.convertInfoboxPartOfArticleToJson(INFOBOX_ACHIEVEMENT_TEXT);

String result = target.convertJsonToInfoboxPartOfArticle(achievementAsJson, makeAchievement().fieldOrder());

assertThat(result, is(INFOBOX_ACHIEVEMENT_TEXT));
}

private static final String INFOBOX_ACHIEVEMENT_TEXT = "{{Infobox Achievement|List={{{1|}}}|GetValue={{{GetValue|}}}\n" +
"| grade = 1\n" +
"| name = Goo Goo Dancer\n" +
"| description = Seeing a mucus plug makes your heart dance and you can't resist to see what it hides. Goo goo away!\n" +
"| spoiler = Obtainable by using 100 [[Muck Remover]]s on [[Mucus Plug]]s.\n" +
"| premium = yes\n" +
"| points = 1\n" +
"| secret = yes\n" +
"| implemented = 9.6\n" +
"| achievementid = 319\n" +
"| relatedpages = [[Muck Remover]], [[Mucus Plug]]\n" +
"}}\n";

private Achievement makeAchievement() {
return Achievement.builder()
.grade(Grade.ONE)
.name("Goo Goo Dancer")
.description("Seeing a mucus plug makes your heart dance and you can't resist to see what it hides. Goo goo away!")
.spoiler("Obtainable by using 100 [[Muck Remover]]s on [[Mucus Plug]]s.")
.premium(YesNo.YES_LOWERCASE)
.points(1)
.secret(YesNo.YES_LOWERCASE)
.implemented("9.6")
.achievementid(319)
.relatedpages("[[Muck Remover]], [[Mucus Plug]]")
.build();
}
}
20 changes: 20 additions & 0 deletions src/main/java/com/tibiawiki/TibiaWikiApiApplication.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,32 @@
package com.tibiawiki;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.tibiawiki.domain.jackson.WikiObjectMixin;
import com.tibiawiki.domain.objects.WikiObject;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;

@SpringBootApplication
public class TibiaWikiApiApplication {

public static void main(String[] args) {
SpringApplication.run(TibiaWikiApiApplication.class, args);
}

@Bean
@Primary
public ObjectMapper objectMapper(Jackson2ObjectMapperBuilder builder) {
ObjectMapper objectMapper = builder.createXmlMapper(false).build();
objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
objectMapper.configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, false);
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);

objectMapper.addMixIn(WikiObjectMixin.class, WikiObject.class);
return objectMapper;
}
}
Loading

0 comments on commit 907cac1

Please sign in to comment.