You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sf...@apache.org on 2015/07/15 19:28:22 UTC
[5/8] incubator-usergrid git commit: remove old test framework
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/876dc8d3/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/ApplicationResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/ApplicationResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/ApplicationResource.java
new file mode 100644
index 0000000..dbf653d
--- /dev/null
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/ApplicationResource.java
@@ -0,0 +1,105 @@
+/*
+ *
+ * * Licensed to the Apache Software Foundation (ASF) under one or more
+ * * contributor license agreements. The ASF licenses this file to You
+ * * under the Apache License, Version 2.0 (the "License"); you may not
+ * * use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License. For additional information regarding
+ * * copyright in this work, please see the NOTICE file in the top level
+ * * directory of this distribution.
+ *
+ */
+
+package org.apache.usergrid.rest.test.resource.endpoints.mgmt;
+
+import javax.ws.rs.core.MediaType;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.usergrid.rest.test.resource.endpoints.CollectionEndpoint;
+import org.apache.usergrid.rest.test.resource.endpoints.NamedResource;
+import org.apache.usergrid.rest.test.resource.endpoints.UrlResource;
+import org.apache.usergrid.rest.test.resource.model.Application;
+import org.apache.usergrid.rest.test.resource.model.*;
+import org.apache.usergrid.rest.test.resource.state.ClientContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.io.StringReader;
+
+
+/**
+ * Classy class class.
+ */
+public class ApplicationResource extends NamedResource {
+
+ private static final Logger logger = LoggerFactory.getLogger(ApplicationResource.class);
+
+ ObjectMapper mapper = new ObjectMapper();
+
+ public ApplicationResource(ClientContext context, UrlResource parent) {
+ super("applications", context, parent);
+ }
+
+ public ApplicationResource( final String name, final ClientContext context, final UrlResource parent ) {
+ super( name, context, parent );
+ }
+
+ public ApplicationResource addToPath( String pathPart ) {
+ return new ApplicationResource( pathPart, context, this );
+ }
+
+
+ public org.apache.usergrid.rest.test.resource.model.ApiResponse post(Application application) {
+ org.apache.usergrid.rest.test.resource.model.ApiResponse apiResponse =getResource(true).type(MediaType.APPLICATION_JSON_TYPE)
+ .accept(MediaType.APPLICATION_JSON).post(org.apache.usergrid.rest.test.resource.model.ApiResponse.class, application);
+ return apiResponse;
+ }
+
+ public org.apache.usergrid.rest.test.resource.model.Entity post(org.apache.usergrid.rest.test.resource.model.Entity payload) {
+
+ String responseString = getResource(true)
+ .type( MediaType.APPLICATION_JSON_TYPE )
+ .accept(MediaType.APPLICATION_JSON)
+ .post(String.class, payload);
+
+ logger.debug("Response from post: " + responseString);
+
+ org.apache.usergrid.rest.test.resource.model.ApiResponse response;
+ try {
+ response = mapper.readValue(new StringReader(responseString), org.apache.usergrid.rest.test.resource.model.ApiResponse.class);
+ } catch (IOException e) {
+ throw new RuntimeException("Error parsing response", e);
+ }
+
+ return new org.apache.usergrid.rest.test.resource.model.Entity(response);
+ }
+
+
+ public org.apache.usergrid.rest.test.resource.model.Entity get() {
+
+ String responseString = getResource(true)
+ .type( MediaType.APPLICATION_JSON_TYPE )
+ .accept(MediaType.APPLICATION_JSON)
+ .get(String.class);
+
+ logger.debug("Response from post: " + responseString);
+
+ org.apache.usergrid.rest.test.resource.model.ApiResponse response;
+ try {
+ response = mapper.readValue(new StringReader(responseString), org.apache.usergrid.rest.test.resource.model.ApiResponse.class);
+ } catch (IOException e) {
+ throw new RuntimeException("Error parsing response", e);
+ }
+
+ return new org.apache.usergrid.rest.test.resource.model.Entity(response);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/876dc8d3/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/ApplicationsResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/ApplicationsResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/ApplicationsResource.java
new file mode 100644
index 0000000..caf93e8
--- /dev/null
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/ApplicationsResource.java
@@ -0,0 +1,65 @@
+/*
+ *
+ * * Licensed to the Apache Software Foundation (ASF) under one or more
+ * * contributor license agreements. The ASF licenses this file to You
+ * * under the Apache License, Version 2.0 (the "License"); you may not
+ * * use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License. For additional information regarding
+ * * copyright in this work, please see the NOTICE file in the top level
+ * * directory of this distribution.
+ *
+ */
+
+package org.apache.usergrid.rest.test.resource.endpoints.mgmt;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.usergrid.rest.test.resource.endpoints.NamedResource;
+import org.apache.usergrid.rest.test.resource.endpoints.UrlResource;
+import org.apache.usergrid.rest.test.resource.state.ClientContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.ws.rs.core.MediaType;
+import java.io.IOException;
+import java.io.StringReader;
+
+
+/**
+ * Management end-point for getting list of applications in organization.
+ */
+public class ApplicationsResource extends NamedResource {
+ private static final Logger logger = LoggerFactory.getLogger(ApplicationsResource.class);
+ ObjectMapper mapper = new ObjectMapper();
+
+ public ApplicationsResource( final ClientContext context, final UrlResource parent ) {
+ super( "apps", context, parent );
+ }
+
+ public ManagementResponse getOrganizationApplications() throws IOException {
+
+ String responseString = this.getResource()
+ .queryParam( "access_token", context.getToken().getAccessToken() )
+ .type(MediaType.APPLICATION_JSON)
+ .get(String.class);
+
+ logger.info("Response: " + responseString);
+
+ return mapper.readValue(
+ new StringReader(responseString), ManagementResponse.class);
+ }
+
+
+
+ public ApplicationResource app( final String appName ){
+ return new ApplicationResource( appName,context,this );
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/876dc8d3/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/AuthorizeResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/AuthorizeResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/AuthorizeResource.java
new file mode 100644
index 0000000..694f9c4
--- /dev/null
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/AuthorizeResource.java
@@ -0,0 +1,59 @@
+/*
+ *
+ * * Licensed to the Apache Software Foundation (ASF) under one or more
+ * * contributor license agreements. The ASF licenses this file to You
+ * * under the Apache License, Version 2.0 (the "License"); you may not
+ * * use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License. For additional information regarding
+ * * copyright in this work, please see the NOTICE file in the top level
+ * * directory of this distribution.
+ *
+ */
+package org.apache.usergrid.rest.test.resource.endpoints.mgmt;
+
+import com.sun.jersey.api.client.GenericType;
+import org.apache.usergrid.rest.test.resource.endpoints.NamedResource;
+import org.apache.usergrid.rest.test.resource.endpoints.UrlResource;
+import org.apache.usergrid.rest.test.resource.state.ClientContext;
+
+/**
+ * OAuth authorization resource
+ */
+public class AuthorizeResource extends NamedResource {
+ public AuthorizeResource(final ClientContext context, final UrlResource parent) {
+ super("authorize", context, parent);
+ }
+
+ /**
+ * Obtains an OAuth authorization
+ *
+ * @param requestEntity
+ * @return
+ */
+ public Object post(Object requestEntity) {
+ return getResource().post(Object.class, requestEntity);
+
+ }
+
+ /**
+ * Obtains an OAuth authorization
+ *
+ * @param type
+ * @param requestEntity
+ * @return
+ */
+ public <T> T post(Class<T> type, Object requestEntity) {
+ GenericType<T> gt = new GenericType<>((Class) type);
+ return getResource().post(gt.getRawClass(), requestEntity);
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/876dc8d3/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/ConfirmResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/ConfirmResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/ConfirmResource.java
new file mode 100644
index 0000000..0a35353
--- /dev/null
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/ConfirmResource.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.usergrid.rest.test.resource.endpoints.mgmt;
+
+
+import javax.ws.rs.core.MediaType;
+
+import org.apache.usergrid.rest.test.resource.endpoints.NamedResource;
+import org.apache.usergrid.rest.test.resource.endpoints.UrlResource;
+import org.apache.usergrid.rest.test.resource.model.ApiResponse;
+import org.apache.usergrid.rest.test.resource.model.QueryParameters;
+import org.apache.usergrid.rest.test.resource.state.ClientContext;
+
+import com.sun.jersey.api.client.WebResource;
+
+
+/**
+ * For confirming users
+ */
+public class ConfirmResource extends NamedResource {
+ public ConfirmResource( final ClientContext context, final UrlResource parent ) {
+ super( "confirm", context, parent );
+ }
+
+ public void get(QueryParameters queryParameters){
+ WebResource resource = getResource();
+ resource = addParametersToResource( resource, queryParameters );
+ String obj = resource.type( MediaType.TEXT_HTML_TYPE )
+ .accept( MediaType.TEXT_HTML).get( String.class );
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/876dc8d3/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/CredentialsResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/CredentialsResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/CredentialsResource.java
new file mode 100644
index 0000000..073d6d6
--- /dev/null
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/CredentialsResource.java
@@ -0,0 +1,53 @@
+/*
+ *
+ * * Licensed to the Apache Software Foundation (ASF) under one or more
+ * * contributor license agreements. The ASF licenses this file to You
+ * * under the Apache License, Version 2.0 (the "License"); you may not
+ * * use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License. For additional information regarding
+ * * copyright in this work, please see the NOTICE file in the top level
+ * * directory of this distribution.
+ *
+ */
+package org.apache.usergrid.rest.test.resource.endpoints.mgmt;
+
+import com.sun.jersey.api.client.WebResource;
+import org.apache.usergrid.rest.test.resource.endpoints.NamedResource;
+import org.apache.usergrid.rest.test.resource.endpoints.UrlResource;
+import org.apache.usergrid.rest.test.resource.model.ApiResponse;
+import org.apache.usergrid.rest.test.resource.model.Credentials;
+import org.apache.usergrid.rest.test.resource.model.QueryParameters;
+import org.apache.usergrid.rest.test.resource.state.ClientContext;
+
+import javax.ws.rs.core.MediaType;
+
+/**
+ */
+public class CredentialsResource extends NamedResource {
+
+ public CredentialsResource(final ClientContext context, final UrlResource parent) {
+ super("credentials", context, parent);
+ }
+
+ public Credentials get(final QueryParameters parameters, final boolean useToken) {
+ WebResource resource = getResource(useToken);
+ resource = addParametersToResource(resource, parameters);
+ ApiResponse response = resource.type(MediaType.APPLICATION_JSON_TYPE).accept(MediaType.APPLICATION_JSON)
+ .get(ApiResponse.class);
+ return new Credentials(response);
+ }
+
+ public Credentials get(final QueryParameters parameters) {
+ return get(parameters, true);
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/876dc8d3/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/FeedResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/FeedResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/FeedResource.java
new file mode 100644
index 0000000..8fd873b
--- /dev/null
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/FeedResource.java
@@ -0,0 +1,49 @@
+/*
+ *
+ * * Licensed to the Apache Software Foundation (ASF) under one or more
+ * * contributor license agreements. The ASF licenses this file to You
+ * * under the Apache License, Version 2.0 (the "License"); you may not
+ * * use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License. For additional information regarding
+ * * copyright in this work, please see the NOTICE file in the top level
+ * * directory of this distribution.
+ *
+ */
+
+package org.apache.usergrid.rest.test.resource.endpoints.mgmt;
+
+
+import javax.ws.rs.core.MediaType;
+
+import org.apache.usergrid.rest.test.resource.endpoints.NamedResource;
+import org.apache.usergrid.rest.test.resource.endpoints.UrlResource;
+import org.apache.usergrid.rest.test.resource.model.ApiResponse;
+import org.apache.usergrid.rest.test.resource.model.Collection;
+import org.apache.usergrid.rest.test.resource.model.Entity;
+import org.apache.usergrid.rest.test.resource.state.ClientContext;
+
+
+/**
+ * Contains the REST methods to interacting with the ManagementEndpoints
+ * and the user feeds
+ */
+public class FeedResource extends NamedResource {
+ public FeedResource(final ClientContext context, final UrlResource parent) {
+ super ( "feed",context, parent);
+ }
+
+ public ApiResponse get() {
+ return getResource( true ).type( MediaType.APPLICATION_JSON_TYPE )
+ .accept( MediaType.APPLICATION_JSON ).get( ApiResponse.class);
+
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/876dc8d3/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/ManagementResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/ManagementResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/ManagementResource.java
new file mode 100644
index 0000000..bc31d34
--- /dev/null
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/ManagementResource.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.usergrid.rest.test.resource.endpoints.mgmt;
+
+
+import org.apache.usergrid.rest.test.resource.endpoints.*;
+import org.apache.usergrid.rest.test.resource.state.ClientContext;
+
+
+/**
+ * Contains the REST methods to interacting with the ManagementEndpoints
+ */
+public class ManagementResource extends NamedResource {
+ public ManagementResource( final ClientContext context, final UrlResource parent ) {
+ super( "management", context, parent );
+ }
+
+ public TokenResource token(){
+ return new TokenResource( context, this );
+ }
+
+ public MeResource me(){
+ return new MeResource( context, this );
+ }
+
+ public AuthorizeResource authorize(){
+ return new AuthorizeResource( context, this );
+ }
+
+ public OrgResource orgs() {
+ return new OrgResource( context, this );
+ }
+
+ public UsersResource users() {
+ return new UsersResource( context, this );
+ }
+
+ public EntityEndpoint externaltoken(){
+ return new EntityEndpoint("externaltoken",context,this);
+ }
+
+ public EntityEndpoint get(final String identifier){
+ return new EntityEndpoint(identifier, context, this);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/876dc8d3/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/ManagementResponse.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/ManagementResponse.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/ManagementResponse.java
new file mode 100644
index 0000000..addd0db
--- /dev/null
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/ManagementResponse.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.usergrid.rest.test.resource.endpoints.mgmt;
+
+import java.util.Map;
+
+
+/**
+ * Represents response from management end-points.
+ */
+public class ManagementResponse {
+ private String action;
+ private Map<String, Object> data;
+ private long timestamp;
+ private long duration;
+ private String uri;
+
+ public long getDuration() {
+ return duration;
+ }
+
+ public void setDuration(long duration) {
+ this.duration = duration;
+ }
+
+ public long getTimestamp() {
+ return timestamp;
+ }
+
+ public void setTimestamp(long timestamp) {
+ this.timestamp = timestamp;
+ }
+
+ public Map<String, Object> getData() {
+ return data;
+ }
+
+ public void setData(Map<String, Object> data) {
+ this.data = data;
+ }
+
+ public String getAction() {
+ return action;
+ }
+
+ public void setAction(String action) {
+ this.action = action;
+ }
+
+ public String getUri() {
+ return uri;
+ }
+
+ public void setUri(String uri) {
+ this.uri = uri;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/876dc8d3/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/MeResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/MeResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/MeResource.java
new file mode 100644
index 0000000..1e5955e
--- /dev/null
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/MeResource.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.usergrid.rest.test.resource.endpoints.mgmt;
+
+
+import org.apache.usergrid.rest.test.resource.endpoints.NamedResource;
+import org.apache.usergrid.rest.test.resource.endpoints.UrlResource;
+import org.apache.usergrid.rest.test.resource.state.ClientContext;
+
+
+/**
+ * Calls the management/me endpoints
+ */
+public class MeResource extends NamedResource {
+ public MeResource( final ClientContext context, final UrlResource parent ) {
+ super( "me", context, parent );
+ }
+
+ public TokenResource token(){
+ return new TokenResource(context,this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/876dc8d3/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/OrgResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/OrgResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/OrgResource.java
new file mode 100644
index 0000000..2a5b813
--- /dev/null
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/OrgResource.java
@@ -0,0 +1,167 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.usergrid.rest.test.resource.endpoints.mgmt;
+
+import javax.ws.rs.core.MediaType;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.usergrid.rest.test.resource.endpoints.NamedResource;
+import org.apache.usergrid.rest.test.resource.endpoints.UrlResource;
+import org.apache.usergrid.rest.test.resource.model.ApiResponse;
+import org.apache.usergrid.rest.test.resource.model.Organization;
+import org.apache.usergrid.rest.test.resource.model.QueryParameters;
+import org.apache.usergrid.rest.test.resource.model.Token;
+import org.apache.usergrid.rest.test.resource.model.User;
+import org.apache.usergrid.rest.test.resource.state.ClientContext;
+
+import com.sun.jersey.api.client.WebResource;
+
+import com.sun.jersey.api.representation.Form;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.io.StringReader;
+
+
+//TODO: add error checking to each of the REST calls.
+/**
+ * Manages the Management/ORG endpoint.
+ */
+public class OrgResource extends NamedResource {
+ private static final Logger logger = LoggerFactory.getLogger(OrgResource.class);
+
+ public OrgResource( final ClientContext context, final UrlResource parent ) {
+ super( "organizations", context, parent );
+ }
+
+
+ public OrganizationResource org( final String orgname ){
+ return new OrganizationResource( orgname,context,this );
+ }
+
+ /**
+ * This post is for the POST params case, where the entire call is made using queryParameters.
+ */
+ public Organization post(Form form){
+
+ // Seems like an apiresponse can't handle what gets returned from the from urlended media type
+
+ ApiResponse response = getResource().type( MediaType.APPLICATION_FORM_URLENCODED )
+ .accept(MediaType.APPLICATION_JSON)
+ .post(ApiResponse.class, form);
+
+ Organization organization = new Organization(response);
+ organization.setOwner( response );
+ return organization;
+ }
+
+ /**
+ * This post is for the POST params case, where the entire call is made using queryParameters.
+ */
+ public Organization post(QueryParameters parameters){
+
+ // Seems like an ApiResponse can't handle what gets returned from the from URL encoded media type
+ WebResource resource = addParametersToResource( getResource(), parameters);
+
+ // use string type so we can log actual response from server
+ String responseString = resource.type(MediaType.APPLICATION_JSON_TYPE)
+ .accept(MediaType.APPLICATION_JSON)
+ .post(String.class);
+
+ logger.debug("Response from post: " + responseString);
+
+ ObjectMapper mapper = new ObjectMapper();
+ ApiResponse response;
+ try {
+ response = mapper.readValue( new StringReader(responseString), ApiResponse.class);
+ } catch (IOException e) {
+ throw new RuntimeException("Error parsing response", e);
+ }
+
+ Organization org = new Organization(response);
+ org.setOwner( response );
+
+ return org;
+ }
+
+ public Organization post(Organization organization){
+
+ // use string type so we can log actual response from server
+ String responseString = getResource(false).type( MediaType.APPLICATION_JSON_TYPE )
+ .accept(MediaType.APPLICATION_JSON)
+ .post(String.class, organization);
+
+ logger.debug("Response from post: " + responseString);
+
+ ObjectMapper mapper = new ObjectMapper();
+ ApiResponse response;
+ try {
+ response = mapper.readValue( new StringReader(responseString), ApiResponse.class);
+ } catch (IOException e) {
+ throw new RuntimeException("Error parsing response", e);
+ }
+
+ Organization org = new Organization(response);
+ org.setOwner( response );
+
+ return org;
+ }
+ public Organization post(Organization organization, Token token){
+ ApiResponse response = getResource(true,token).type( MediaType.APPLICATION_JSON_TYPE ).accept( MediaType.APPLICATION_JSON )
+ .post( ApiResponse.class,organization );
+
+ Organization org = new Organization(response);
+ org.setOwner( response );
+
+ return org;
+ }
+
+ public Organization put(Organization organization){
+
+ // use string type so we can log actual response from server
+ String responseString = getResource().type( MediaType.APPLICATION_JSON_TYPE )
+ .accept(MediaType.APPLICATION_JSON)
+ .put(String.class, organization);
+
+ logger.debug("Response from put: " + responseString);
+
+ ObjectMapper mapper = new ObjectMapper();
+ ApiResponse response;
+ try {
+ response = mapper.readValue( new StringReader(responseString), ApiResponse.class);
+ } catch (IOException e) {
+ throw new RuntimeException("Error parsing response", e);
+ }
+
+ Organization org = new Organization(response);
+ org.setOwner( response );
+
+ return org;
+
+ }
+
+ public Organization get(){
+ throw new UnsupportedOperationException("service doesn't exist");
+ }
+
+ public CredentialsResource credentials(){
+ return new CredentialsResource( context ,this );
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/876dc8d3/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/OrganizationApplicationResponse.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/OrganizationApplicationResponse.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/OrganizationApplicationResponse.java
new file mode 100644
index 0000000..9afe084
--- /dev/null
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/OrganizationApplicationResponse.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.usergrid.rest.test.resource.endpoints.mgmt;
+
+
+import java.util.Map;
+
+public class OrganizationApplicationResponse {
+ private String action;
+ private Map<String, Object> data;
+ private long timestamp;
+ private long duration;
+
+ public long getDuration() {
+ return duration;
+ }
+
+ public void setDuration(long duration) {
+ this.duration = duration;
+ }
+
+ public long getTimestamp() {
+ return timestamp;
+ }
+
+ public void setTimestamp(long timestamp) {
+ this.timestamp = timestamp;
+ }
+
+ public Map<String, Object> getData() {
+ return data;
+ }
+
+ public void setData(Map<String, Object> data) {
+ this.data = data;
+ }
+
+ public String getAction() {
+ return action;
+ }
+
+ public void setAction(String action) {
+ this.action = action;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/876dc8d3/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/OrganizationResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/OrganizationResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/OrganizationResource.java
new file mode 100644
index 0000000..cf0987e
--- /dev/null
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/OrganizationResource.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.usergrid.rest.test.resource.endpoints.mgmt;
+
+import org.apache.usergrid.rest.test.resource.endpoints.NamedResource;
+import org.apache.usergrid.rest.test.resource.endpoints.UrlResource;
+import org.apache.usergrid.rest.test.resource.model.ApiResponse;
+import org.apache.usergrid.rest.test.resource.model.Organization;
+import org.apache.usergrid.rest.test.resource.state.ClientContext;
+
+import javax.ws.rs.core.MediaType;
+import java.util.Map;
+
+
+/**
+ * This is for the Management endpoint.
+ * Holds the information required for building and chaining organization objects to applications.
+ * Should also contain the GET,PUT,POST,DELETE methods of functioning in here.
+ */
+public class OrganizationResource extends NamedResource {
+
+ public OrganizationResource(final String name, final ClientContext context, final UrlResource parent) {
+ super(name, context, parent);
+ }
+
+ public UsersResource users() {
+ return new UsersResource(context, this);
+ }
+
+ public Organization get() {
+ ApiResponse rep = getResource(true).type(MediaType.APPLICATION_JSON_TYPE)
+ .accept(MediaType.APPLICATION_JSON).get(ApiResponse.class);
+
+ //TODO: not sure if this will work for multiple users.
+ Organization org = new Organization(rep);
+ org.setUserOwner(rep);
+ return org;
+ }
+
+ // Doesn't return anything useful server side so this was made as a void. .
+ public void put(Organization organization) {
+ Map<String, Object> response = getResource(true).type(MediaType.APPLICATION_JSON_TYPE)
+ .accept(MediaType.APPLICATION_JSON).put(Organization.class,
+ organization);
+
+ }
+
+ public ApplicationResource app(){
+ return new ApplicationResource( context ,this );
+ }
+
+ public CredentialsResource credentials() {
+ return new CredentialsResource(context, this);
+ }
+
+ public ApplicationsResource apps() {
+ return new ApplicationsResource( context, this );
+ }
+
+
+ public ApplicationResource addToPath( String pathPart ) {
+ return new ApplicationResource( pathPart, context, this );
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/876dc8d3/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/PasswordResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/PasswordResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/PasswordResource.java
new file mode 100644
index 0000000..59121ab
--- /dev/null
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/PasswordResource.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.usergrid.rest.test.resource.endpoints.mgmt;
+
+
+import java.util.Map;
+
+import javax.ws.rs.core.MediaType;
+
+import org.apache.usergrid.rest.test.resource.endpoints.NamedResource;
+import org.apache.usergrid.rest.test.resource.endpoints.UrlResource;
+import org.apache.usergrid.rest.test.resource.model.ApiResponse;
+import org.apache.usergrid.rest.test.resource.model.Entity;
+import org.apache.usergrid.rest.test.resource.model.Token;
+import org.apache.usergrid.rest.test.resource.state.ClientContext;
+
+import com.sun.jersey.api.client.WebResource;
+
+
+/**
+ * Relations to the following endpoint
+ * /management/users/"username"/password
+ * Allows admin users to change their passwords
+ */
+public class PasswordResource extends NamedResource {
+
+ public PasswordResource( final ClientContext context, final UrlResource parent ) {
+ super( "password", context, parent );
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/876dc8d3/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/ReactivateResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/ReactivateResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/ReactivateResource.java
new file mode 100644
index 0000000..3959b3e
--- /dev/null
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/ReactivateResource.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.usergrid.rest.test.resource.endpoints.mgmt;
+
+
+import javax.ws.rs.core.MediaType;
+
+import org.apache.usergrid.rest.test.resource.endpoints.NamedResource;
+import org.apache.usergrid.rest.test.resource.endpoints.UrlResource;
+import org.apache.usergrid.rest.test.resource.model.ApiResponse;
+import org.apache.usergrid.rest.test.resource.model.Entity;
+import org.apache.usergrid.rest.test.resource.state.ClientContext;
+
+import com.sun.jersey.api.client.WebResource;
+
+
+/**
+ * handles the * /reactivate endpoints
+ */
+public class ReactivateResource extends NamedResource {
+ public ReactivateResource(final ClientContext context, final UrlResource parent) {
+ super("reactivate",context, parent);
+ }
+
+ public Entity get(){
+ WebResource resource = getResource(true);
+ ApiResponse response = resource.type( MediaType.APPLICATION_JSON_TYPE )
+ .accept( MediaType.APPLICATION_JSON ).get( ApiResponse.class);
+ return new Entity(response);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/876dc8d3/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/ResetResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/ResetResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/ResetResource.java
new file mode 100644
index 0000000..076e284
--- /dev/null
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/ResetResource.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.usergrid.rest.test.resource.endpoints.mgmt;
+
+
+import javax.ws.rs.core.MediaType;
+
+import org.apache.usergrid.rest.test.resource.endpoints.NamedResource;
+import org.apache.usergrid.rest.test.resource.endpoints.UrlResource;
+import org.apache.usergrid.rest.test.resource.state.ClientContext;
+
+import com.sun.jersey.api.representation.Form;
+
+
+/**
+ * Handles /resetpw endpoints for the user resource.
+ */
+public class ResetResource extends NamedResource {
+
+ public ResetResource( final ClientContext context, final UrlResource parent ) {
+ super( "resetpw", context, parent );
+ }
+
+ public String post(Form formPayload) {
+ return getResource().type( MediaType.APPLICATION_FORM_URLENCODED_TYPE )
+ .accept( MediaType.TEXT_HTML ).post( String.class, formPayload);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/876dc8d3/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/RevokeTokenResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/RevokeTokenResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/RevokeTokenResource.java
new file mode 100644
index 0000000..8a73114
--- /dev/null
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/RevokeTokenResource.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.usergrid.rest.test.resource.endpoints.mgmt;
+
+
+import org.apache.usergrid.rest.test.resource.endpoints.NamedResource;
+import org.apache.usergrid.rest.test.resource.endpoints.UrlResource;
+import org.apache.usergrid.rest.test.resource.state.ClientContext;
+
+
+/**
+ * Handles /revokeToken endpoint ( as opposed to revokeTokens
+ */
+public class RevokeTokenResource extends NamedResource {
+ public RevokeTokenResource( final ClientContext context, final UrlResource parent ) {
+ super( "revoketoken", context, parent );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/876dc8d3/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/RevokeTokensResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/RevokeTokensResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/RevokeTokensResource.java
new file mode 100644
index 0000000..dcd3e5d
--- /dev/null
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/RevokeTokensResource.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.usergrid.rest.test.resource.endpoints.mgmt;
+
+
+import org.apache.usergrid.rest.test.resource.endpoints.NamedResource;
+import org.apache.usergrid.rest.test.resource.endpoints.UrlResource;
+import org.apache.usergrid.rest.test.resource.state.ClientContext;
+
+
+/**
+ * Handles endpoints against /revoketokens
+ */
+public class RevokeTokensResource extends NamedResource {
+ public RevokeTokensResource( final ClientContext context, final UrlResource parent ) {
+ super( "revoketokens", context, parent );
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/876dc8d3/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/TokenResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/TokenResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/TokenResource.java
new file mode 100644
index 0000000..613955a
--- /dev/null
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/TokenResource.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.usergrid.rest.test.resource.endpoints.mgmt;
+
+
+import com.sun.jersey.api.client.WebResource;
+import org.apache.usergrid.rest.test.resource.endpoints.NamedResource;
+import org.apache.usergrid.rest.test.resource.endpoints.UrlResource;
+import org.apache.usergrid.rest.test.resource.model.QueryParameters;
+import org.apache.usergrid.rest.test.resource.model.Token;
+import org.apache.usergrid.rest.test.resource.state.ClientContext;
+
+import javax.ws.rs.core.MediaType;
+
+
+/**
+ * Called by the ManagementResource. This contains anything token related that comes back to the ManagementResource.
+ */
+public class TokenResource extends NamedResource {
+ public TokenResource(final ClientContext context, final UrlResource parent) {
+ super("token", context, parent);
+ }
+
+ public Token get(String username, String password){
+ QueryParameters queryParameters = new QueryParameters();
+ queryParameters.addParam( "grant_type", "password" );
+ queryParameters.addParam( "username", username );
+ queryParameters.addParam( "password", password );
+ return get(queryParameters);
+
+ }
+ /**
+ * Obtains an access token and sets the token for the context to use in later calls
+ *
+ * @return
+ */
+ public Token get(QueryParameters params) {
+ WebResource resource = getResource(false);
+ resource = addParametersToResource(resource, params);
+ Token token = resource.type(MediaType.APPLICATION_JSON_TYPE).accept(MediaType.APPLICATION_JSON)
+ .get(Token.class);
+
+ this.context.setToken(token);
+ return token;
+ }
+
+
+ /**
+ * Convinece method to set the token needed for each call.
+ * @param token
+ * @return
+ */
+ public TokenResource setToken(Token token) {
+ this.context.setToken(token);
+ return this;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/876dc8d3/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/UserResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/UserResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/UserResource.java
new file mode 100644
index 0000000..ee804e6
--- /dev/null
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/UserResource.java
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.usergrid.rest.test.resource.endpoints.mgmt;
+
+import javax.ws.rs.core.MediaType;
+
+import org.apache.usergrid.rest.test.resource.endpoints.NamedResource;
+import org.apache.usergrid.rest.test.resource.endpoints.UrlResource;
+import org.apache.usergrid.rest.test.resource.model.ApiResponse;
+import org.apache.usergrid.rest.test.resource.model.Entity;
+import org.apache.usergrid.rest.test.resource.state.ClientContext;
+
+import com.sun.jersey.api.client.WebResource;
+
+
+/**
+ * Relations to the following endpoint
+ * /management/users/"username"
+ * Store endpoints relating to specific users
+ */
+public class UserResource extends NamedResource {
+
+ public UserResource( final String name, final ClientContext context, final UrlResource parent ) {
+ super( name, context, parent );
+ }
+
+ public ReactivateResource reactivate() {
+ return new ReactivateResource( context, this );
+ }
+
+ public ConfirmResource confirm() {
+ return new ConfirmResource(context,this);
+ }
+
+ public PasswordResource password() {
+ return new PasswordResource( context, this );
+ }
+
+ public FeedResource feed() {
+ return new FeedResource( context, this );
+ }
+
+ public ResetResource resetpw() {
+ return new ResetResource(context,this);
+ }
+
+ public OrgResource organizations() {
+ return new OrgResource( context, this );
+ }
+
+ public RevokeTokensResource revokeTokens() {
+ return new RevokeTokensResource( context, this );
+ }
+
+ public RevokeTokenResource revokeToken() {
+ return new RevokeTokenResource( context, this );
+ }
+
+ public Entity get() {
+ WebResource resource = getResource( true );
+ ApiResponse response = resource.type( MediaType.APPLICATION_JSON_TYPE )
+ .accept( MediaType.APPLICATION_JSON ).get( ApiResponse.class );
+ return new Entity(response);
+ }
+
+ public Entity put(Entity userPayload){
+ WebResource resource = getResource(true);
+
+ ApiResponse response = resource.type( MediaType.APPLICATION_JSON_TYPE )
+ .accept( MediaType.APPLICATION_JSON ).put( ApiResponse.class, userPayload);
+ return new Entity(response);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/876dc8d3/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/UsersResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/UsersResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/UsersResource.java
new file mode 100644
index 0000000..5ef681d
--- /dev/null
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/UsersResource.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.usergrid.rest.test.resource.endpoints.mgmt;
+
+
+import javax.ws.rs.core.MediaType;
+
+import org.apache.usergrid.rest.test.resource.endpoints.EntityEndpoint;
+import org.apache.usergrid.rest.test.resource.endpoints.NamedResource;
+import org.apache.usergrid.rest.test.resource.endpoints.UrlResource;
+import org.apache.usergrid.rest.test.resource.model.ApiResponse;
+import org.apache.usergrid.rest.test.resource.model.Entity;
+import org.apache.usergrid.rest.test.resource.state.ClientContext;
+
+import com.sun.jersey.api.client.WebResource;
+
+
+/**
+ * Handles calls to the users management endpoint
+ * Example: /management/orgs/org_name/users
+ */
+public class UsersResource extends NamedResource {
+ public UsersResource( final ClientContext context, final UrlResource parent ) {
+ super( "users", context, parent );
+ }
+
+
+ /**
+ * Should this be here? this would facilitate calling the entity endpoint as a way to get/put things
+ * @param identifier
+ * @return
+ */
+ //TODO: See if this should be reused here or if we should rename it to something else.
+ public EntityEndpoint entity(String identifier) {
+ return new EntityEndpoint(identifier, context, this);
+ }
+
+ public UserResource user(String identifier) {
+ return new UserResource( identifier, context, this );
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/876dc8d3/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/mgmt/Application.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/mgmt/Application.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/mgmt/Application.java
deleted file mode 100644
index d1e67c8..0000000
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/mgmt/Application.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.usergrid.rest.test.resource.mgmt;
-
-
-import java.util.UUID;
-
-import org.apache.usergrid.rest.test.resource.EntityResource;
-import org.apache.usergrid.rest.test.resource.NamedResource;
-
-
-/**
- * A resource for testing queues
- *
- * @author tnine
- */
-public class Application extends EntityResource {
-
- /**
- * @param entityId
- * @param parent
- */
- public Application( UUID entityId, NamedResource parent ) {
- super( entityId, parent );
- }
-
-
- /**
- * @param entityName
- * @param parent
- */
- public Application( String entityName, NamedResource parent ) {
- super( entityName, parent );
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/876dc8d3/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/mgmt/ApplicationsCollection.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/mgmt/ApplicationsCollection.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/mgmt/ApplicationsCollection.java
deleted file mode 100644
index 401167a..0000000
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/mgmt/ApplicationsCollection.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.usergrid.rest.test.resource.mgmt;
-
-
-import java.util.UUID;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import java.io.IOException;
-import org.apache.usergrid.rest.test.resource.CollectionResource;
-import org.apache.usergrid.rest.test.resource.NamedResource;
-import org.apache.usergrid.utils.MapUtils;
-
-
-/** @author tnine */
-public class ApplicationsCollection extends CollectionResource {
-
- /**
- * @param collectionName
- * @param parent
- */
- public ApplicationsCollection( NamedResource parent ) {
- super( "apps", parent );
- }
-
-
- public Application application( String name ) {
- return new Application( name, this );
- }
-
-
- /** Create the org and return it's UUID */
- public UUID create( String name ) throws IOException {
-
- JsonNode node = postInternal( MapUtils.hashMap( "name", name ) );
-
- return getEntityId( node, 0 );
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/876dc8d3/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/mgmt/Management.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/mgmt/Management.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/mgmt/Management.java
deleted file mode 100644
index 78ea3ec..0000000
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/mgmt/Management.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.usergrid.rest.test.resource.mgmt;
-
-
-import java.util.Map;
-
-import javax.ws.rs.core.MediaType;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import java.io.IOException;
-import org.apache.usergrid.rest.test.resource.Me;
-import org.apache.usergrid.rest.test.resource.NamedResource;
-import org.apache.usergrid.rest.test.resource.RootResource;
-import org.apache.usergrid.rest.test.resource.app.UsersCollection;
-import org.apache.usergrid.utils.MapUtils;
-
-
-/** @author tnine */
-public class Management extends NamedResource {
-
- protected ObjectMapper mapper = new ObjectMapper();
-
- /**
- * @param parent
- */
- public Management( RootResource root ) {
- super( root );
- }
-
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.apache.usergrid.rest.resource.NamedResource#addToUrl(java.lang.StringBuilder)
- */
- @Override
- public void addToUrl( StringBuilder buffer ) {
- parent.addToUrl( buffer );
- buffer.append( SLASH );
- buffer.append( "management" );
- }
-
-
- public UsersCollection users() {
- return new UsersCollection( this );
- }
-
-
- public OrganizationsCollection orgs() {
- return new OrganizationsCollection( this );
- }
-
-
- /** Get the token from management for this username and password */
- public String tokenGet( String username, String password ) throws IOException {
-
- JsonNode node = mapper.readTree( resource().path( String.format( "%s/token", url() ) ).queryParam( "grant_type", "password" )
- .queryParam( "username", username ).queryParam( "password", password )
- .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE ).get( String.class ));
-
- return node.get( "access_token" ).asText();
- }
-
-
- /** Get the token from management for this username and password */
- public String tokenPost( String username, String password ) throws IOException {
-
- Map<String, String> payload =
- MapUtils.hashMap( "grant_type", "password" ).map( "username", username ).map( "password", password );
-
- JsonNode node = mapper.readTree( resource().path( String.format( "%s/token", url() ) ).accept( MediaType.APPLICATION_JSON )
- .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class, payload ));
-
- return node.get( "access_token" ).asText();
- }
-
-
- public Me me() {
- return new Me( this );
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/876dc8d3/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/mgmt/Organization.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/mgmt/Organization.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/mgmt/Organization.java
deleted file mode 100644
index c143ebb..0000000
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/mgmt/Organization.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.usergrid.rest.test.resource.mgmt;
-
-
-import java.util.UUID;
-
-import org.apache.usergrid.rest.test.resource.EntityResource;
-import org.apache.usergrid.rest.test.resource.NamedResource;
-import org.apache.usergrid.rest.test.resource.app.UsersCollection;
-
-
-/**
- * A resource for testing queues
- *
- * @author tnine
- */
-public class Organization extends EntityResource {
-
- /**
- * @param entityId
- * @param parent
- */
- public Organization( UUID entityId, NamedResource parent ) {
- super( entityId, parent );
- }
-
-
- /**
- * @param entityName
- * @param parent
- */
- public Organization( String entityName, NamedResource parent ) {
- super( entityName, parent );
- }
-
-
- public ApplicationsCollection apps() {
- return new ApplicationsCollection( this );
- }
-
-
- public UsersCollection users() {
- return new UsersCollection( this );
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/876dc8d3/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/mgmt/OrganizationsCollection.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/mgmt/OrganizationsCollection.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/mgmt/OrganizationsCollection.java
deleted file mode 100644
index 522eadf..0000000
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/mgmt/OrganizationsCollection.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.usergrid.rest.test.resource.mgmt;
-
-
-import java.util.Map;
-import java.util.UUID;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import java.io.IOException;
-import org.apache.usergrid.rest.test.resource.CollectionResource;
-import org.apache.usergrid.rest.test.resource.NamedResource;
-import org.apache.usergrid.rest.test.resource.OrgUserUUIDWrapper;
-import org.apache.usergrid.rest.test.security.TestUser;
-import org.apache.usergrid.utils.MapUtils;
-
-
-/** @author tnine */
-public class OrganizationsCollection extends CollectionResource {
-
- /**
- * @param collectionName
- * @param parent
- */
- public OrganizationsCollection( NamedResource parent ) {
- super( "orgs", parent );
- }
-
-
- public Organization organization( String name ) {
- return new Organization( name, this );
- }
-
-
- /** Create the org and return it's UUID */
- public OrgUserUUIDWrapper create( String name, TestUser owner ) throws IOException {
-//not entirely convinced we want to do this here, maybe we should shove the node and data get another level deeper?
- JsonNode node = postInternal(mapOrganization( name,owner.getUser(),owner.getEmail(),owner.getUser(),owner.getPassword() ) );
-
-//org && user uuid wrapper
- OrgUserUUIDWrapper wrapper = new OrgUserUUIDWrapper(getOrgUUID( node ),getUserUUID(node) );
-
- return wrapper;
- }
-
- public UUID getOrgUUID(JsonNode node){
- return UUID.fromString(node.get("data").get( "organization" ).get("uuid").asText());
- }
-
- public UUID getUserUUID (JsonNode node){
- return UUID.fromString( node.get( "data" ).get( "owner" ).get( "uuid" ).asText() );
- }
-
- public Map<String,String> mapOrganization(String orgName, String username, String email, String name, String password){
-
- return MapUtils.hashMap( "organization", orgName ).map( "username", username )
- .map( "email", email ).map( "name", name )
- .map( "password", password);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/876dc8d3/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/model/ActivityEntity.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/model/ActivityEntity.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/model/ActivityEntity.java
new file mode 100644
index 0000000..f3c66fa
--- /dev/null
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/model/ActivityEntity.java
@@ -0,0 +1,49 @@
+/*
+ *
+ * * Licensed to the Apache Software Foundation (ASF) under one or more
+ * * contributor license agreements. The ASF licenses this file to You
+ * * under the Apache License, Version 2.0 (the "License"); you may not
+ * * use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License. For additional information regarding
+ * * copyright in this work, please see the NOTICE file in the top level
+ * * directory of this distribution.
+ *
+ */
+
+package org.apache.usergrid.rest.test.resource.model;
+
+import org.apache.usergrid.persistence.index.utils.MapUtils;
+
+import java.util.Map;
+
+/**
+ * Provide Guidance on ActivityEntity
+ */
+public class ActivityEntity extends Entity {
+ public ActivityEntity(String email, String verb, String content){
+ this.chainPut("content",content).chainPut("verb",verb).chainPut("email",email);
+ }
+ public ActivityEntity() {
+ this.putAll(new MapUtils.HashMapBuilder<String, Object>());
+ }
+ public ActivityEntity(Map<String,Object> map){
+ this.putAll(map);
+ }
+
+ public ActivityEntity putActor(Map<String, Object> actorPost) {
+ this.put("actor",actorPost);
+ return this;
+ }
+
+ public Map<String, Object> getActor() {
+ return (Map<String, Object>) this.get("actor");
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/876dc8d3/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/model/ApiResponse.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/model/ApiResponse.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/model/ApiResponse.java
new file mode 100644
index 0000000..471cf5e
--- /dev/null
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/model/ApiResponse.java
@@ -0,0 +1,223 @@
+/**
+ * Created by ApigeeCorporation on 12/4/14.
+ */
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.usergrid.rest.test.resource.model;
+
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import com.fasterxml.jackson.annotation.JsonAnyGetter;
+import com.fasterxml.jackson.annotation.JsonAnySetter;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize.Inclusion;
+
+
+/**
+ * Contains the needed types
+ */
+public class ApiResponse {
+
+ private String accessToken;
+
+ private String error;
+ private String errorDescription;
+ private String errorUri;
+ private String exception;
+
+ private String path;
+ private String uri;
+ private Object data;
+ private String status;
+ private long timestamp;
+ private List<Entity> entities;
+ private String cursor;
+
+
+ private final Map<String, Object> properties = new HashMap<String, Object>();
+
+
+ public ApiResponse() {
+ }
+
+
+ @JsonAnyGetter
+ public Map<String, Object> getProperties() {
+ return properties;
+ }
+
+
+ @JsonAnySetter
+ public void setProperty( String key, Object value ) {
+ properties.put( key, value );
+ }
+
+
+ @JsonProperty( "access_token" )
+ @JsonSerialize( include = Inclusion.NON_NULL )
+ public String getAccessToken() {
+ return accessToken;
+ }
+
+
+ @JsonProperty( "access_token" )
+ public void setAccessToken( String accessToken ) {
+ this.accessToken = accessToken;
+ }
+
+
+ @JsonSerialize( include = Inclusion.NON_NULL )
+ public String getError() {
+ return error;
+ }
+
+
+ public void setError( String error ) {
+ this.error = error;
+ }
+
+
+ @JsonSerialize( include = Inclusion.NON_NULL )
+ @JsonProperty( "error_description" )
+ public String getErrorDescription() {
+ return errorDescription;
+ }
+
+
+ @JsonProperty( "error_description" )
+ public void setErrorDescription( String errorDescription ) {
+ this.errorDescription = errorDescription;
+ }
+
+
+ @JsonSerialize( include = Inclusion.NON_NULL )
+ @JsonProperty( "error_uri" )
+ public String getErrorUri() {
+ return errorUri;
+ }
+
+
+ @JsonProperty( "error_uri" )
+ public void setErrorUri( String errorUri ) {
+ this.errorUri = errorUri;
+ }
+
+
+ @JsonSerialize( include = Inclusion.NON_NULL )
+ public String getException() {
+ return exception;
+ }
+
+
+ public void setException( String exception ) {
+ this.exception = exception;
+ }
+
+
+ @JsonSerialize( include = Inclusion.NON_NULL )
+ public String getPath() {
+ return path;
+ }
+
+
+ public void setPath( String path ) {
+ this.path = path;
+ }
+
+
+ @JsonSerialize( include = Inclusion.NON_NULL )
+ public String getUri() {
+ return uri;
+ }
+
+
+ public void setUri( String uri ) {
+ this.uri = uri;
+ }
+
+
+ @JsonSerialize( include = Inclusion.NON_NULL )
+ public String getStatus() {
+ return status;
+ }
+
+
+ public void setStatus( String status ) {
+ this.status = status;
+ }
+
+
+ public long getTimestamp() {
+ return timestamp;
+ }
+
+
+ public void setTimestamp( long timestamp ) {
+ this.timestamp = timestamp;
+ }
+
+ @JsonSerialize( include = Inclusion.NON_NULL )
+ public List<Entity> getEntities() {
+ return entities;
+ }
+
+
+ public void setEntities( List<Entity> entities ) {
+ this.entities = entities;
+ }
+
+ public List<String> list(){
+ return (List<String>)getProperties().get("list");
+ }
+
+
+ public int getEntityCount() {
+ if ( entities == null ) {
+ return 0;
+ }
+ return entities.size();
+ }
+
+ @JsonSerialize( include = Inclusion.NON_NULL )
+ public String getCursor() {
+ return cursor;
+ }
+
+
+ public void setCursor( String cursor ) {
+ this.cursor = cursor;
+ }
+
+ @JsonSerialize( include = Inclusion.NON_NULL )
+ public Object getData() {
+ return data;
+ }
+
+ public void setData ( Object data ) {
+ this.data = data;
+ }
+
+ public Entity getEntity() {
+ return getEntities().get(0);
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/876dc8d3/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/model/Application.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/model/Application.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/model/Application.java
new file mode 100644
index 0000000..96df4c5
--- /dev/null
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/model/Application.java
@@ -0,0 +1,39 @@
+/*
+ *
+ * * Licensed to the Apache Software Foundation (ASF) under one or more
+ * * contributor license agreements. The ASF licenses this file to You
+ * * under the Apache License, Version 2.0 (the "License"); you may not
+ * * use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License. For additional information regarding
+ * * copyright in this work, please see the NOTICE file in the top level
+ * * directory of this distribution.
+ *
+ */
+
+package org.apache.usergrid.rest.test.resource.model;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Classy class class.
+ */
+public class Application extends Entity {
+ public Application(){ }
+
+ public Application(String name){
+ this.put("name",name);
+ }
+
+ public Application(ApiResponse response){
+ super(response);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/876dc8d3/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/model/ChangePasswordEntity.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/model/ChangePasswordEntity.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/model/ChangePasswordEntity.java
new file mode 100644
index 0000000..63291a5
--- /dev/null
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/model/ChangePasswordEntity.java
@@ -0,0 +1,33 @@
+/*
+ *
+ * * Licensed to the Apache Software Foundation (ASF) under one or more
+ * * contributor license agreements. The ASF licenses this file to You
+ * * under the Apache License, Version 2.0 (the "License"); you may not
+ * * use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License. For additional information regarding
+ * * copyright in this work, please see the NOTICE file in the top level
+ * * directory of this distribution.
+ *
+ */
+
+package org.apache.usergrid.rest.test.resource.model;
+
+/**
+ * Provide guidance on change passwords
+ */
+public class ChangePasswordEntity extends Entity {
+ public ChangePasswordEntity( String newPassword){
+ this.chainPut("newpassword", newPassword);
+ }
+ public ChangePasswordEntity(String oldPassword, String newPassword){
+ this.chainPut("oldpassword", oldPassword).chainPut("newpassword", newPassword);
+ }
+}