-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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
1 parent
122a8e8
commit 907cac1
Showing
83 changed files
with
4,624 additions
and
1,104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
language: java | ||
|
||
jdk: | ||
- openjdk8 | ||
- openjdk11 | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
src/it/java/com/tibiawiki/domain/factories/JsonFactoryIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
Oops, something went wrong.