added versioning to APIs
This commit is contained in:
@@ -2,6 +2,7 @@ package com.poststats.golf.api;
|
||||
|
||||
import com.brianlong.sql.DataSet;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.poststats.api.BaseApi;
|
||||
import com.poststats.golf.api.model.Event;
|
||||
import com.poststats.golf.api.model.EventDetail;
|
||||
import com.poststats.golf.service.EventService;
|
||||
@@ -25,8 +26,8 @@ import org.slf4j.LoggerFactory;
|
||||
* @author brian.long@poststats.com
|
||||
*/
|
||||
@RequestScoped
|
||||
@Path("/event/{eventId}")
|
||||
public class EventApi {
|
||||
@Path(BaseApi.BASE_PATH + "/golf/event/{eventId}")
|
||||
public class EventApi extends BaseApi {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
|
@@ -3,6 +3,7 @@ package com.poststats.golf.api;
|
||||
import com.brianlong.sql.DataSet;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.poststats.api.BaseApi;
|
||||
import com.poststats.golf.service.EventFinanceService;
|
||||
import jakarta.annotation.security.RolesAllowed;
|
||||
import jakarta.enterprise.context.RequestScoped;
|
||||
@@ -23,8 +24,8 @@ import org.apache.commons.csv.CSVFormat;
|
||||
import org.apache.commons.csv.CSVPrinter;
|
||||
|
||||
@RequestScoped
|
||||
@Path("/event/{eventId}/finance")
|
||||
public class EventFinanceApi {
|
||||
@Path(BaseApi.BASE_PATH + "/golf/event/{eventId}/finance")
|
||||
public class EventFinanceApi extends BaseApi {
|
||||
|
||||
private final ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
|
@@ -3,6 +3,7 @@ package com.poststats.golf.api;
|
||||
import com.brianlong.sql.DataSet;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.poststats.api.BaseApi;
|
||||
import com.poststats.golf.service.EventPersonService;
|
||||
import com.poststats.golf.service.EventService;
|
||||
import com.poststats.security.Person;
|
||||
@@ -29,8 +30,8 @@ import org.apache.commons.csv.CSVFormat;
|
||||
import org.apache.commons.csv.CSVPrinter;
|
||||
|
||||
@RequestScoped
|
||||
@Path("/event/{eventId}")
|
||||
public class EventPersonApi {
|
||||
@Path(BaseApi.BASE_PATH + "/golf/event/{eventId}")
|
||||
public class EventPersonApi extends BaseApi {
|
||||
|
||||
private final ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
|
@@ -2,6 +2,7 @@ package com.poststats.golf.api;
|
||||
|
||||
import com.brianlong.sql.DataSet;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.poststats.api.BaseApi;
|
||||
import com.poststats.api.model.Person;
|
||||
import com.poststats.golf.transformer.GolferTransformer;
|
||||
import com.poststats.service.PersonService;
|
||||
@@ -24,8 +25,8 @@ import org.slf4j.LoggerFactory;
|
||||
* @author brian.long@poststats.com
|
||||
*/
|
||||
@RequestScoped
|
||||
@Path("/golfer/{personId}")
|
||||
public class GolferApi {
|
||||
@Path(BaseApi.BASE_PATH + "/golfer/{personId}")
|
||||
public class GolferApi extends BaseApi {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
|
@@ -2,6 +2,7 @@ package com.poststats.golf.api;
|
||||
|
||||
import com.brianlong.sql.DataSet;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.poststats.api.BaseApi;
|
||||
import com.poststats.golf.api.model.Event;
|
||||
import com.poststats.golf.api.model.Series;
|
||||
import com.poststats.golf.service.EventService;
|
||||
@@ -33,8 +34,8 @@ import org.slf4j.LoggerFactory;
|
||||
* @author brian.long@poststats.com
|
||||
*/
|
||||
@RequestScoped
|
||||
@Path("/series/{seriesId}")
|
||||
public class SeriesApi {
|
||||
@Path(BaseApi.BASE_PATH + "/golf/series/{seriesId}")
|
||||
public class SeriesApi extends BaseApi {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
|
@@ -1,46 +0,0 @@
|
||||
package com.poststats.golf.api;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.poststats.api.VersionApi;
|
||||
import java.io.IOException;
|
||||
import java.util.regex.Pattern;
|
||||
import org.junit.Assert;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
public class VersionApiUnitTest {
|
||||
|
||||
private static ObjectMapper om = new ObjectMapper();
|
||||
private static VersionApi api;
|
||||
|
||||
@BeforeClass
|
||||
public static void init() {
|
||||
api = new VersionApi();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void get() throws IOException {
|
||||
String current = api.get();
|
||||
Assert.assertNotNull(current);
|
||||
Assert.assertTrue(current.length() > 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getPattern() throws IOException {
|
||||
String pattern = api.getRegexPattern();
|
||||
Assert.assertNotNull(pattern);
|
||||
Assert.assertTrue(pattern.length() > 0);
|
||||
|
||||
Pattern.compile(om.readValue(pattern, String.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isValidFormat() throws IOException {
|
||||
String pattern = om.readValue(api.getRegexPattern(), String.class);
|
||||
String current = om.readValue(api.get(), String.class);
|
||||
Assert.assertTrue(Pattern.compile(pattern)
|
||||
.matcher(current)
|
||||
.matches());
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user