http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/webapp/src/main/java/org/apache/atlas/web/resources/RexsterGraphResource.java ---------------------------------------------------------------------- diff --git a/webapp/src/main/java/org/apache/atlas/web/resources/RexsterGraphResource.java b/webapp/src/main/java/org/apache/atlas/web/resources/RexsterGraphResource.java index 5f54988..150f913 100755 --- a/webapp/src/main/java/org/apache/atlas/web/resources/RexsterGraphResource.java +++ b/webapp/src/main/java/org/apache/atlas/web/resources/RexsterGraphResource.java @@ -86,10 +86,8 @@ public class RexsterGraphResource { private static void validateInputs(String errorMsg, String... inputs) { for (String input : inputs) { if (StringUtils.isEmpty(input)) { - throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST) - .entity(errorMsg) - .type("text/plain") - .build()); + throw new WebApplicationException( + Response.status(Response.Status.BAD_REQUEST).entity(errorMsg).type("text/plain").build()); } } } @@ -122,12 +120,11 @@ public class RexsterGraphResource { Vertex vertex = findVertex(vertexId); JSONObject response = new JSONObject(); - response.put(AtlasClient.RESULTS, GraphSONUtility.jsonFromElement( - vertex, getVertexIndexedKeys(), GraphSONMode.NORMAL)); + response.put(AtlasClient.RESULTS, + GraphSONUtility.jsonFromElement(vertex, getVertexIndexedKeys(), GraphSONMode.NORMAL)); return Response.ok(response).build(); } catch (JSONException e) { - throw new WebApplicationException( - Servlets.getErrorResponse(e, Response.Status.INTERNAL_SERVER_ERROR)); + throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.INTERNAL_SERVER_ERROR)); } } @@ -136,8 +133,7 @@ public class RexsterGraphResource { if (vertex == null) { String message = "Vertex with [" + vertexId + "] cannot be found."; LOG.info(message); - throw new WebApplicationException( - Servlets.getErrorResponse(message, Response.Status.NOT_FOUND)); + throw new WebApplicationException(Servlets.getErrorResponse(message, Response.Status.NOT_FOUND)); } return vertex; @@ -153,8 +149,7 @@ public class RexsterGraphResource { @Path("/vertices/properties/{id}") @Produces({Servlets.JSON_MEDIA_TYPE}) public Response getVertexProperties(@PathParam("id") final String vertexId, - @DefaultValue("false") @QueryParam("relationships") - final String relationships) { + @DefaultValue("false") @QueryParam("relationships") final String relationships) { LOG.info("Get vertex for vertexId= {}", vertexId); validateInputs("Invalid argument: vertex id passed is null or empty.", vertexId); try { @@ -167,8 +162,7 @@ public class RexsterGraphResource { response.put(AtlasClient.COUNT, vertexProperties.size()); return Response.ok(response).build(); } catch (JSONException e) { - throw new WebApplicationException( - Servlets.getErrorResponse(e, Response.Status.INTERNAL_SERVER_ERROR)); + throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.INTERNAL_SERVER_ERROR)); } } @@ -192,8 +186,7 @@ public class RexsterGraphResource { @GET @Path("/vertices") @Produces({Servlets.JSON_MEDIA_TYPE}) - public Response getVertices(@QueryParam("key") final String key, - @QueryParam("value") final String value) { + public Response getVertices(@QueryParam("key") final String key, @QueryParam("value") final String value) { LOG.info("Get vertices for property key= {}, value= {}", key, value); validateInputs("Invalid argument: key or value passed is null or empty.", key, value); try { @@ -201,8 +194,7 @@ public class RexsterGraphResource { return Response.ok(response).build(); } catch (JSONException e) { - throw new WebApplicationException( - Servlets.getErrorResponse(e, Response.Status.INTERNAL_SERVER_ERROR)); + throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.INTERNAL_SERVER_ERROR)); } } @@ -216,20 +208,17 @@ public class RexsterGraphResource { @GET @Path("vertices/{id}/{direction}") @Produces({Servlets.JSON_MEDIA_TYPE}) - public Response getVertexEdges(@PathParam("id") String vertexId, - @PathParam("direction") String direction) { + public Response getVertexEdges(@PathParam("id") String vertexId, @PathParam("direction") String direction) { LOG.info("Get vertex edges for vertexId= {}, direction= {}", vertexId, direction); // Validate vertex id. Direction is validated in VertexQueryArguments. - validateInputs("Invalid argument: vertex id or direction passed is null or empty.", - vertexId, direction); + validateInputs("Invalid argument: vertex id or direction passed is null or empty.", vertexId, direction); try { Vertex vertex = findVertex(vertexId); return getVertexEdges(vertex, direction); } catch (JSONException e) { - throw new WebApplicationException( - Servlets.getErrorResponse(e, Response.Status.INTERNAL_SERVER_ERROR)); + throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.INTERNAL_SERVER_ERROR)); } } @@ -253,8 +242,7 @@ public class RexsterGraphResource { Iterable<Vertex> vertexQueryResults = query.vertices(); for (Vertex v : vertexQueryResults) { if (returnType.equals(ReturnType.VERTICES)) { - elementArray.put(GraphSONUtility.jsonFromElement( - v, getVertexIndexedKeys(), GraphSONMode.NORMAL)); + elementArray.put(GraphSONUtility.jsonFromElement(v, getVertexIndexedKeys(), GraphSONMode.NORMAL)); } else { elementArray.put(v.getId()); } @@ -263,8 +251,7 @@ public class RexsterGraphResource { } else if (returnType == ReturnType.EDGES) { Iterable<Edge> edgeQueryResults = query.edges(); for (Edge e : edgeQueryResults) { - elementArray.put(GraphSONUtility.jsonFromElement( - e, getEdgeIndexedKeys(), GraphSONMode.NORMAL)); + elementArray.put(GraphSONUtility.jsonFromElement(e, getEdgeIndexedKeys(), GraphSONMode.NORMAL)); counter++; } } else if (returnType == ReturnType.COUNT) { @@ -296,28 +283,25 @@ public class RexsterGraphResource { if (edge == null) { String message = "Edge with [" + edgeId + "] cannot be found."; LOG.info(message); - throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND) - .entity(Servlets.escapeJsonString(message)).build()); + throw new WebApplicationException( + Response.status(Response.Status.NOT_FOUND).entity(Servlets.escapeJsonString(message)).build()); } JSONObject response = new JSONObject(); - response.put(AtlasClient.RESULTS, GraphSONUtility.jsonFromElement( - edge, getEdgeIndexedKeys(), GraphSONMode.NORMAL)); + response.put(AtlasClient.RESULTS, + GraphSONUtility.jsonFromElement(edge, getEdgeIndexedKeys(), GraphSONMode.NORMAL)); return Response.ok(response).build(); } catch (JSONException e) { - throw new WebApplicationException( - Servlets.getErrorResponse(e, Response.Status.INTERNAL_SERVER_ERROR)); + throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.INTERNAL_SERVER_ERROR)); } } - private <T extends Element> JSONObject buildJSONResponse(Iterable<T> elements) - throws JSONException { + private <T extends Element> JSONObject buildJSONResponse(Iterable<T> elements) throws JSONException { JSONArray vertexArray = new JSONArray(); long counter = 0; for (Element element : elements) { counter++; - vertexArray.put(GraphSONUtility.jsonFromElement( - element, getVertexIndexedKeys(), GraphSONMode.NORMAL)); + vertexArray.put(GraphSONUtility.jsonFromElement(element, getVertexIndexedKeys(), GraphSONMode.NORMAL)); } JSONObject response = new JSONObject(); @@ -326,6 +310,7 @@ public class RexsterGraphResource { return response; } + private enum ReturnType {VERTICES, EDGES, COUNT, VERTEX_IDS} /** @@ -388,8 +373,7 @@ public class RexsterGraphResource { countOnly = false; } else { throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST) - .entity(Servlets.escapeJsonString(directionSegment + " segment was invalid.")) - .build()); + .entity(Servlets.escapeJsonString(directionSegment + " segment was invalid.")).build()); } }
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/webapp/src/main/java/org/apache/atlas/web/resources/TypesResource.java ---------------------------------------------------------------------- diff --git a/webapp/src/main/java/org/apache/atlas/web/resources/TypesResource.java b/webapp/src/main/java/org/apache/atlas/web/resources/TypesResource.java index 6c4a7ca..d6d5915 100755 --- a/webapp/src/main/java/org/apache/atlas/web/resources/TypesResource.java +++ b/webapp/src/main/java/org/apache/atlas/web/resources/TypesResource.java @@ -19,8 +19,8 @@ package org.apache.atlas.web.resources; import com.sun.jersey.api.client.ClientResponse; -import org.apache.atlas.AtlasException; import org.apache.atlas.AtlasClient; +import org.apache.atlas.AtlasException; import org.apache.atlas.services.MetadataService; import org.apache.atlas.typesystem.types.DataTypes; import org.apache.atlas.web.util.Servlets; @@ -98,12 +98,10 @@ public class TypesResource { return Response.status(ClientResponse.Status.CREATED).entity(response).build(); } catch (AtlasException | IllegalArgumentException e) { LOG.error("Unable to persist types", e); - throw new WebApplicationException( - Servlets.getErrorResponse(e, Response.Status.BAD_REQUEST)); + throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.BAD_REQUEST)); } catch (Throwable e) { LOG.error("Unable to persist types", e); - throw new WebApplicationException( - Servlets.getErrorResponse(e, Response.Status.INTERNAL_SERVER_ERROR)); + throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.INTERNAL_SERVER_ERROR)); } } @@ -115,8 +113,7 @@ public class TypesResource { @GET @Path("{typeName}") @Produces(Servlets.JSON_MEDIA_TYPE) - public Response getDefinition(@Context HttpServletRequest request, - @PathParam("typeName") String typeName) { + public Response getDefinition(@Context HttpServletRequest request, @PathParam("typeName") String typeName) { try { final String typeDefinition = metadataService.getTypeDefinition(typeName); @@ -128,16 +125,13 @@ public class TypesResource { return Response.ok(response).build(); } catch (AtlasException e) { LOG.error("Unable to get type definition for type {}", typeName, e); - throw new WebApplicationException( - Servlets.getErrorResponse(e, Response.Status.NOT_FOUND)); + throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.NOT_FOUND)); } catch (JSONException | IllegalArgumentException e) { LOG.error("Unable to get type definition for type {}", typeName, e); - throw new WebApplicationException( - Servlets.getErrorResponse(e, Response.Status.BAD_REQUEST)); + throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.BAD_REQUEST)); } catch (Throwable e) { LOG.error("Unable to get type definition for type {}", typeName, e); - throw new WebApplicationException( - Servlets.getErrorResponse(e, Response.Status.INTERNAL_SERVER_ERROR)); + throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.INTERNAL_SERVER_ERROR)); } } @@ -152,7 +146,7 @@ public class TypesResource { @GET @Produces(Servlets.JSON_MEDIA_TYPE) public Response getTypesByFilter(@Context HttpServletRequest request, - @DefaultValue(TYPE_ALL) @QueryParam("type") String type) { + @DefaultValue(TYPE_ALL) @QueryParam("type") String type) { try { List<String> result; if (TYPE_ALL.equals(type)) { @@ -174,8 +168,7 @@ public class TypesResource { Servlets.getErrorResponse("Unsupported type " + type, Response.Status.BAD_REQUEST)); } catch (Throwable e) { LOG.error("Unable to get types list", e); - throw new WebApplicationException( - Servlets.getErrorResponse(e, Response.Status.INTERNAL_SERVER_ERROR)); + throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.INTERNAL_SERVER_ERROR)); } } } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/webapp/src/main/java/org/apache/atlas/web/service/EmbeddedServer.java ---------------------------------------------------------------------- diff --git a/webapp/src/main/java/org/apache/atlas/web/service/EmbeddedServer.java b/webapp/src/main/java/org/apache/atlas/web/service/EmbeddedServer.java index 48285f0..88200f0 100755 --- a/webapp/src/main/java/org/apache/atlas/web/service/EmbeddedServer.java +++ b/webapp/src/main/java/org/apache/atlas/web/service/EmbeddedServer.java @@ -66,8 +66,7 @@ public class EmbeddedServer { private Integer getBufferSize() { try { - PropertiesConfiguration configuration = new PropertiesConfiguration( - "application.properties"); + PropertiesConfiguration configuration = new PropertiesConfiguration("application.properties"); return configuration.getInt("atlas.jetty.request.buffer.size", DEFAULT_BUFFER_SIZE); } catch (ConfigurationException e) { // do nothing http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/webapp/src/main/java/org/apache/atlas/web/service/SecureEmbeddedServer.java ---------------------------------------------------------------------- diff --git a/webapp/src/main/java/org/apache/atlas/web/service/SecureEmbeddedServer.java b/webapp/src/main/java/org/apache/atlas/web/service/SecureEmbeddedServer.java index 19e7783..63862a9 100755 --- a/webapp/src/main/java/org/apache/atlas/web/service/SecureEmbeddedServer.java +++ b/webapp/src/main/java/org/apache/atlas/web/service/SecureEmbeddedServer.java @@ -73,7 +73,7 @@ public class SecureEmbeddedServer extends EmbeddedServer { * configured credential provider. * @param config application configuration * @param key the key/alias for the password. - * @return the password. + * @return the password. * @throws IOException */ private String getPassword(PropertiesConfiguration config, String key) throws IOException { @@ -85,12 +85,11 @@ public class SecureEmbeddedServer extends EmbeddedServer { LOG.info("Attempting to retrieve password from configured credential provider path"); Configuration c = new Configuration(); c.set(CredentialProviderFactory.CREDENTIAL_PROVIDER_PATH, provider); - CredentialProvider credentialProvider = - CredentialProviderFactory.getProviders(c).get(0); + CredentialProvider credentialProvider = CredentialProviderFactory.getProviders(c).get(0); CredentialProvider.CredentialEntry entry = credentialProvider.getCredentialEntry(key); if (entry == null) { - throw new IOException(String.format("No credential entry found for %s. " + - "Please create an entry in the configured credential provider", key)); + throw new IOException(String.format("No credential entry found for %s. " + + "Please create an entry in the configured credential provider", key)); } else { password = String.valueOf(entry.getCredential()); } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/webapp/src/main/java/org/apache/atlas/web/util/DateTimeHelper.java ---------------------------------------------------------------------- diff --git a/webapp/src/main/java/org/apache/atlas/web/util/DateTimeHelper.java b/webapp/src/main/java/org/apache/atlas/web/util/DateTimeHelper.java index 7dced7e..26f3f1c 100755 --- a/webapp/src/main/java/org/apache/atlas/web/util/DateTimeHelper.java +++ b/webapp/src/main/java/org/apache/atlas/web/util/DateTimeHelper.java @@ -33,8 +33,7 @@ public final class DateTimeHelper { public static final String ISO8601_FORMAT = "yyyy-MM-dd'T'HH:mm'Z'"; private static final String DATE_PATTERN = - "(2\\d\\d\\d|19\\d\\d)-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])T" + - "([0-1][0-9]|2[0-3]):([0-5][0-9])Z"; + "(2\\d\\d\\d|19\\d\\d)-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])T" + "([0-1][0-9]|2[0-3]):([0-5][0-9])Z"; private static final Pattern PATTERN = Pattern.compile(DATE_PATTERN); private DateTimeHelper() { @@ -65,12 +64,10 @@ public final class DateTimeHelper { } } - public static String formatDateUTCToISO8601(final String dateString, - final String dateStringFormat) { + public static String formatDateUTCToISO8601(final String dateString, final String dateStringFormat) { try { - DateFormat dateFormat = new SimpleDateFormat( - dateStringFormat.substring(0, dateString.length())); + DateFormat dateFormat = new SimpleDateFormat(dateStringFormat.substring(0, dateString.length())); dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); return DateTimeHelper.formatDateUTC(dateFormat.parse(dateString)); } catch (ParseException e) { @@ -98,10 +95,8 @@ public final class DateTimeHelper { String month = matcher.group(2); String day = matcher.group(3); - if (day.equals("31") - && (month.equals("4") || month.equals("6") - || month.equals("9") || month.equals("11") - || month.equals("04") || month.equals("06") || month.equals("09"))) { + if (day.equals("31") && (month.equals("4") || month.equals("6") || month.equals("9") || month + .equals("11") || month.equals("04") || month.equals("06") || month.equals("09"))) { return false; // only 1,3,5,7,8,10,12 has 31 days } else if (month.equals("2") || month.equals("02")) { // leap year http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/webapp/src/main/java/org/apache/atlas/web/util/Servlets.java ---------------------------------------------------------------------- diff --git a/webapp/src/main/java/org/apache/atlas/web/util/Servlets.java b/webapp/src/main/java/org/apache/atlas/web/util/Servlets.java index 1713341..3d4c715 100755 --- a/webapp/src/main/java/org/apache/atlas/web/util/Servlets.java +++ b/webapp/src/main/java/org/apache/atlas/web/util/Servlets.java @@ -41,6 +41,7 @@ import java.io.StringWriter; public final class Servlets { private static final Logger LOG = LoggerFactory.getLogger(Servlets.class); + private Servlets() { /* singleton */ } @@ -128,11 +129,7 @@ public final class Servlets { } catch (JSONException jsonE) { LOG.warn("Could not construct error Json rensponse", jsonE); } - return Response - .status(status) - .entity(errorEntity) - .type(JSON_MEDIA_TYPE) - .build(); + return Response.status(status).entity(errorEntity).type(JSON_MEDIA_TYPE).build(); } public static String getRequestPayload(HttpServletRequest request) throws IOException { http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/webapp/src/test/java/org/apache/atlas/CredentialProviderUtilityIT.java ---------------------------------------------------------------------- diff --git a/webapp/src/test/java/org/apache/atlas/CredentialProviderUtilityIT.java b/webapp/src/test/java/org/apache/atlas/CredentialProviderUtilityIT.java index 2bb70d0..dcec28a 100755 --- a/webapp/src/test/java/org/apache/atlas/CredentialProviderUtilityIT.java +++ b/webapp/src/test/java/org/apache/atlas/CredentialProviderUtilityIT.java @@ -56,25 +56,24 @@ public class CredentialProviderUtilityIT { System.out.print(String.format(fmt, params)); } - public String readLine(String fmt, Object ... args) { + public String readLine(String fmt, Object... args) { return finalTestPath.toString(); } @Override - public char[] readPassword(String fmt, Object ... args) { + public char[] readPassword(String fmt, Object... args) { return defaultPass; } }; - CredentialProviderUtility.main(new String[] {}); + CredentialProviderUtility.main(new String[]{}); String providerUrl = JavaKeyStoreProvider.SCHEME_NAME + "://file" + testPath.toUri(); Configuration conf = new Configuration(false); conf.set(CredentialProviderFactory.CREDENTIAL_PROVIDER_PATH, providerUrl); - CredentialProvider provider = - CredentialProviderFactory.getProviders(conf).get(0); + CredentialProvider provider = CredentialProviderFactory.getProviders(conf).get(0); CredentialProvider.CredentialEntry entry = provider.getCredentialEntry(SecurityProperties.KEYSTORE_PASSWORD_KEY); @@ -113,12 +112,12 @@ public class CredentialProviderUtilityIT { System.out.print(String.format(fmt, params)); } - public String readLine(String fmt, Object ... args) { + public String readLine(String fmt, Object... args) { return finalTestPath.toString(); } @Override - public char[] readPassword(String fmt, Object ... args) { + public char[] readPassword(String fmt, Object... args) { List<char[]> responses = new ArrayList<>(); responses.add(new char[0]); responses.add(defaultPass); @@ -129,15 +128,14 @@ public class CredentialProviderUtilityIT { } }; - CredentialProviderUtility.main(new String[] {}); + CredentialProviderUtility.main(new String[]{}); String providerUrl = JavaKeyStoreProvider.SCHEME_NAME + "://file" + testPath.toUri(); Configuration conf = new Configuration(false); conf.set(CredentialProviderFactory.CREDENTIAL_PROVIDER_PATH, providerUrl); - CredentialProvider provider = - CredentialProviderFactory.getProviders(conf).get(0); + CredentialProvider provider = CredentialProviderFactory.getProviders(conf).get(0); CredentialProvider.CredentialEntry entry = provider.getCredentialEntry(SecurityProperties.KEYSTORE_PASSWORD_KEY); @@ -161,20 +159,21 @@ public class CredentialProviderUtilityIT { CredentialProviderUtility.textDevice = new CredentialProviderUtility.TextDevice() { int i = 0; + @Override public void printf(String fmt, Object... params) { System.out.print(String.format(fmt, params)); } - public String readLine(String fmt, Object ... args) { + public String readLine(String fmt, Object... args) { return finalTestPath.toString(); } @Override - public char[] readPassword(String fmt, Object ... args) { + public char[] readPassword(String fmt, Object... args) { List<char[]> responses = new ArrayList<>(); responses.add(defaultPass); - responses.add(new char[] {'b', 'a', 'd', 'p', 'a', 's', 's'}); + responses.add(new char[]{'b', 'a', 'd', 'p', 'a', 's', 's'}); responses.add(defaultPass); int item = i % 3; @@ -183,15 +182,14 @@ public class CredentialProviderUtilityIT { } }; - CredentialProviderUtility.main(new String[] {}); + CredentialProviderUtility.main(new String[]{}); String providerUrl = JavaKeyStoreProvider.SCHEME_NAME + "://file" + testPath.toUri(); Configuration conf = new Configuration(false); conf.set(CredentialProviderFactory.CREDENTIAL_PROVIDER_PATH, providerUrl); - CredentialProvider provider = - CredentialProviderFactory.getProviders(conf).get(0); + CredentialProvider provider = CredentialProviderFactory.getProviders(conf).get(0); CredentialProvider.CredentialEntry entry = provider.getCredentialEntry(SecurityProperties.KEYSTORE_PASSWORD_KEY); @@ -218,17 +216,17 @@ public class CredentialProviderUtilityIT { System.out.print(String.format(fmt, params)); } - public String readLine(String fmt, Object ... args) { + public String readLine(String fmt, Object... args) { return finalTestPath.toString(); } @Override - public char[] readPassword(String fmt, Object ... args) { + public char[] readPassword(String fmt, Object... args) { return defaultPass; } }; - CredentialProviderUtility.main(new String[] {}); + CredentialProviderUtility.main(new String[]{}); // now attempt to overwrite values CredentialProviderUtility.textDevice = new CredentialProviderUtility.TextDevice() { @@ -240,25 +238,24 @@ public class CredentialProviderUtilityIT { System.out.print(String.format(fmt, params)); } - public String readLine(String fmt, Object ... args) { + public String readLine(String fmt, Object... args) { return i++ == 0 ? finalTestPath.toString() : "y"; } @Override - public char[] readPassword(String fmt, Object ... args) { - return new char[] {'n', 'e', 'w', 'p', 'a', 's', 's'}; + public char[] readPassword(String fmt, Object... args) { + return new char[]{'n', 'e', 'w', 'p', 'a', 's', 's'}; } }; - CredentialProviderUtility.main(new String[] {}); + CredentialProviderUtility.main(new String[]{}); String providerUrl = JavaKeyStoreProvider.SCHEME_NAME + "://file" + testPath.toUri(); Configuration conf = new Configuration(false); conf.set(CredentialProviderFactory.CREDENTIAL_PROVIDER_PATH, providerUrl); - CredentialProvider provider = - CredentialProviderFactory.getProviders(conf).get(0); + CredentialProvider provider = CredentialProviderFactory.getProviders(conf).get(0); char[] newpass = "newpass".toCharArray(); CredentialProvider.CredentialEntry entry = http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/webapp/src/test/java/org/apache/atlas/web/filters/MetadataAuthenticationKerberosFilterIT.java ---------------------------------------------------------------------- diff --git a/webapp/src/test/java/org/apache/atlas/web/filters/MetadataAuthenticationKerberosFilterIT.java b/webapp/src/test/java/org/apache/atlas/web/filters/MetadataAuthenticationKerberosFilterIT.java index 5782af7..95acc57 100644 --- a/webapp/src/test/java/org/apache/atlas/web/filters/MetadataAuthenticationKerberosFilterIT.java +++ b/webapp/src/test/java/org/apache/atlas/web/filters/MetadataAuthenticationKerberosFilterIT.java @@ -61,7 +61,7 @@ public class MetadataAuthenticationKerberosFilterIT extends BaseSecurityTest { } } - @Test (enabled = false) + @Test(enabled = false) public void testKerberosBasedLogin() throws Exception { String originalConf = System.getProperty("metadata.conf"); System.setProperty("metadata.conf", System.getProperty("user.dir")); http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/webapp/src/test/java/org/apache/atlas/web/filters/MetadataAuthenticationSimpleFilterIT.java ---------------------------------------------------------------------- diff --git a/webapp/src/test/java/org/apache/atlas/web/filters/MetadataAuthenticationSimpleFilterIT.java b/webapp/src/test/java/org/apache/atlas/web/filters/MetadataAuthenticationSimpleFilterIT.java index aa6f0f9..5ea2e15 100644 --- a/webapp/src/test/java/org/apache/atlas/web/filters/MetadataAuthenticationSimpleFilterIT.java +++ b/webapp/src/test/java/org/apache/atlas/web/filters/MetadataAuthenticationSimpleFilterIT.java @@ -33,7 +33,7 @@ import java.util.Properties; */ public class MetadataAuthenticationSimpleFilterIT extends BaseSecurityTest { - class TestEmbeddedServer extends EmbeddedServer { + class TestEmbeddedServer extends EmbeddedServer { public TestEmbeddedServer(int port, String path) throws IOException { super(port, path); } @@ -43,7 +43,7 @@ public class MetadataAuthenticationSimpleFilterIT extends BaseSecurityTest { } } - @Test (enabled = false) + @Test(enabled = false) public void testSimpleLogin() throws Exception { String originalConf = System.getProperty("metadata.conf"); System.setProperty("metadata.conf", System.getProperty("user.dir")); @@ -55,7 +55,7 @@ public class MetadataAuthenticationSimpleFilterIT extends BaseSecurityTest { startEmbeddedServer(server.getServer()); URL url = new URL("http://localhost:23001"); - HttpURLConnection connection = (HttpURLConnection)url.openConnection(); + HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod("GET"); connection.connect(); @@ -66,7 +66,7 @@ public class MetadataAuthenticationSimpleFilterIT extends BaseSecurityTest { } url = new URL("http://localhost:23001/?user.name=testuser"); - connection = (HttpURLConnection)url.openConnection(); + connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod("GET"); connection.connect(); http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/webapp/src/test/java/org/apache/atlas/web/listeners/LoginProcessorIT.java ---------------------------------------------------------------------- diff --git a/webapp/src/test/java/org/apache/atlas/web/listeners/LoginProcessorIT.java b/webapp/src/test/java/org/apache/atlas/web/listeners/LoginProcessorIT.java index a250bca..54a7a7b 100644 --- a/webapp/src/test/java/org/apache/atlas/web/listeners/LoginProcessorIT.java +++ b/webapp/src/test/java/org/apache/atlas/web/listeners/LoginProcessorIT.java @@ -32,8 +32,7 @@ import java.io.File; */ public class LoginProcessorIT extends BaseSecurityTest { - protected static final String kerberosRule = - "RULE:[1:$1@$0](.*@EXAMPLE.COM)s/@.*//\nDEFAULT"; + protected static final String kerberosRule = "RULE:[1:$1@$0](.*@EXAMPLE.COM)s/@.*//\nDEFAULT"; @Test public void testDefaultSimpleLogin() throws Exception { http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/webapp/src/test/java/org/apache/atlas/web/resources/AdminJerseyResourceIT.java ---------------------------------------------------------------------- diff --git a/webapp/src/test/java/org/apache/atlas/web/resources/AdminJerseyResourceIT.java b/webapp/src/test/java/org/apache/atlas/web/resources/AdminJerseyResourceIT.java index a0410cb..e7af0b2 100755 --- a/webapp/src/test/java/org/apache/atlas/web/resources/AdminJerseyResourceIT.java +++ b/webapp/src/test/java/org/apache/atlas/web/resources/AdminJerseyResourceIT.java @@ -42,28 +42,21 @@ public class AdminJerseyResourceIT extends BaseResourceIT { @Test public void testGetVersion() throws Exception { - WebResource resource = service - .path("api/atlas/admin/version"); + WebResource resource = service.path("api/atlas/admin/version"); - ClientResponse clientResponse = resource - .accept(Servlets.JSON_MEDIA_TYPE) - .type(Servlets.JSON_MEDIA_TYPE) + ClientResponse clientResponse = resource.accept(Servlets.JSON_MEDIA_TYPE).type(Servlets.JSON_MEDIA_TYPE) .method(HttpMethod.GET, ClientResponse.class); Assert.assertEquals(clientResponse.getStatus(), Response.Status.OK.getStatusCode()); String responseAsString = clientResponse.getEntity(String.class); Assert.assertNotNull(responseAsString); - PropertiesConfiguration buildConfiguration = - new PropertiesConfiguration("atlas-buildinfo.properties"); + PropertiesConfiguration buildConfiguration = new PropertiesConfiguration("atlas-buildinfo.properties"); JSONObject response = new JSONObject(responseAsString); - Assert.assertEquals(response.get("Version"), - buildConfiguration.getString("build.version")); - Assert.assertEquals(response.get("Name"), - buildConfiguration.getString("project.name")); - Assert.assertEquals(response.get("Description"), - buildConfiguration.getString("project.description")); + Assert.assertEquals(response.get("Version"), buildConfiguration.getString("build.version")); + Assert.assertEquals(response.get("Name"), buildConfiguration.getString("project.name")); + Assert.assertEquals(response.get("Description"), buildConfiguration.getString("project.description")); } } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/webapp/src/test/java/org/apache/atlas/web/resources/BaseResourceIT.java ---------------------------------------------------------------------- diff --git a/webapp/src/test/java/org/apache/atlas/web/resources/BaseResourceIT.java b/webapp/src/test/java/org/apache/atlas/web/resources/BaseResourceIT.java index a82106f..884d4de 100755 --- a/webapp/src/test/java/org/apache/atlas/web/resources/BaseResourceIT.java +++ b/webapp/src/test/java/org/apache/atlas/web/resources/BaseResourceIT.java @@ -62,19 +62,16 @@ public abstract class BaseResourceIT { protected void createType(TypesDef typesDef) throws Exception { HierarchicalTypeDefinition<ClassType> sampleType = typesDef.classTypesAsJavaList().get(0); - if (serviceClient.getType(sampleType.typeName) == null ) { + if (serviceClient.getType(sampleType.typeName) == null) { String typesAsJSON = TypesSerialization.toJson(typesDef); createType(typesAsJSON); } } protected void createType(String typesAsJSON) throws Exception { - WebResource resource = service - .path("api/atlas/types"); + WebResource resource = service.path("api/atlas/types"); - ClientResponse clientResponse = resource - .accept(Servlets.JSON_MEDIA_TYPE) - .type(Servlets.JSON_MEDIA_TYPE) + ClientResponse clientResponse = resource.accept(Servlets.JSON_MEDIA_TYPE).type(Servlets.JSON_MEDIA_TYPE) .method(HttpMethod.POST, ClientResponse.class, typesAsJSON); Assert.assertEquals(clientResponse.getStatus(), Response.Status.CREATED.getStatusCode()); http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/webapp/src/test/java/org/apache/atlas/web/resources/EntityJerseyResourceIT.java ---------------------------------------------------------------------- diff --git a/webapp/src/test/java/org/apache/atlas/web/resources/EntityJerseyResourceIT.java b/webapp/src/test/java/org/apache/atlas/web/resources/EntityJerseyResourceIT.java index 52fcd81..9e28383 100755 --- a/webapp/src/test/java/org/apache/atlas/web/resources/EntityJerseyResourceIT.java +++ b/webapp/src/test/java/org/apache/atlas/web/resources/EntityJerseyResourceIT.java @@ -98,8 +98,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT { @DataProvider public Object[][] invalidAttrValues() { - return new Object[][]{ - {null}, {""}, {" "}}; + return new Object[][]{{null}, {""}, {" "}}; } @Test(dataProvider = "invalidAttrValues") @@ -111,7 +110,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT { try { createInstance(databaseInstance); Assert.fail("Exptected MetadataServiceException"); - } catch(AtlasServiceException e) { + } catch (AtlasServiceException e) { Assert.assertEquals(e.getStatus(), ClientResponse.Status.BAD_REQUEST); } } @@ -124,8 +123,8 @@ public class EntityJerseyResourceIT extends BaseResourceIT { databaseInstance.set("name", DATABASE_NAME); databaseInstance.set("description", "foo database"); - Referenceable tableInstance = new Referenceable(TABLE_TYPE, - "classification", "pii", "phi", "pci", "sox", "sec", "finance"); + Referenceable tableInstance = + new Referenceable(TABLE_TYPE, "classification", "pii", "phi", "pci", "sox", "sec", "finance"); tableInstance.set("name", TABLE_NAME); tableInstance.set("description", "bar table"); tableInstance.set("date", "2014-07-11"); @@ -151,8 +150,8 @@ public class EntityJerseyResourceIT extends BaseResourceIT { tableId = createInstance(tableInstance); Assert.fail("Was expecting an exception here "); } catch (AtlasServiceException e) { - Assert.assertTrue( - e.getMessage().contains("\"error\":\"Cannot convert value '2014-07-11' to datatype date\"")); + Assert.assertTrue( + e.getMessage().contains("\"error\":\"Cannot convert value '2014-07-11' to datatype date\"")); } } @@ -234,22 +233,15 @@ public class EntityJerseyResourceIT extends BaseResourceIT { } private ClientResponse addProperty(String guid, String property, String value) { - WebResource resource = service - .path("api/atlas/entities") - .path(guid); - - return resource.queryParam("property", property).queryParam("value", value) - .accept(Servlets.JSON_MEDIA_TYPE) - .type(Servlets.JSON_MEDIA_TYPE) - .method(HttpMethod.PUT, ClientResponse.class); + WebResource resource = service.path("api/atlas/entities").path(guid); + + return resource.queryParam("property", property).queryParam("value", value).accept(Servlets.JSON_MEDIA_TYPE) + .type(Servlets.JSON_MEDIA_TYPE).method(HttpMethod.PUT, ClientResponse.class); } private ClientResponse getEntityDefinition(String guid) { - WebResource resource = service - .path("api/atlas/entities") - .path(guid); - return resource.accept(Servlets.JSON_MEDIA_TYPE) - .type(Servlets.JSON_MEDIA_TYPE) + WebResource resource = service.path("api/atlas/entities").path(guid); + return resource.accept(Servlets.JSON_MEDIA_TYPE).type(Servlets.JSON_MEDIA_TYPE) .method(HttpMethod.GET, ClientResponse.class); } @@ -264,13 +256,9 @@ public class EntityJerseyResourceIT extends BaseResourceIT { @Test public void testGetInvalidEntityDefinition() throws Exception { - WebResource resource = service - .path("api/atlas/entities") - .path("blah"); + WebResource resource = service.path("api/atlas/entities").path("blah"); - ClientResponse clientResponse = resource - .accept(Servlets.JSON_MEDIA_TYPE) - .type(Servlets.JSON_MEDIA_TYPE) + ClientResponse clientResponse = resource.accept(Servlets.JSON_MEDIA_TYPE).type(Servlets.JSON_MEDIA_TYPE) .method(HttpMethod.GET, ClientResponse.class); Assert.assertEquals(clientResponse.getStatus(), Response.Status.NOT_FOUND.getStatusCode()); @@ -284,12 +272,9 @@ public class EntityJerseyResourceIT extends BaseResourceIT { @Test(dependsOnMethods = "testSubmitEntity") public void testGetEntityList() throws Exception { - ClientResponse clientResponse = service - .path("api/atlas/entities") - .queryParam("type", TABLE_TYPE) - .accept(Servlets.JSON_MEDIA_TYPE) - .type(Servlets.JSON_MEDIA_TYPE) - .method(HttpMethod.GET, ClientResponse.class); + ClientResponse clientResponse = + service.path("api/atlas/entities").queryParam("type", TABLE_TYPE).accept(Servlets.JSON_MEDIA_TYPE) + .type(Servlets.JSON_MEDIA_TYPE).method(HttpMethod.GET, ClientResponse.class); Assert.assertEquals(clientResponse.getStatus(), Response.Status.OK.getStatusCode()); String responseAsString = clientResponse.getEntity(String.class); @@ -305,12 +290,9 @@ public class EntityJerseyResourceIT extends BaseResourceIT { @Test public void testGetEntityListForBadEntityType() throws Exception { - ClientResponse clientResponse = service - .path("api/atlas/entities") - .queryParam("type", "blah") - .accept(Servlets.JSON_MEDIA_TYPE) - .type(Servlets.JSON_MEDIA_TYPE) - .method(HttpMethod.GET, ClientResponse.class); + ClientResponse clientResponse = + service.path("api/atlas/entities").queryParam("type", "blah").accept(Servlets.JSON_MEDIA_TYPE) + .type(Servlets.JSON_MEDIA_TYPE).method(HttpMethod.GET, ClientResponse.class); Assert.assertEquals(clientResponse.getStatus(), Response.Status.BAD_REQUEST.getStatusCode()); String responseAsString = clientResponse.getEntity(String.class); @@ -326,12 +308,9 @@ public class EntityJerseyResourceIT extends BaseResourceIT { public void testGetEntityListForNoInstances() throws Exception { addNewType(); - ClientResponse clientResponse = service - .path("api/atlas/entities") - .queryParam("type", "test") - .accept(Servlets.JSON_MEDIA_TYPE) - .type(Servlets.JSON_MEDIA_TYPE) - .method(HttpMethod.GET, ClientResponse.class); + ClientResponse clientResponse = + service.path("api/atlas/entities").queryParam("type", "test").accept(Servlets.JSON_MEDIA_TYPE) + .type(Servlets.JSON_MEDIA_TYPE).method(HttpMethod.GET, ClientResponse.class); Assert.assertEquals(clientResponse.getStatus(), Response.Status.OK.getStatusCode()); String responseAsString = clientResponse.getEntity(String.class); @@ -345,8 +324,8 @@ public class EntityJerseyResourceIT extends BaseResourceIT { } private void addNewType() throws Exception { - HierarchicalTypeDefinition<ClassType> testTypeDefinition = - TypesUtil.createClassTypeDef("test", ImmutableList.<String>of(), + HierarchicalTypeDefinition<ClassType> testTypeDefinition = TypesUtil + .createClassTypeDef("test", ImmutableList.<String>of(), TypesUtil.createRequiredAttrDef("name", DataTypes.STRING_TYPE), TypesUtil.createRequiredAttrDef("description", DataTypes.STRING_TYPE)); @@ -357,13 +336,9 @@ public class EntityJerseyResourceIT extends BaseResourceIT { @Test(dependsOnMethods = "testSubmitEntity") public void testGetTraitNames() throws Exception { final String guid = tableId._getId(); - ClientResponse clientResponse = service - .path("api/atlas/entities") - .path(guid) - .path(TRAITS) - .accept(Servlets.JSON_MEDIA_TYPE) - .type(Servlets.JSON_MEDIA_TYPE) - .method(HttpMethod.GET, ClientResponse.class); + ClientResponse clientResponse = + service.path("api/atlas/entities").path(guid).path(TRAITS).accept(Servlets.JSON_MEDIA_TYPE) + .type(Servlets.JSON_MEDIA_TYPE).method(HttpMethod.GET, ClientResponse.class); Assert.assertEquals(clientResponse.getStatus(), Response.Status.OK.getStatusCode()); String responseAsString = clientResponse.getEntity(String.class); @@ -391,13 +366,10 @@ public class EntityJerseyResourceIT extends BaseResourceIT { LOG.debug("traitInstanceAsJSON = " + traitInstanceAsJSON); final String guid = tableId._getId(); - ClientResponse clientResponse = service - .path("api/atlas/entities") - .path(guid) - .path(TRAITS) - .accept(Servlets.JSON_MEDIA_TYPE) - .type(Servlets.JSON_MEDIA_TYPE) - .method(HttpMethod.POST, ClientResponse.class, traitInstanceAsJSON); + ClientResponse clientResponse = + service.path("api/atlas/entities").path(guid).path(TRAITS).accept(Servlets.JSON_MEDIA_TYPE) + .type(Servlets.JSON_MEDIA_TYPE) + .method(HttpMethod.POST, ClientResponse.class, traitInstanceAsJSON); Assert.assertEquals(clientResponse.getStatus(), Response.Status.CREATED.getStatusCode()); String responseAsString = clientResponse.getEntity(String.class); @@ -417,21 +389,18 @@ public class EntityJerseyResourceIT extends BaseResourceIT { LOG.debug("traitInstanceAsJSON = " + traitInstanceAsJSON); final String guid = tableId._getId(); - ClientResponse clientResponse = service - .path("api/atlas/entities") - .path(guid) - .path(TRAITS) - .accept(Servlets.JSON_MEDIA_TYPE) - .type(Servlets.JSON_MEDIA_TYPE) - .method(HttpMethod.POST, ClientResponse.class, traitInstanceAsJSON); + ClientResponse clientResponse = + service.path("api/atlas/entities").path(guid).path(TRAITS).accept(Servlets.JSON_MEDIA_TYPE) + .type(Servlets.JSON_MEDIA_TYPE) + .method(HttpMethod.POST, ClientResponse.class, traitInstanceAsJSON); Assert.assertEquals(clientResponse.getStatus(), Response.Status.NOT_FOUND.getStatusCode()); } @Test(dependsOnMethods = "testGetTraitNames") public void testAddTraitWithAttribute() throws Exception { final String traitName = "PII_Trait" + randomString(); - HierarchicalTypeDefinition<TraitType> piiTrait = - TypesUtil.createTraitTypeDef(traitName, ImmutableList.<String>of(), + HierarchicalTypeDefinition<TraitType> piiTrait = TypesUtil + .createTraitTypeDef(traitName, ImmutableList.<String>of(), TypesUtil.createRequiredAttrDef("type", DataTypes.STRING_TYPE)); String traitDefinitionAsJSON = TypesSerialization$.MODULE$.toJson(piiTrait, true); LOG.debug("traitDefinitionAsJSON = " + traitDefinitionAsJSON); @@ -443,13 +412,10 @@ public class EntityJerseyResourceIT extends BaseResourceIT { LOG.debug("traitInstanceAsJSON = " + traitInstanceAsJSON); final String guid = tableId._getId(); - ClientResponse clientResponse = service - .path("api/atlas/entities") - .path(guid) - .path(TRAITS) - .accept(Servlets.JSON_MEDIA_TYPE) - .type(Servlets.JSON_MEDIA_TYPE) - .method(HttpMethod.POST, ClientResponse.class, traitInstanceAsJSON); + ClientResponse clientResponse = + service.path("api/atlas/entities").path(guid).path(TRAITS).accept(Servlets.JSON_MEDIA_TYPE) + .type(Servlets.JSON_MEDIA_TYPE) + .method(HttpMethod.POST, ClientResponse.class, traitInstanceAsJSON); Assert.assertEquals(clientResponse.getStatus(), Response.Status.CREATED.getStatusCode()); String responseAsString = clientResponse.getEntity(String.class); @@ -487,13 +453,10 @@ public class EntityJerseyResourceIT extends BaseResourceIT { String traitInstanceAsJSON = InstanceSerialization$.MODULE$.toJson(traitInstance, true); LOG.debug("traitInstanceAsJSON = " + traitInstanceAsJSON); - ClientResponse clientResponse = service - .path("api/atlas/entities") - .path("random") - .path(TRAITS) - .accept(Servlets.JSON_MEDIA_TYPE) - .type(Servlets.JSON_MEDIA_TYPE) - .method(HttpMethod.POST, ClientResponse.class, traitInstanceAsJSON); + ClientResponse clientResponse = + service.path("api/atlas/entities").path("random").path(TRAITS).accept(Servlets.JSON_MEDIA_TYPE) + .type(Servlets.JSON_MEDIA_TYPE) + .method(HttpMethod.POST, ClientResponse.class, traitInstanceAsJSON); Assert.assertEquals(clientResponse.getStatus(), Response.Status.NOT_FOUND.getStatusCode()); } @@ -501,13 +464,8 @@ public class EntityJerseyResourceIT extends BaseResourceIT { public void testDeleteTrait() throws Exception { final String guid = tableId._getId(); - ClientResponse clientResponse = service - .path("api/atlas/entities") - .path(guid) - .path(TRAITS) - .path(traitName) - .accept(Servlets.JSON_MEDIA_TYPE) - .type(Servlets.JSON_MEDIA_TYPE) + ClientResponse clientResponse = service.path("api/atlas/entities").path(guid).path(TRAITS).path(traitName) + .accept(Servlets.JSON_MEDIA_TYPE).type(Servlets.JSON_MEDIA_TYPE) .method(HttpMethod.DELETE, ClientResponse.class); Assert.assertEquals(clientResponse.getStatus(), Response.Status.OK.getStatusCode()); @@ -524,13 +482,8 @@ public class EntityJerseyResourceIT extends BaseResourceIT { public void testDeleteTraitNonExistent() throws Exception { final String traitName = "blah_trait"; - ClientResponse clientResponse = service - .path("api/atlas/entities") - .path("random") - .path(TRAITS) - .path(traitName) - .accept(Servlets.JSON_MEDIA_TYPE) - .type(Servlets.JSON_MEDIA_TYPE) + ClientResponse clientResponse = service.path("api/atlas/entities").path("random").path(TRAITS).path(traitName) + .accept(Servlets.JSON_MEDIA_TYPE).type(Servlets.JSON_MEDIA_TYPE) .method(HttpMethod.DELETE, ClientResponse.class); Assert.assertEquals(clientResponse.getStatus(), Response.Status.NOT_FOUND.getStatusCode()); @@ -558,12 +511,13 @@ public class EntityJerseyResourceIT extends BaseResourceIT { String attrName = random(); String attrValue = random(); - HierarchicalTypeDefinition<ClassType> classTypeDefinition = - TypesUtil.createClassTypeDef(classType, ImmutableList.<String>of(), + HierarchicalTypeDefinition<ClassType> classTypeDefinition = TypesUtil + .createClassTypeDef(classType, ImmutableList.<String>of(), TypesUtil.createUniqueRequiredAttrDef(attrName, DataTypes.STRING_TYPE)); - TypesDef typesDef = TypeUtils.getTypesDef(ImmutableList.<EnumTypeDefinition>of(), - ImmutableList.<StructTypeDefinition>of(), ImmutableList.<HierarchicalTypeDefinition<TraitType>>of(), - ImmutableList.of(classTypeDefinition)); + TypesDef typesDef = TypeUtils + .getTypesDef(ImmutableList.<EnumTypeDefinition>of(), ImmutableList.<StructTypeDefinition>of(), + ImmutableList.<HierarchicalTypeDefinition<TraitType>>of(), + ImmutableList.of(classTypeDefinition)); createType(typesDef); Referenceable instance = new Referenceable(classType); @@ -577,48 +531,35 @@ public class EntityJerseyResourceIT extends BaseResourceIT { } private void createHiveTypes() throws Exception { - HierarchicalTypeDefinition<ClassType> databaseTypeDefinition = - TypesUtil.createClassTypeDef(DATABASE_TYPE, - ImmutableList.<String>of(), + HierarchicalTypeDefinition<ClassType> databaseTypeDefinition = TypesUtil + .createClassTypeDef(DATABASE_TYPE, ImmutableList.<String>of(), TypesUtil.createUniqueRequiredAttrDef("name", DataTypes.STRING_TYPE), TypesUtil.createRequiredAttrDef("description", DataTypes.STRING_TYPE)); - StructTypeDefinition structTypeDefinition = - new StructTypeDefinition("serdeType", - new AttributeDefinition[]{ - TypesUtil.createRequiredAttrDef("name", DataTypes.STRING_TYPE), - TypesUtil.createRequiredAttrDef("serde", DataTypes.STRING_TYPE) - }); + StructTypeDefinition structTypeDefinition = new StructTypeDefinition("serdeType", + new AttributeDefinition[]{TypesUtil.createRequiredAttrDef("name", DataTypes.STRING_TYPE), + TypesUtil.createRequiredAttrDef("serde", DataTypes.STRING_TYPE)}); - EnumValue values[] = { - new EnumValue("MANAGED", 1), - new EnumValue("EXTERNAL", 2), - }; + EnumValue values[] = {new EnumValue("MANAGED", 1), new EnumValue("EXTERNAL", 2),}; EnumTypeDefinition enumTypeDefinition = new EnumTypeDefinition("tableType", values); - HierarchicalTypeDefinition<ClassType> tableTypeDefinition = - TypesUtil.createClassTypeDef(TABLE_TYPE, - ImmutableList.<String>of(), + HierarchicalTypeDefinition<ClassType> tableTypeDefinition = TypesUtil + .createClassTypeDef(TABLE_TYPE, ImmutableList.<String>of(), TypesUtil.createUniqueRequiredAttrDef("name", DataTypes.STRING_TYPE), TypesUtil.createOptionalAttrDef("description", DataTypes.STRING_TYPE), TypesUtil.createRequiredAttrDef("type", DataTypes.STRING_TYPE), TypesUtil.createRequiredAttrDef("date", DataTypes.DATE_TYPE), TypesUtil.createRequiredAttrDef("level", DataTypes.INT_TYPE), - new AttributeDefinition("tableType", "tableType", - Multiplicity.REQUIRED, false, null), - new AttributeDefinition("serde1", - "serdeType", Multiplicity.REQUIRED, false, null), - new AttributeDefinition("serde2", - "serdeType", Multiplicity.REQUIRED, false, null), - new AttributeDefinition("database", - DATABASE_TYPE, Multiplicity.REQUIRED, true, null), - new AttributeDefinition("compressed", - DataTypes.BOOLEAN_TYPE.getName(), Multiplicity.OPTIONAL, true, null)); - - HierarchicalTypeDefinition<TraitType> classificationTraitDefinition = - TypesUtil.createTraitTypeDef("classification", - ImmutableList.<String>of(), + new AttributeDefinition("tableType", "tableType", Multiplicity.REQUIRED, false, null), + new AttributeDefinition("serde1", "serdeType", Multiplicity.REQUIRED, false, null), + new AttributeDefinition("serde2", "serdeType", Multiplicity.REQUIRED, false, null), + new AttributeDefinition("database", DATABASE_TYPE, Multiplicity.REQUIRED, true, null), + new AttributeDefinition("compressed", DataTypes.BOOLEAN_TYPE.getName(), Multiplicity.OPTIONAL, + true, null)); + + HierarchicalTypeDefinition<TraitType> classificationTraitDefinition = TypesUtil + .createTraitTypeDef("classification", ImmutableList.<String>of(), TypesUtil.createRequiredAttrDef("tag", DataTypes.STRING_TYPE)); HierarchicalTypeDefinition<TraitType> piiTrait = TypesUtil.createTraitTypeDef("pii", ImmutableList.<String>of()); @@ -633,12 +574,10 @@ public class EntityJerseyResourceIT extends BaseResourceIT { HierarchicalTypeDefinition<TraitType> financeTrait = TypesUtil.createTraitTypeDef("finance", ImmutableList.<String>of()); - TypesDef typesDef = TypeUtils.getTypesDef( - ImmutableList.of(enumTypeDefinition), - ImmutableList.of(structTypeDefinition), - ImmutableList.of(classificationTraitDefinition, piiTrait, phiTrait, pciTrait, - soxTrait, secTrait, financeTrait), - ImmutableList.of(databaseTypeDefinition, tableTypeDefinition)); + TypesDef typesDef = TypeUtils + .getTypesDef(ImmutableList.of(enumTypeDefinition), ImmutableList.of(structTypeDefinition), ImmutableList + .of(classificationTraitDefinition, piiTrait, phiTrait, pciTrait, soxTrait, secTrait, + financeTrait), ImmutableList.of(databaseTypeDefinition, tableTypeDefinition)); createType(typesDef); } @@ -647,8 +586,8 @@ public class EntityJerseyResourceIT extends BaseResourceIT { databaseInstance.set("name", DATABASE_NAME); databaseInstance.set("description", "foo database"); - Referenceable tableInstance = new Referenceable(TABLE_TYPE, - "classification", "pii", "phi", "pci", "sox", "sec", "finance"); + Referenceable tableInstance = + new Referenceable(TABLE_TYPE, "classification", "pii", "phi", "pci", "sox", "sec", "finance"); tableInstance.set("name", TABLE_NAME); tableInstance.set("description", "bar table"); tableInstance.set("date", "2014-07-11T08:00:00.000Z"); http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/webapp/src/test/java/org/apache/atlas/web/resources/HiveLineageJerseyResourceIT.java ---------------------------------------------------------------------- diff --git a/webapp/src/test/java/org/apache/atlas/web/resources/HiveLineageJerseyResourceIT.java b/webapp/src/test/java/org/apache/atlas/web/resources/HiveLineageJerseyResourceIT.java index eb8d1be..a884b5f 100644 --- a/webapp/src/test/java/org/apache/atlas/web/resources/HiveLineageJerseyResourceIT.java +++ b/webapp/src/test/java/org/apache/atlas/web/resources/HiveLineageJerseyResourceIT.java @@ -65,15 +65,9 @@ public class HiveLineageJerseyResourceIT extends BaseResourceIT { @Test public void testInputsGraph() throws Exception { - WebResource resource = service - .path(BASE_URI) - .path("sales_fact_monthly_mv") - .path("inputs") - .path("graph"); - - ClientResponse clientResponse = resource - .accept(Servlets.JSON_MEDIA_TYPE) - .type(Servlets.JSON_MEDIA_TYPE) + WebResource resource = service.path(BASE_URI).path("sales_fact_monthly_mv").path("inputs").path("graph"); + + ClientResponse clientResponse = resource.accept(Servlets.JSON_MEDIA_TYPE).type(Servlets.JSON_MEDIA_TYPE) .method(HttpMethod.GET, ClientResponse.class); Assert.assertEquals(clientResponse.getStatus(), Response.Status.OK.getStatusCode()); @@ -99,15 +93,9 @@ public class HiveLineageJerseyResourceIT extends BaseResourceIT { @Test public void testOutputsGraph() throws Exception { - WebResource resource = service - .path(BASE_URI) - .path("sales_fact") - .path("outputs") - .path("graph"); - - ClientResponse clientResponse = resource - .accept(Servlets.JSON_MEDIA_TYPE) - .type(Servlets.JSON_MEDIA_TYPE) + WebResource resource = service.path(BASE_URI).path("sales_fact").path("outputs").path("graph"); + + ClientResponse clientResponse = resource.accept(Servlets.JSON_MEDIA_TYPE).type(Servlets.JSON_MEDIA_TYPE) .method(HttpMethod.GET, ClientResponse.class); Assert.assertEquals(clientResponse.getStatus(), Response.Status.OK.getStatusCode()); @@ -133,14 +121,9 @@ public class HiveLineageJerseyResourceIT extends BaseResourceIT { @Test public void testSchema() throws Exception { - WebResource resource = service - .path(BASE_URI) - .path("sales_fact") - .path("schema"); - - ClientResponse clientResponse = resource - .accept(Servlets.JSON_MEDIA_TYPE) - .type(Servlets.JSON_MEDIA_TYPE) + WebResource resource = service.path(BASE_URI).path("sales_fact").path("schema"); + + ClientResponse clientResponse = resource.accept(Servlets.JSON_MEDIA_TYPE).type(Servlets.JSON_MEDIA_TYPE) .method(HttpMethod.GET, ClientResponse.class); Assert.assertEquals(clientResponse.getStatus(), Response.Status.OK.getStatusCode()); @@ -168,32 +151,20 @@ public class HiveLineageJerseyResourceIT extends BaseResourceIT { @Test public void testSchemaForEmptyTable() throws Exception { - WebResource resource = service - .path(BASE_URI) - .path("") - .path("schema"); - - ClientResponse clientResponse = resource - .accept(Servlets.JSON_MEDIA_TYPE) - .type(Servlets.JSON_MEDIA_TYPE) + WebResource resource = service.path(BASE_URI).path("").path("schema"); + + ClientResponse clientResponse = resource.accept(Servlets.JSON_MEDIA_TYPE).type(Servlets.JSON_MEDIA_TYPE) .method(HttpMethod.GET, ClientResponse.class); - Assert.assertEquals(clientResponse.getStatus(), - Response.Status.NOT_FOUND.getStatusCode()); + Assert.assertEquals(clientResponse.getStatus(), Response.Status.NOT_FOUND.getStatusCode()); } @Test public void testSchemaForInvalidTable() throws Exception { - WebResource resource = service - .path(BASE_URI) - .path("blah") - .path("schema"); - - ClientResponse clientResponse = resource - .accept(Servlets.JSON_MEDIA_TYPE) - .type(Servlets.JSON_MEDIA_TYPE) + WebResource resource = service.path(BASE_URI).path("blah").path("schema"); + + ClientResponse clientResponse = resource.accept(Servlets.JSON_MEDIA_TYPE).type(Servlets.JSON_MEDIA_TYPE) .method(HttpMethod.GET, ClientResponse.class); - Assert.assertEquals(clientResponse.getStatus(), - Response.Status.NOT_FOUND.getStatusCode()); + Assert.assertEquals(clientResponse.getStatus(), Response.Status.NOT_FOUND.getStatusCode()); } private void setUpTypes() throws Exception { @@ -207,69 +178,47 @@ public class HiveLineageJerseyResourceIT extends BaseResourceIT { private static final String HIVE_PROCESS_TYPE = "hive_process"; private TypesDef createTypeDefinitions() { - HierarchicalTypeDefinition<ClassType> dbClsDef - = TypesUtil.createClassTypeDef(DATABASE_TYPE, null, - attrDef("name", DataTypes.STRING_TYPE), - attrDef("description", DataTypes.STRING_TYPE), - attrDef("locationUri", DataTypes.STRING_TYPE), - attrDef("owner", DataTypes.STRING_TYPE), - attrDef("createTime", DataTypes.INT_TYPE) - ); - - HierarchicalTypeDefinition<ClassType> columnClsDef = - TypesUtil.createClassTypeDef(COLUMN_TYPE, null, - attrDef("name", DataTypes.STRING_TYPE), - attrDef("dataType", DataTypes.STRING_TYPE), - attrDef("comment", DataTypes.STRING_TYPE) - ); - - HierarchicalTypeDefinition<ClassType> tblClsDef = - TypesUtil.createClassTypeDef(HIVE_TABLE_TYPE, ImmutableList.of("DataSet"), - attrDef("owner", DataTypes.STRING_TYPE), - attrDef("createTime", DataTypes.INT_TYPE), - attrDef("lastAccessTime", DataTypes.INT_TYPE), - attrDef("tableType", DataTypes.STRING_TYPE), + HierarchicalTypeDefinition<ClassType> dbClsDef = TypesUtil + .createClassTypeDef(DATABASE_TYPE, null, attrDef("name", DataTypes.STRING_TYPE), + attrDef("description", DataTypes.STRING_TYPE), attrDef("locationUri", DataTypes.STRING_TYPE), + attrDef("owner", DataTypes.STRING_TYPE), attrDef("createTime", DataTypes.INT_TYPE)); + + HierarchicalTypeDefinition<ClassType> columnClsDef = TypesUtil + .createClassTypeDef(COLUMN_TYPE, null, attrDef("name", DataTypes.STRING_TYPE), + attrDef("dataType", DataTypes.STRING_TYPE), attrDef("comment", DataTypes.STRING_TYPE)); + + HierarchicalTypeDefinition<ClassType> tblClsDef = TypesUtil + .createClassTypeDef(HIVE_TABLE_TYPE, ImmutableList.of("DataSet"), + attrDef("owner", DataTypes.STRING_TYPE), attrDef("createTime", DataTypes.INT_TYPE), + attrDef("lastAccessTime", DataTypes.INT_TYPE), attrDef("tableType", DataTypes.STRING_TYPE), attrDef("temporary", DataTypes.BOOLEAN_TYPE), - new AttributeDefinition("db", DATABASE_TYPE, - Multiplicity.REQUIRED, false, null), - new AttributeDefinition("columns", - DataTypes.arrayTypeName(COLUMN_TYPE), - Multiplicity.COLLECTION, true, null) - ); - - HierarchicalTypeDefinition<ClassType> loadProcessClsDef = - TypesUtil.createClassTypeDef(HIVE_PROCESS_TYPE, ImmutableList.of("Process"), - attrDef("userName", DataTypes.STRING_TYPE), - attrDef("startTime", DataTypes.INT_TYPE), + new AttributeDefinition("db", DATABASE_TYPE, Multiplicity.REQUIRED, false, null), + new AttributeDefinition("columns", DataTypes.arrayTypeName(COLUMN_TYPE), + Multiplicity.COLLECTION, true, null)); + + HierarchicalTypeDefinition<ClassType> loadProcessClsDef = TypesUtil + .createClassTypeDef(HIVE_PROCESS_TYPE, ImmutableList.of("Process"), + attrDef("userName", DataTypes.STRING_TYPE), attrDef("startTime", DataTypes.INT_TYPE), attrDef("endTime", DataTypes.INT_TYPE), attrDef("queryText", DataTypes.STRING_TYPE, Multiplicity.REQUIRED), attrDef("queryPlan", DataTypes.STRING_TYPE, Multiplicity.REQUIRED), attrDef("queryId", DataTypes.STRING_TYPE, Multiplicity.REQUIRED), - attrDef("queryGraph", DataTypes.STRING_TYPE, Multiplicity.REQUIRED) - ); + attrDef("queryGraph", DataTypes.STRING_TYPE, Multiplicity.REQUIRED)); - HierarchicalTypeDefinition<TraitType> dimTraitDef = - TypesUtil.createTraitTypeDef("Dimension", null); + HierarchicalTypeDefinition<TraitType> dimTraitDef = TypesUtil.createTraitTypeDef("Dimension", null); - HierarchicalTypeDefinition<TraitType> factTraitDef = - TypesUtil.createTraitTypeDef("Fact", null); + HierarchicalTypeDefinition<TraitType> factTraitDef = TypesUtil.createTraitTypeDef("Fact", null); - HierarchicalTypeDefinition<TraitType> metricTraitDef = - TypesUtil.createTraitTypeDef("Metric", null); + HierarchicalTypeDefinition<TraitType> metricTraitDef = TypesUtil.createTraitTypeDef("Metric", null); - HierarchicalTypeDefinition<TraitType> etlTraitDef = - TypesUtil.createTraitTypeDef("ETL", null); + HierarchicalTypeDefinition<TraitType> etlTraitDef = TypesUtil.createTraitTypeDef("ETL", null); - HierarchicalTypeDefinition<TraitType> piiTraitDef = - TypesUtil.createTraitTypeDef("PII", null); + HierarchicalTypeDefinition<TraitType> piiTraitDef = TypesUtil.createTraitTypeDef("PII", null); - return TypeUtils.getTypesDef( - ImmutableList.<EnumTypeDefinition>of(), - ImmutableList.<StructTypeDefinition>of(), + return TypeUtils.getTypesDef(ImmutableList.<EnumTypeDefinition>of(), ImmutableList.<StructTypeDefinition>of(), ImmutableList.of(dimTraitDef, factTraitDef, metricTraitDef, etlTraitDef, piiTraitDef), - ImmutableList.of(dbClsDef, columnClsDef, tblClsDef, loadProcessClsDef) - ); + ImmutableList.of(dbClsDef, columnClsDef, tblClsDef, loadProcessClsDef)); } AttributeDefinition attrDef(String name, IDataType dT) { @@ -280,8 +229,8 @@ public class HiveLineageJerseyResourceIT extends BaseResourceIT { return attrDef(name, dT, m, false, null); } - AttributeDefinition attrDef(String name, IDataType dT, - Multiplicity m, boolean isComposite, String reverseAttributeName) { + AttributeDefinition attrDef(String name, IDataType dT, Multiplicity m, boolean isComposite, + String reverseAttributeName) { Preconditions.checkNotNull(name); Preconditions.checkNotNull(dT); return new AttributeDefinition(name, dT.getName(), m, isComposite, reverseAttributeName); @@ -290,43 +239,40 @@ public class HiveLineageJerseyResourceIT extends BaseResourceIT { private void setupInstances() throws Exception { Id salesDB = database("Sales", "Sales Database", "John ETL", "hdfs://host:8000/apps/warehouse/sales"); - List<Referenceable> salesFactColumns = ImmutableList.of(column("time_id", "int", "time id"), - column("product_id", "int", "product id"), column("customer_id", "int", "customer id", "PII"), - column("sales", "double", "product id", "Metric")); + List<Referenceable> salesFactColumns = ImmutableList + .of(column("time_id", "int", "time id"), column("product_id", "int", "product id"), + column("customer_id", "int", "customer id", "PII"), + column("sales", "double", "product id", "Metric")); Id salesFact = table("sales_fact", "sales fact table", salesDB, "Joe", "Managed", salesFactColumns, "Fact"); - List<Referenceable> timeDimColumns = ImmutableList.of(column("time_id", "int", "time id"), - column("dayOfYear", "int", "day Of Year"), column("weekDay", "int", "week Day")); + List<Referenceable> timeDimColumns = ImmutableList + .of(column("time_id", "int", "time id"), column("dayOfYear", "int", "day Of Year"), + column("weekDay", "int", "week Day")); - Id timeDim = table("time_dim", "time dimension table", salesDB, "John Doe", "External", timeDimColumns, - "Dimension"); + Id timeDim = + table("time_dim", "time dimension table", salesDB, "John Doe", "External", timeDimColumns, "Dimension"); - Id reportingDB = database("Reporting", "reporting database", "Jane BI", - "hdfs://host:8000/apps/warehouse/reporting"); + Id reportingDB = + database("Reporting", "reporting database", "Jane BI", "hdfs://host:8000/apps/warehouse/reporting"); - Id salesFactDaily = table("sales_fact_daily_mv", - "sales fact daily materialized view", - reportingDB, "Joe BI", "Managed", salesFactColumns, "Metric"); + Id salesFactDaily = + table("sales_fact_daily_mv", "sales fact daily materialized view", reportingDB, "Joe BI", "Managed", + salesFactColumns, "Metric"); - loadProcess("loadSalesDaily", "John ETL", - ImmutableList.of(salesFact, timeDim), ImmutableList.of(salesFactDaily), - "create table as select ", "plan", "id", "graph", - "ETL"); + loadProcess("loadSalesDaily", "John ETL", ImmutableList.of(salesFact, timeDim), + ImmutableList.of(salesFactDaily), "create table as select ", "plan", "id", "graph", "ETL"); - Id salesFactMonthly = table("sales_fact_monthly_mv", - "sales fact monthly materialized view", - reportingDB, "Jane BI", "Managed", salesFactColumns, "Metric"); + Id salesFactMonthly = + table("sales_fact_monthly_mv", "sales fact monthly materialized view", reportingDB, "Jane BI", + "Managed", salesFactColumns, "Metric"); - loadProcess("loadSalesMonthly", "John ETL", - ImmutableList.of(salesFactDaily), ImmutableList.of(salesFactMonthly), - "create table as select ", "plan", "id", "graph", - "ETL"); + loadProcess("loadSalesMonthly", "John ETL", ImmutableList.of(salesFactDaily), + ImmutableList.of(salesFactMonthly), "create table as select ", "plan", "id", "graph", "ETL"); } - Id database(String name, String description, - String owner, String locationUri, - String... traitNames) throws Exception { + Id database(String name, String description, String owner, String locationUri, String... traitNames) + throws Exception { Referenceable referenceable = new Referenceable(DATABASE_TYPE, traitNames); referenceable.set("name", name); referenceable.set("description", description); @@ -337,8 +283,7 @@ public class HiveLineageJerseyResourceIT extends BaseResourceIT { return createInstance(referenceable); } - Referenceable column(String name, String dataType, String comment, - String... traitNames) throws Exception { + Referenceable column(String name, String dataType, String comment, String... traitNames) throws Exception { Referenceable referenceable = new Referenceable(COLUMN_TYPE, traitNames); referenceable.set("name", name); referenceable.set("dataType", dataType); @@ -347,10 +292,8 @@ public class HiveLineageJerseyResourceIT extends BaseResourceIT { return referenceable; } - Id table(String name, String description, Id dbId, - String owner, String tableType, - List<Referenceable> columns, - String... traitNames) throws Exception { + Id table(String name, String description, Id dbId, String owner, String tableType, List<Referenceable> columns, + String... traitNames) throws Exception { Referenceable referenceable = new Referenceable(HIVE_TABLE_TYPE, traitNames); referenceable.set("name", name); referenceable.set("description", description); @@ -366,12 +309,8 @@ public class HiveLineageJerseyResourceIT extends BaseResourceIT { return createInstance(referenceable); } - Id loadProcess(String name, String user, - List<Id> inputTables, - List<Id> outputTables, - String queryText, String queryPlan, - String queryId, String queryGraph, - String... traitNames) throws Exception { + Id loadProcess(String name, String user, List<Id> inputTables, List<Id> outputTables, String queryText, + String queryPlan, String queryId, String queryGraph, String... traitNames) throws Exception { Referenceable referenceable = new Referenceable(HIVE_PROCESS_TYPE, traitNames); referenceable.set("name", name); referenceable.set("user", user); http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/webapp/src/test/java/org/apache/atlas/web/resources/MetadataDiscoveryJerseyResourceIT.java ---------------------------------------------------------------------- diff --git a/webapp/src/test/java/org/apache/atlas/web/resources/MetadataDiscoveryJerseyResourceIT.java b/webapp/src/test/java/org/apache/atlas/web/resources/MetadataDiscoveryJerseyResourceIT.java index 0af5aa2..d7c3703 100755 --- a/webapp/src/test/java/org/apache/atlas/web/resources/MetadataDiscoveryJerseyResourceIT.java +++ b/webapp/src/test/java/org/apache/atlas/web/resources/MetadataDiscoveryJerseyResourceIT.java @@ -61,13 +61,9 @@ public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT { @Test public void testSearchByDSL() throws Exception { String dslQuery = "from dsl_test_type"; - WebResource resource = service - .path("api/atlas/discovery/search/dsl") - .queryParam("query", dslQuery); + WebResource resource = service.path("api/atlas/discovery/search/dsl").queryParam("query", dslQuery); - ClientResponse clientResponse = resource - .accept(Servlets.JSON_MEDIA_TYPE) - .type(Servlets.JSON_MEDIA_TYPE) + ClientResponse clientResponse = resource.accept(Servlets.JSON_MEDIA_TYPE).type(Servlets.JSON_MEDIA_TYPE) .method(HttpMethod.GET, ClientResponse.class); Assert.assertEquals(clientResponse.getStatus(), Response.Status.OK.getStatusCode()); @@ -94,28 +90,19 @@ public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT { @Test public void testSearchByDSLForUnknownType() throws Exception { String dslQuery = "from blah"; - WebResource resource = service - .path("api/atlas/discovery/search/dsl") - .queryParam("query", dslQuery); + WebResource resource = service.path("api/atlas/discovery/search/dsl").queryParam("query", dslQuery); - ClientResponse clientResponse = resource - .accept(Servlets.JSON_MEDIA_TYPE) - .type(Servlets.JSON_MEDIA_TYPE) + ClientResponse clientResponse = resource.accept(Servlets.JSON_MEDIA_TYPE).type(Servlets.JSON_MEDIA_TYPE) .method(HttpMethod.GET, ClientResponse.class); - Assert.assertEquals(clientResponse.getStatus(), - Response.Status.BAD_REQUEST.getStatusCode()); + Assert.assertEquals(clientResponse.getStatus(), Response.Status.BAD_REQUEST.getStatusCode()); } @Test public void testSearchUsingGremlin() throws Exception { String query = "g.V.has('type', 'dsl_test_type').toList()"; - WebResource resource = service - .path("api/atlas/discovery/search") - .queryParam("query", query); + WebResource resource = service.path("api/atlas/discovery/search").queryParam("query", query); - ClientResponse clientResponse = resource - .accept(Servlets.JSON_MEDIA_TYPE) - .type(Servlets.JSON_MEDIA_TYPE) + ClientResponse clientResponse = resource.accept(Servlets.JSON_MEDIA_TYPE).type(Servlets.JSON_MEDIA_TYPE) .method(HttpMethod.GET, ClientResponse.class); Assert.assertEquals(clientResponse.getStatus(), Response.Status.OK.getStatusCode()); @@ -132,13 +119,9 @@ public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT { @Test public void testSearchUsingDSL() throws Exception { String query = "from dsl_test_type"; - WebResource resource = service - .path("api/atlas/discovery/search") - .queryParam("query", query); + WebResource resource = service.path("api/atlas/discovery/search").queryParam("query", query); - ClientResponse clientResponse = resource - .accept(Servlets.JSON_MEDIA_TYPE) - .type(Servlets.JSON_MEDIA_TYPE) + ClientResponse clientResponse = resource.accept(Servlets.JSON_MEDIA_TYPE).type(Servlets.JSON_MEDIA_TYPE) .method(HttpMethod.GET, ClientResponse.class); Assert.assertEquals(clientResponse.getStatus(), Response.Status.OK.getStatusCode()); @@ -174,15 +157,13 @@ public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT { } private void createTypes() throws Exception { - HierarchicalTypeDefinition<ClassType> dslTestTypeDefinition = - TypesUtil.createClassTypeDef("dsl_test_type", - ImmutableList.<String>of(), + HierarchicalTypeDefinition<ClassType> dslTestTypeDefinition = TypesUtil + .createClassTypeDef("dsl_test_type", ImmutableList.<String>of(), TypesUtil.createUniqueRequiredAttrDef("name", DataTypes.STRING_TYPE), TypesUtil.createRequiredAttrDef("description", DataTypes.STRING_TYPE)); - HierarchicalTypeDefinition<TraitType> classificationTraitDefinition = - TypesUtil.createTraitTypeDef("Classification", - ImmutableList.<String>of(), + HierarchicalTypeDefinition<TraitType> classificationTraitDefinition = TypesUtil + .createTraitTypeDef("Classification", ImmutableList.<String>of(), TypesUtil.createRequiredAttrDef("tag", DataTypes.STRING_TYPE)); HierarchicalTypeDefinition<TraitType> piiTrait = TypesUtil.createTraitTypeDef("PII_TYPE", ImmutableList.<String>of()); @@ -197,18 +178,17 @@ public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT { HierarchicalTypeDefinition<TraitType> financeTrait = TypesUtil.createTraitTypeDef("Finance", ImmutableList.<String>of()); - TypesDef typesDef = TypeUtils.getTypesDef( - ImmutableList.<EnumTypeDefinition>of(), - ImmutableList.<StructTypeDefinition>of(), - ImmutableList.of(classificationTraitDefinition, piiTrait, phiTrait, pciTrait, - soxTrait, secTrait, financeTrait), - ImmutableList.of(dslTestTypeDefinition)); + TypesDef typesDef = TypeUtils + .getTypesDef(ImmutableList.<EnumTypeDefinition>of(), ImmutableList.<StructTypeDefinition>of(), + ImmutableList + .of(classificationTraitDefinition, piiTrait, phiTrait, pciTrait, soxTrait, secTrait, + financeTrait), ImmutableList.of(dslTestTypeDefinition)); createType(typesDef); } private Id createInstance() throws Exception { - Referenceable entityInstance = new Referenceable("dsl_test_type", - "Classification", "PII_TYPE", "PHI", "PCI", "SOX", "SEC", "Finance"); + Referenceable entityInstance = + new Referenceable("dsl_test_type", "Classification", "PII_TYPE", "PHI", "PCI", "SOX", "SEC", "Finance"); entityInstance.set("name", "foo name"); entityInstance.set("description", "bar description"); http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/webapp/src/test/java/org/apache/atlas/web/resources/RexsterGraphJerseyResourceIT.java ---------------------------------------------------------------------- diff --git a/webapp/src/test/java/org/apache/atlas/web/resources/RexsterGraphJerseyResourceIT.java b/webapp/src/test/java/org/apache/atlas/web/resources/RexsterGraphJerseyResourceIT.java index e3f29ae..fab84e4 100755 --- a/webapp/src/test/java/org/apache/atlas/web/resources/RexsterGraphJerseyResourceIT.java +++ b/webapp/src/test/java/org/apache/atlas/web/resources/RexsterGraphJerseyResourceIT.java @@ -44,13 +44,9 @@ public class RexsterGraphJerseyResourceIT extends BaseResourceIT { public void testGetVertex() throws Exception { // todo: add a vertex before fetching it - WebResource resource = service - .path("api/atlas/graph/vertices") - .path("0"); + WebResource resource = service.path("api/atlas/graph/vertices").path("0"); - ClientResponse clientResponse = resource - .accept(Servlets.JSON_MEDIA_TYPE) - .type(Servlets.JSON_MEDIA_TYPE) + ClientResponse clientResponse = resource.accept(Servlets.JSON_MEDIA_TYPE).type(Servlets.JSON_MEDIA_TYPE) .method(HttpMethod.GET, ClientResponse.class); Assert.assertEquals(clientResponse.getStatus(), Response.Status.OK.getStatusCode()); String response = clientResponse.getEntity(String.class); @@ -58,12 +54,9 @@ public class RexsterGraphJerseyResourceIT extends BaseResourceIT { } public void testGetVertexWithInvalidId() throws Exception { - WebResource resource = service - .path("api/atlas/graph/vertices/blah"); + WebResource resource = service.path("api/atlas/graph/vertices/blah"); - ClientResponse clientResponse = resource - .accept(Servlets.JSON_MEDIA_TYPE) - .type(Servlets.JSON_MEDIA_TYPE) + ClientResponse clientResponse = resource.accept(Servlets.JSON_MEDIA_TYPE).type(Servlets.JSON_MEDIA_TYPE) .method(HttpMethod.GET, ClientResponse.class); Assert.assertEquals(clientResponse.getStatus(), Response.Status.NOT_FOUND.getStatusCode()); }
