Commit b85f4f9b authored by Ricco Førgaard's avatar Ricco Førgaard

Merge branch 'master' of prosjekt.nsd.uib.no:nesstar/nesstar-rest-api

Conflicts:
	src/main/java/com/nesstar/rest/NesstarDropService.java
	src/main/java/com/nesstar/rest/common/ETag.java
	src/test/java/com/nesstar/rest/common/ETagTest.java
parents 78777df2 0ba1723d
......@@ -4,7 +4,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.yammer.dropwizard.config.Configuration;
import org.hibernate.validator.constraints.NotEmpty;
public class NesstarDropConfiguration extends Configuration {
public final class NesstarDropConfiguration extends Configuration {
@NotEmpty
@JsonProperty
private String serverURI;
......
......@@ -25,8 +25,7 @@ import com.yammer.dropwizard.config.Bootstrap;
import com.yammer.dropwizard.config.Environment;
import com.yammer.dropwizard.config.FilterBuilder;
public class NesstarDropService extends Service<NesstarDropConfiguration> {
public final class NesstarDropService extends Service<NesstarDropConfiguration> {
public static void main(String[] args) throws Exception {
new NesstarDropService().run(args);
}
......
......@@ -4,7 +4,7 @@ package com.nesstar.rest.common;
import com.nesstar.api.NesstarObject;
import com.nesstar.rest.Version;
public class ETag {
public final class ETag {
public static final String HEADER_NAME = "ETag";
private String hash;
......@@ -27,11 +27,9 @@ public class ETag {
return false;
}
public boolean equals(String someEtag) {
if (someEtag != null && !someEtag.isEmpty()) {
return someEtag.equalsIgnoreCase(hash);
}
return false;
@Override
public int hashCode() {
return hash.hashCode();
}
public static ETag createEtag(String url, NesstarObject object) {
......
......@@ -4,7 +4,6 @@ import java.io.IOException;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Calendar;
import java.util.Date;
import com.nesstar.api.NesstarList;
......@@ -14,6 +13,7 @@ import com.nesstar.api.NotAuthorizedException;
public class ETagGenerator {
private final String salt;
private final static String ALGORITHM = "MD5";
private static final Date zeroDate = new Date(0l);
public ETagGenerator(String salt) {
this.salt = salt;
......@@ -46,7 +46,7 @@ public class ETagGenerator {
}
private Date getLatestTimestampFromList(NesstarList<NesstarObject> list) throws NotAuthorizedException, IOException {
Date latest = createDefaultDate();
Date latest = zeroDate;
for (NesstarObject object : list) {
if (object.getTimeStamp().after(latest)) {
latest = object.getTimeStamp();
......@@ -55,12 +55,6 @@ public class ETagGenerator {
return latest;
}
private Date createDefaultDate() {
Calendar calendar = Calendar.getInstance();
calendar.set(1970, 0, 0, 0, 0);
return calendar.getTime();
}
private String generateChecksum(String id, Date timestamp, String url, String salt) {
String checksum;
try {
......
......@@ -9,7 +9,7 @@ public abstract class Operation {
public abstract Object run() throws Exception;
public boolean tryToRecover(Exception e, ServerHandler serverHandler) {
public final boolean tryToRecover(Exception e, ServerHandler serverHandler) {
if (e instanceof NotAuthorizedException) {
try {
Server server = serverHandler.getServer();
......
......@@ -10,7 +10,7 @@ public final class OperationRunner {
private OperationRunner() {
}
public static Object runWithExceptionHandling(HttpServletRequest request, Operation operation, ServerHandler serverHandler) {
public static Object runWithExceptionHandling(Operation operation, ServerHandler serverHandler) {
int attempts = 0;
while (true) {
try {
......
......@@ -23,7 +23,7 @@ import com.nesstar.rest.common.ETag;
import com.nesstar.rest.common.ETagGenerator;
import com.nesstar.rest.common.ServerHandler;
public class EntityTagFilter implements Filter {
public final class EntityTagFilter implements Filter {
private static final String HEADER_NAME = "If-None-Match";
private ServerHandler serverHandler;
private ETagGenerator generator = new ETagGenerator(Version.version());
......@@ -46,7 +46,7 @@ public class EntityTagFilter implements Filter {
HttpServletRequest httpRequest = (HttpServletRequest) request;
HttpServletResponse httpResponse = (HttpServletResponse) response;
if (requestHasETag(httpRequest) && checkForMatchingETag(httpRequest, httpResponse)) {
if (requestHasETag(httpRequest) && checkForMatchingETag(httpRequest)) {
return304Header(httpResponse);
} else {
chain.doFilter(request, response);
......@@ -58,7 +58,7 @@ public class EntityTagFilter implements Filter {
return etag != null && !etag.isEmpty();
}
private boolean checkForMatchingETag(HttpServletRequest request, HttpServletResponse response) {
private boolean checkForMatchingETag(HttpServletRequest request) {
boolean matches = false;
NesstarObject object = getObject(request);
......@@ -211,7 +211,7 @@ public class EntityTagFilter implements Filter {
private boolean etagsMatch(HttpServletRequest request, ETag etag) {
String etagFromRequest = getEtagFromRequest(request);
return etag.equals(etagFromRequest);
return etagFromRequest.equals(etag.getValue());
}
private String getEtagFromRequest(HttpServletRequest request) {
......@@ -232,7 +232,7 @@ public class EntityTagFilter implements Filter {
}
private void return304Header(HttpServletResponse response) throws IOException {
response.setStatus(304);
response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
response.flushBuffer();
}
......
......@@ -7,7 +7,7 @@ import javax.servlet.*;
import java.io.IOException;
import java.util.Locale;
public class LanguageFilter implements Filter {
public final class LanguageFilter implements Filter {
@Override
public void init(FilterConfig filterConfig) throws ServletException {
......
......@@ -11,7 +11,7 @@ import java.io.IOException;
import static com.yammer.metrics.core.HealthCheck.Result.healthy;
import static com.yammer.metrics.core.HealthCheck.Result.unhealthy;
public class NesstarHealthCheck extends HealthCheck {
public final class NesstarHealthCheck extends HealthCheck {
private ServerHandler serverHandler;
public NesstarHealthCheck(ServerHandler serverHandler) {
......
......@@ -8,7 +8,7 @@ import java.io.IOException;
import java.util.List;
import java.util.Map;
public class CubeRequest {
public final class CubeRequest {
private static final Logger LOGGER = LoggerFactory.getLogger(CubeRequest.class);
private static ObjectMapper objectMapper = new ObjectMapper();
......
......@@ -7,7 +7,7 @@ import com.nesstar.api.NesstarObject;
import com.nesstar.rest.common.ETag;
import com.nesstar.rest.common.ServerHandler;
public class AbstractResource {
class AbstractResource {
protected ServerHandler serverHandler;
protected AbstractResource(ServerHandler serverHandler) {
......
......@@ -28,7 +28,7 @@ import java.util.Map;
@Path("study/{studyId}/correlate")
@Produces(MediaType.APPLICATION_JSON)
public class CorrelationResource extends AbstractResource {
public final class CorrelationResource extends AbstractResource {
public CorrelationResource(ServerHandler serverHandler) {
super(serverHandler);
......@@ -54,7 +54,7 @@ public class CorrelationResource extends AbstractResource {
final ClassVariables classVariables = new ClassVariables();
return OperationRunner.runWithExceptionHandling(request, new Operation() {
return OperationRunner.runWithExceptionHandling(new Operation() {
@Override
public Object run() throws Exception {
classVariables.server = serverHandler.getServer();
......
......@@ -38,7 +38,7 @@ import com.yammer.metrics.annotation.Timed;
@Path("cube/{cubeId}")
@Produces(MediaType.APPLICATION_JSON)
public class CubeResource extends AbstractResource{
public final class CubeResource extends AbstractResource{
public CubeResource(ServerHandler serverHandler) {
super(serverHandler);
......@@ -71,7 +71,7 @@ public class CubeResource extends AbstractResource{
return ErrorMaker.getBadRequestError("The request must specify at least one break variable or one measure variable.");
}
return OperationRunner.runWithExceptionHandling(request, new Operation() {
return OperationRunner.runWithExceptionHandling(new Operation() {
@Override
public Object run() throws Exception {
classVariables.server = serverHandler.getServer();
......@@ -91,7 +91,7 @@ public class CubeResource extends AbstractResource{
classVariables.values = null;
classVariables.dimensionMemberList = new LinkedHashMap<Dimension, List<Member>>();
return OperationRunner.runWithExceptionHandling(request, new Operation() {
return OperationRunner.runWithExceptionHandling(new Operation() {
@Override
public Object run() throws Exception {
classVariables.server = serverHandler.getServer();
......@@ -140,7 +140,7 @@ public class CubeResource extends AbstractResource{
}
}
classVariables.dimensionMemberList.put(dimension, members);
if (members.size() == 0) {
if (members.isEmpty()) {
sliceBuilder.addDimension(dimension);
} else {
sliceBuilder.addDimension(dimension, members.toArray(new Member[members.size()]));
......@@ -190,7 +190,7 @@ public class CubeResource extends AbstractResource{
private double formattedValue(Measure measure, Double value) throws NotAuthorizedException, IOException {
StringBuilder format = new StringBuilder("%.");
format.append(getDecimalsForMeasure(measure)).append("f");
return Double.valueOf(String.format(Locale.US, format.toString(), value)).doubleValue();
return Double.valueOf(String.format(Locale.US, format.toString(), value));
}
private void setCell(List<Map<String, Object>> dimensionvaluelist, Cell cell, Measure measure) throws IOException, NotAuthorizedException {
......@@ -212,7 +212,7 @@ public class CubeResource extends AbstractResource{
int depth = coords.size();
Dimension dimension = classVariables.dimensions.get(depth);
List<Member> members = classVariables.dimensionMemberList.get(dimension);
if (members == null || members.size() == 0) {
if (members == null || members.isEmpty()) {
members = DimensionMaker.getMembersFromDimension(dimension);
}
for (Member member : members) {
......
......@@ -2,20 +2,17 @@ package com.nesstar.rest.resources;
import com.nesstar.api.*;
import com.nesstar.api.subset.CaseSubset;
import com.nesstar.api.subset.SubsetSyntaxException;
import com.nesstar.rest.common.*;
import com.yammer.metrics.annotation.Timed;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.*;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.io.IOException;
import java.util.List;
@Path("study/{studyId}/download")
public class DownloadResource extends AbstractResource {
public final class DownloadResource extends AbstractResource {
public DownloadResource(ServerHandler serverHandler) {
super(serverHandler);
......@@ -23,9 +20,9 @@ public class DownloadResource extends AbstractResource {
@GET
@Timed
public Object download(@QueryParam("var") final List<String> variableIDs, @QueryParam("format") final String fileFormat, @QueryParam("caseSubset") final String caseSubset, @PathParam("studyId") final String studyId, @Context final HttpServletRequest request) throws IOException, MissingResourceException, SubsetSyntaxException, NotAuthorizedException {
public Object download(@QueryParam("var") final List<String> variableIDs, @QueryParam("format") final String fileFormat, @QueryParam("caseSubset") final String caseSubset, @PathParam("studyId") final String studyId, @Context final HttpServletRequest request) {
return OperationRunner.runWithExceptionHandling(request, new Operation() {
return OperationRunner.runWithExceptionHandling(new Operation() {
@Override
public Object run() throws Exception {
Server server = serverHandler.getServer();
......
......@@ -29,7 +29,7 @@ import com.yammer.metrics.annotation.Timed;
@Path("search")
@Produces(MediaType.APPLICATION_JSON)
public class QueryResource extends AbstractResource {
public final class QueryResource extends AbstractResource {
private static Map<String, Class<? extends NesstarObject>> supportedReturnTypes;
public QueryResource(ServerHandler serverHandler) {
......@@ -56,7 +56,7 @@ public class QueryResource extends AbstractResource {
return ErrorMaker.getBadRequestError("The query must specify at least one included term.");
}
return OperationRunner.runWithExceptionHandling(request, new Operation() {
return OperationRunner.runWithExceptionHandling(new Operation() {
@Override
public Object run() throws Exception {
Server server = serverHandler.getServer();
......
......@@ -29,7 +29,7 @@ import java.util.Map;
@Path("study/{studyId}/regress")
@Produces(MediaType.APPLICATION_JSON)
public class RegressionResource extends AbstractResource {
public final class RegressionResource extends AbstractResource {
public RegressionResource(ServerHandler serverHandler) {
super(serverHandler);
......@@ -61,7 +61,7 @@ public class RegressionResource extends AbstractResource {
return ErrorMaker.getBadRequestError("The request must specify a dependent variable and at least 1 independent variables.");
}
return OperationRunner.runWithExceptionHandling(request, new Operation() {
return OperationRunner.runWithExceptionHandling(new Operation() {
@Override
public Object run() throws Exception {
classVariables.server = serverHandler.getServer();
......
......@@ -32,7 +32,7 @@ import com.yammer.metrics.annotation.Timed;
@Path("/studies")
@Produces(MediaType.APPLICATION_JSON)
public class StudyListResource extends AbstractResource {
public final class StudyListResource extends AbstractResource {
public StudyListResource(ServerHandler serverHandler) {
super(serverHandler);
......@@ -41,7 +41,7 @@ public class StudyListResource extends AbstractResource {
@GET
@Timed
public Object getStudyList(@Context final HttpServletRequest request, @Context final HttpServletResponse response) {
return OperationRunner.runWithExceptionHandling(request, new Operation() {
return OperationRunner.runWithExceptionHandling(new Operation() {
@Override
public Object run() throws Exception {
Server server = serverHandler.getServer();
......
......@@ -31,15 +31,18 @@ import com.yammer.metrics.annotation.Timed;
@Path("study/{studyId}")
@Produces(MediaType.APPLICATION_JSON)
public class StudyResource extends AbstractResource {
public final class StudyResource extends AbstractResource {
public static final String STUDY_ID_PARAM_NAME = "studyId";
public StudyResource(ServerHandler serverHandler) {
super(serverHandler);
}
@GET
@Timed
public Object getMetadata(@PathParam("studyId") final String studyId, @Context final HttpServletRequest request, @Context final HttpServletResponse response) {
return OperationRunner.runWithExceptionHandling(request, new Operation() {
public Object getMetadata(@PathParam(STUDY_ID_PARAM_NAME) final String studyId, @Context final HttpServletRequest request, @Context final HttpServletResponse response) {
return OperationRunner.runWithExceptionHandling(new Operation() {
@Override
public Object run() throws Exception {
com.nesstar.api.Server server = serverHandler.getServer();
......@@ -53,8 +56,8 @@ public class StudyResource extends AbstractResource {
@Path("all-metadata")
@GET
@Timed
public Object getAllMetadata(@PathParam("studyId") final String studyId, @Context final HttpServletRequest request, @Context final HttpServletResponse response) {
return OperationRunner.runWithExceptionHandling(request, new Operation() {
public Object getAllMetadata(@PathParam(STUDY_ID_PARAM_NAME) final String studyId, @Context final HttpServletRequest request, @Context final HttpServletResponse response) {
return OperationRunner.runWithExceptionHandling(new Operation() {
@Override
public Object run() throws Exception {
com.nesstar.api.Server server = serverHandler.getServer();
......@@ -68,10 +71,10 @@ public class StudyResource extends AbstractResource {
@Path("/variables")
@GET
@Timed
public Object getVariables(@PathParam("studyId") final String studyId, @QueryParam("pageNumber") final int pageNumber,
public Object getVariables(@PathParam(STUDY_ID_PARAM_NAME) final String studyId, @QueryParam("pageNumber") final int pageNumber,
@QueryParam("pageSize") final int pageSize, @Context final HttpServletRequest request,
@Context final HttpServletResponse response) {
return OperationRunner.runWithExceptionHandling(request, new Operation() {
return OperationRunner.runWithExceptionHandling(new Operation() {
@Override
public Object run() throws Exception {
com.nesstar.api.Server server = serverHandler.getServer();
......@@ -86,9 +89,9 @@ public class StudyResource extends AbstractResource {
@Path("/variable-groups")
@GET
@Timed
public Object getVariableGroups(@PathParam("studyId") final String studyId, @Context final HttpServletRequest request,
public Object getVariableGroups(@PathParam(STUDY_ID_PARAM_NAME) final String studyId, @Context final HttpServletRequest request,
@Context final HttpServletResponse response) {
return OperationRunner.runWithExceptionHandling(request, new Operation() {
return OperationRunner.runWithExceptionHandling(new Operation() {
@Override
public Object run() throws Exception {
Server server = serverHandler.getServer();
......@@ -103,8 +106,8 @@ public class StudyResource extends AbstractResource {
@Path("/updated-time-stamp")
@GET
@Timed
public Object getUpdatedTimeStamp(@PathParam("studyId") final String studyId, @Context final HttpServletRequest request) {
return OperationRunner.runWithExceptionHandling(request, new Operation() {
public Object getUpdatedTimeStamp(@PathParam(STUDY_ID_PARAM_NAME) final String studyId, @Context final HttpServletRequest request) {
return OperationRunner.runWithExceptionHandling(new Operation() {
@Override
public Object run() throws Exception {
Server server = serverHandler.getServer();
......
......@@ -30,7 +30,7 @@ import com.yammer.metrics.annotation.Timed;
@Path("study/{studyId}/tabulate")
@Produces(MediaType.APPLICATION_JSON)
public class TabulateResource extends AbstractResource {
public final class TabulateResource extends AbstractResource {
public TabulateResource(ServerHandler serverHandler) {
super(serverHandler);
}
......@@ -63,7 +63,7 @@ public class TabulateResource extends AbstractResource {
final ClassVariables classVariables = new ClassVariables();
classVariables.categories = new ArrayList<DdiList<Category>>();
return OperationRunner.runWithExceptionHandling(request, new Operation() {
return OperationRunner.runWithExceptionHandling(new Operation() {
@Override
public Object run() throws Exception {
classVariables.server = serverHandler.getServer();
......
......@@ -19,7 +19,7 @@ import java.util.Scanner;
@Path("metadata-translation/{languageCode}")
@Produces(MediaType.APPLICATION_JSON)
public class TranslationResource extends AbstractResource {
public final class TranslationResource extends AbstractResource {
public TranslationResource(ServerHandler serverHandler) {
super(serverHandler);
}
......@@ -27,7 +27,7 @@ public class TranslationResource extends AbstractResource {
@GET
@Timed
public Object getTranslation(@PathParam("languageCode") final String languageCode, @Context final HttpServletRequest request) {
return OperationRunner.runWithExceptionHandling(request, new Operation() {
return OperationRunner.runWithExceptionHandling(new Operation() {
@Override
public Object run() throws Exception {
String fileName = "MetadataTranslation_" + languageCode + ".json";
......
......@@ -22,7 +22,7 @@ import com.yammer.metrics.annotation.Timed;
@Path("variable-group/{groupId}")
@Produces(MediaType.APPLICATION_JSON)
public class VariableGroupResource extends AbstractResource {
public final class VariableGroupResource extends AbstractResource {
public VariableGroupResource(ServerHandler serverHandler) {
super(serverHandler);
......@@ -34,7 +34,7 @@ public class VariableGroupResource extends AbstractResource {
public Object getVariables(@PathParam("groupId") final String groupId, @QueryParam("pageNumber") final int pageNumber,
@QueryParam("pageSize") final int pageSize, @Context final HttpServletRequest request,
@Context final HttpServletResponse response) {
return OperationRunner.runWithExceptionHandling(request, new Operation() {
return OperationRunner.runWithExceptionHandling(new Operation() {
@Override
public Object run() throws Exception {
com.nesstar.api.Server server = serverHandler.getServer();
......@@ -50,7 +50,7 @@ public class VariableGroupResource extends AbstractResource {
@Timed
public Object getChildGroups(@PathParam("groupId") final String groupId, @Context final HttpServletRequest request,
@Context final HttpServletResponse response) {
return OperationRunner.runWithExceptionHandling(request, new Operation() {
return OperationRunner.runWithExceptionHandling(new Operation() {
@Override
public Object run() throws Exception {
Server server = serverHandler.getServer();
......
......@@ -20,7 +20,7 @@ import com.yammer.metrics.annotation.Timed;
@Path("/variable/{variableId}")
@Produces(MediaType.APPLICATION_JSON)
public class VariableResource extends AbstractResource{
public final class VariableResource extends AbstractResource{
public VariableResource(ServerHandler serverHandler) {
super(serverHandler);
}
......@@ -29,7 +29,7 @@ public class VariableResource extends AbstractResource{
@Timed
public Object getVariableMetadata(@PathParam("variableId") final String variableId, @Context final HttpServletRequest request,
@Context final HttpServletResponse response) {
return OperationRunner.runWithExceptionHandling(request, new Operation() {
return OperationRunner.runWithExceptionHandling(new Operation() {
@Override
public Object run() throws Exception {
Server server = serverHandler.getServer();
......
......@@ -13,12 +13,15 @@ import java.util.Set;
import com.nesstar.api.NotAuthorizedException;
import com.nesstar.api.cube.*;
public class DimensionMaker {
public final class DimensionMaker {
public static final String DIMENSION_TYPE_PLAIN = "plain";
public static final String DIMENSION_TYPE_TEMPORAL = "temporal";
public static final String DIMENSION_TYPE_SPATIAL = "spatial";
private DimensionMaker() {
}
public static Map<String, Object> getDimensionJsonObject(Dimension dimension) throws NotAuthorizedException, IOException {
Map<String, Object> objectmap = new LinkedHashMap<String, Object>();
objectmap.put("id", dimension.getId());
......@@ -31,7 +34,7 @@ public class DimensionMaker {
private static void addDimensionMembersToObjectMap(Dimension dimension, Map<String, Object> objectmap) throws NotAuthorizedException, IOException {
List<Member> memberList = getMembersFromDimension(dimension);
if (memberList.size() > 0) {
if (!memberList.isEmpty()) {
objectmap.put("members", MemberMaker.getMemberJsonObjectList(dimension, memberList));
}
}
......@@ -55,7 +58,7 @@ public class DimensionMaker {
}
private static void addObject(Map<String, Object> objectmap, String id, Collection<String> objects) {
if(objects.size() > 0) {
if(!objects.isEmpty()) {
objectmap.put(id, objects);
}
}
......
......@@ -2,6 +2,8 @@ package com.nesstar.rest.result_object_makers;
import com.nesstar.api.NotAuthorizedException;
import com.nesstar.rest.common.MissingResourceException;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.core.Response;
import java.util.HashMap;
import java.util.LinkedHashMap;
......@@ -20,10 +22,10 @@ public final class ErrorMaker {
static {
errorTypeToErrorCodeMap = new HashMap<ErrorType, Integer>();
errorTypeToErrorCodeMap.put(ErrorType.PERMISSION_DENIED, 401);
errorTypeToErrorCodeMap.put(ErrorType.MISSING_RESOURCE, 404);
errorTypeToErrorCodeMap.put(ErrorType.BAD_REQUEST, 400);
errorTypeToErrorCodeMap.put(ErrorType.UNEXPECTED_ERROR, 500);
errorTypeToErrorCodeMap.put(ErrorType.PERMISSION_DENIED, HttpServletResponse.SC_UNAUTHORIZED);
errorTypeToErrorCodeMap.put(ErrorType.MISSING_RESOURCE, HttpServletResponse.SC_NOT_FOUND);
errorTypeToErrorCodeMap.put(ErrorType.BAD_REQUEST, HttpServletResponse.SC_BAD_REQUEST);
errorTypeToErrorCodeMap.put(ErrorType.UNEXPECTED_ERROR, HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
}
private ErrorMaker() {
......
......@@ -12,7 +12,10 @@ import com.nesstar.api.cube.Dimension;
import com.nesstar.api.cube.Hierarchy;
import com.nesstar.api.cube.Level;
public class HierarchyMaker {
public final class HierarchyMaker {
private HierarchyMaker() {
}
public static Map<String, Object> getHierarchyJsonObject(Dimension dimension, Hierarchy hierarchy) throws NotAuthorizedException, IOException {
Map<String, Object> measuremap = new LinkedHashMap<String, Object>();
measuremap.put("root", hierarchy.getRoot().getId());
......
......@@ -10,7 +10,10 @@ import java.util.Map;
import com.nesstar.api.NotAuthorizedException;
import com.nesstar.api.cube.Measure;
public class MeasureMaker {
public final class MeasureMaker {
private MeasureMaker() {
}
public static Map<String, Object> getMeasureJsonObject(Measure measure) throws NotAuthorizedException, IOException {
Map<String, Object> measuremap = new LinkedHashMap<String, Object>();
measuremap.put("id", measure.getId());
......
......@@ -11,7 +11,9 @@ import com.nesstar.api.NotAuthorizedException;
import com.nesstar.api.cube.Dimension;
import com.nesstar.api.cube.Member;
public class MemberMaker {
public final class MemberMaker {
private MemberMaker() {
}
public static Map<String, Object> getMemberJsonObject(Dimension dimension, Member member) throws NotAuthorizedException, IOException {
Map<String, Object> objectmap = new LinkedHashMap<String, Object>();
......
......@@ -27,7 +27,7 @@ public final class SearchResultMaker {
supportedClassJSONNameList.put(VariableGroup.class, "variableGroups");
supportedClassJSONNameList.put(Category.class, "categories");
supportedClassJSONNameList.put(EGMSResource.class, "EGMSResources");
};
}
private SearchResultMaker() {
......
......@@ -25,13 +25,12 @@ public class ETagTest {
String expectedTagValue = "148c8ef4be39449dc56acbc2e0e0b455";
ETag tag = ETag.createETag(url, study, generator);
assertEquals("Tags don't match", expectedTagValue, tag.getValue());
assertTrue("Tags aren't equal", tag.equals(expectedTagValue));
}
@Test
public void testEmptyInput() {
ETag tag = ETag.createETag(url, study, generator);
assertFalse(tag.equals(""));
assertFalse(tag.getValue().isEmpty());
}
@Test
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment