diff --git a/pom.xml b/pom.xml index b2c57874..5200555a 100644 --- a/pom.xml +++ b/pom.xml @@ -7,14 +7,16 @@ com.jaspersoft jrs-rest-java-client - 8.0.0 + 8.1.0 REST client for JasperReports server http://github.com/Jaspersoft/jrs-rest-java-client UTF-8 - 1.5.5 - 8.0.0 + 8.1.0 + 2.0.9 + 2.36 + 2.13.3 @@ -25,16 +27,16 @@ - jaspersoft-clients-snapshots - Jaspersoft clients snapshots - https://jaspersoft.jfrog.io/jaspersoft/jaspersoft-clients-releases + jaspersoft-clients-snapshots + Jaspersoft clients snapshots + https://jaspersoft.jfrog.io/jaspersoft/jaspersoft-clients-releases - central - jaspersoft-releases - https://jaspersoft.jfrog.io/jaspersoft/jrs-ce-releases + central + jaspersoft-releases + https://jaspersoft.jfrog.io/jaspersoft/jrs-ce-releases - + @@ -46,6 +48,10 @@ jackson-annotations com.fasterxml.jackson.core + + commons-logging + commons-logging + @@ -53,47 +59,86 @@ org.glassfish.jersey.core jersey-client - 2.22.1 + ${jersey.version} org.glassfish.jersey.media jersey-media-multipart - 2.22.1 + ${jersey.version} - com.sun.jersey - jersey-json - 1.19 + org.glassfish.jersey.media + jersey-media-json-jackson + ${jersey.version} org.glassfish.jersey.media - jersey-media-json-jackson - 2.22.1 + jersey-media-json-processing + ${jersey.version} org.glassfish.jersey.media jersey-media-jaxb - 2.22.1 + ${jersey.version} + + + org.glassfish.jersey.inject + jersey-hk2 + ${jersey.version} + + + + org.codehaus.jettison + jettison + 1.5.0 + + + + com.fasterxml.jackson.core + jackson-databind + ${jackson.version} + + + com.fasterxml.jackson.core + jackson-core + ${jackson.version} + + + com.fasterxml.jackson.core + jackson-annotations + ${jackson.version} + + + com.fasterxml.jackson.module + jackson-module-jaxb-annotations + ${jackson.version} org.testng testng - 6.8.7 + 7.4.0 test + + org.mockito + mockito-core + + 3.12.4 + test + org.powermock - powermock-module-testng + powermock-api-mockito2 ${powermock.version} test org.powermock - powermock-api-mockito + powermock-module-testng ${powermock.version} test @@ -103,60 +148,46 @@ ${powermock.version} test + + org.hamcrest + hamcrest + 2.2 + test + org.easymock easymock - 3.2 + 4.3 test - - com.owlike - genson - 0.99 - org.bouncycastle bcprov-jdk15on - 1.51 + 1.70 org.apache.commons commons-lang3 - 3.0 + 3.12.0 commons-io commons-io - 2.4 - - - commons-logging - commons-logging - 1.0.4 + 2.11.0 - org.slf4j - slf4j-api - 1.7.12 - - - org.slf4j - slf4j-log4j12 - 1.7.12 - - - log4j - log4j - 1.2.17 + org.apache.logging.log4j + log4j-slf4j-impl + 2.17.2 org.slf4j jul-to-slf4j - 1.7.12 + 1.7.36 @@ -166,16 +197,16 @@ org.apache.maven.plugins maven-compiler-plugin - 3.1 + 3.8.1 - 1.7 - 1.7 + 1.8 + 1.8 org.codehaus.mojo cobertura-maven-plugin - 2.5.2 + 2.7 xml 256m @@ -188,7 +219,9 @@ **/com/jaspersoft/jasperserver/jaxrs/client/core/exceptions/** **/com/jaspersoft/jasperserver/jaxrs/client/core/enums/** - **/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/adhoc/queryexecution/enums/** + + **/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/adhoc/queryexecution/enums/** + @@ -197,7 +230,7 @@ org.eluder.coveralls coveralls-maven-plugin - 2.0.0 + 4.3.0 develop @@ -207,7 +240,7 @@ org.apache.maven.plugins maven-surefire-plugin - 2.12 + 2.22.2 false false @@ -241,17 +274,17 @@ org.codehaus.mojo findbugs-maven-plugin - 3.0.0 + 3.0.5 org.apache.maven.plugins maven-pmd-plugin - 3.4 + 3.15.0 org.apache.maven.plugins maven-checkstyle-plugin - 2.14 + 3.1.2 config/sun_checks.xml @@ -263,34 +296,4 @@ - - - borys.kolesnykov - Borys Kolesnykov - borys.kolesnikov@gmail.com - - architect - developer - - +3 - - - Krasnyanskiy - Alexander Krasnyanskiy - krasnyanskiy.alex@gmail.com - - developer - - +3 - - - tetiana.iefimenko - Tetiana Iefiemenko - efimenkot@gmail.com - - developer - - +3 - - diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/adhoc/queryexecution/QueryExecutionAdapter.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/adhoc/queryexecution/QueryExecutionAdapter.java index 8ec3cfcc..3b5ff013 100755 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/adhoc/queryexecution/QueryExecutionAdapter.java +++ b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/adhoc/queryexecution/QueryExecutionAdapter.java @@ -115,16 +115,6 @@ public OperationResult retrieveData(String executionId) { return request.get(); } - /** - * @deprecated Replaced by {@link QueryExecutionAdapter#delete()} - */ - @Deprecated - public OperationResult deleteExecution(String executionId) { - uri.add(executionId); - JerseyRequest request = buildRequest(responseClass); - return request.delete(); - } - public OperationResult delete() { JerseyRequest request = buildRequest(Object.class); return request.delete(); diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/attributes/SingleAttributeAdapter.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/attributes/SingleAttributeAdapter.java index 7378770d..597ca212 100644 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/attributes/SingleAttributeAdapter.java +++ b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/attributes/SingleAttributeAdapter.java @@ -31,6 +31,7 @@ import com.jaspersoft.jasperserver.jaxrs.client.core.ThreadPoolUtil; import com.jaspersoft.jasperserver.jaxrs.client.core.exceptions.handling.DefaultErrorHandler; import com.jaspersoft.jasperserver.jaxrs.client.core.operationresult.OperationResult; + import java.util.ArrayList; /** diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/organizations/OrganizationsService.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/organizations/OrganizationsService.java index 6d51118d..5c9879f2 100644 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/organizations/OrganizationsService.java +++ b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/organizations/OrganizationsService.java @@ -32,7 +32,7 @@ public OrganizationsService(SessionStorage sessionStorage) { public SingleOrganizationAdapter organization(ClientTenant organization) { if (organization != null && ((organization.getAlias() != null && !organization.getAlias().isEmpty()) - ||(organization.getId() != null && !organization.getId().isEmpty()) )) { + || (organization.getId() != null && !organization.getId().isEmpty()))) { return new SingleOrganizationAdapter(sessionStorage, organization); } throw new IllegalArgumentException("Organization is not valid."); @@ -46,12 +46,5 @@ public BatchOrganizationsAdapter allOrganizations() { return new BatchOrganizationsAdapter(sessionStorage); } - /** - * @deprecated Replaced by {@link OrganizationsService#allOrganizations()}. - */ -@Deprecated - public BatchOrganizationsAdapter organizations() { - return new BatchOrganizationsAdapter(sessionStorage); - } } diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/organizations/SingleOrganizationAdapter.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/organizations/SingleOrganizationAdapter.java index da43991a..11124998 100644 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/organizations/SingleOrganizationAdapter.java +++ b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/organizations/SingleOrganizationAdapter.java @@ -31,6 +31,7 @@ import com.jaspersoft.jasperserver.jaxrs.client.core.UrlUtils; import com.jaspersoft.jasperserver.jaxrs.client.core.exceptions.handling.DefaultErrorHandler; import com.jaspersoft.jasperserver.jaxrs.client.core.operationresult.OperationResult; + import javax.ws.rs.core.MultivaluedHashMap; @@ -144,14 +145,4 @@ private JerseyRequest request() { ); } - /** - * @deprecated Replaced by {@link SingleOrganizationAdapter#create()}. - */ - @Deprecated - public OperationResult create(ClientTenant clientTenant) { - JerseyRequest request = request(); - return params.size() != 0 - ? request.addParams(params).post(clientTenant) - : request.post(clientTenant); - } } \ No newline at end of file diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/roles/RolesParameter.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/roles/RolesParameter.java index cd61335a..8100b152 100644 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/roles/RolesParameter.java +++ b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/roles/RolesParameter.java @@ -23,21 +23,6 @@ public enum RolesParameter { - /** - * max quantity of results - * @deprecated Use common approach instead. - */ - @Deprecated - MAX_RECORDS("maxRecords"), - - /** - * Allows inFolder search roles, may work in conjunction with any - * other param. - * @deprecated Use common approach instead. - */ - @Deprecated - SEARCH("search"), - /** * If false, returns all roles of users, set by "user" param, * otherwise returns only roles, which owned by all set users. diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/users/SingleUserRequestAdapter.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/users/SingleUserRequestAdapter.java index ff2ae5e5..000c5182 100644 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/users/SingleUserRequestAdapter.java +++ b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/users/SingleUserRequestAdapter.java @@ -9,20 +9,14 @@ import com.jaspersoft.jasperserver.jaxrs.client.core.ThreadPoolUtil; import com.jaspersoft.jasperserver.jaxrs.client.core.exceptions.handling.DefaultErrorHandler; import com.jaspersoft.jasperserver.jaxrs.client.core.operationresult.OperationResult; + import java.util.ArrayList; public class SingleUserRequestAdapter extends AbstractAdapter { - private ArrayList uri = new ArrayList(); + private ArrayList uri = new ArrayList<>(); private ClientUser user; - /** - * The field is used for deprecated methods of the class. - * - * @deprecated Replaced by {@link SingleUserRequestAdapter#uri}. - */ - private String userUriPrefix; - public SingleUserRequestAdapter(SessionStorage sessionStorage, ClientUser user) { super(sessionStorage); @@ -91,161 +85,8 @@ private JerseyRequest buildRequest() { uri.add(user.getUsername()); return JerseyRequest.buildRequest(sessionStorage, ClientUser.class, - uri.toArray(new String[uri.size()]), + uri.toArray(new String[0]), new DefaultErrorHandler()); } - /** - * @deprecated Replaced by {@link SingleUserRequestAdapter#SingleUserRequestAdapter(SessionStorage, ClientUser)}. - */ - public SingleUserRequestAdapter(SessionStorage sessionStorage, String organizationId, String username) { - super(sessionStorage); - if (organizationId != null) { - uri.add("organizations"); - uri.add(organizationId); - uri.add("users"); - } else { - uri.add("users"); - } - user = new ClientUser(); - user.setUsername(username); - } - - /** - * @deprecated Replaced by {@link SingleUserRequestAdapter#SingleUserRequestAdapter(SessionStorage, ClientUser)}. - */ - public SingleUserRequestAdapter(SessionStorage sessionStorage, String organizationId) { - super(sessionStorage); - if (organizationId != null) { - uri.add("organizations"); - uri.add(organizationId); - uri.add("users"); - } else { - uri.add("users"); - } - } - - /** - * @deprecated Replaced by {@link SingleUserRequestAdapter#SingleUserRequestAdapter(SessionStorage, ClientUser)}. - */ - public SingleUserRequestAdapter(String userId, String organizationId, SessionStorage sessionStorage) { - super(sessionStorage); - if (organizationId != null && !organizationId.equals("") && userId != null && !userId.equals("")) { - uri.add("organizations"); - uri.add(organizationId); - uri.add("users"); - uri.add(userId); - } else if (organizationId == null && userId != null && !userId.equals("")) { - uri.add("users"); - uri.add(userId); - } else { - throw new IllegalArgumentException("Wrong parameters has been passed!"); - } - } - - /** - * @deprecated Replaced by {@link SingleUserRequestAdapter#get()}. - */ - public OperationResult get(String userId) { - - if (!uri.contains("users")) { - return request().get(); - } - if (!uri.get(uri.size() - 1).equals(userId)) { - uri.add(userId); - } - return request().get(); - } - - /** - * @deprecated Replaced by {@link SingleUserRequestAdapter#buildRequest()}. - */ - private JerseyRequest request() { - return JerseyRequest.buildRequest(sessionStorage, - ClientUser.class, - uri.toArray(new String[uri.size()]), - new DefaultErrorHandler()); - } - - /** - * @deprecated Replaced by {@link SingleUserRequestAdapter#asyncGet(Callback)}. - */ - public RequestExecution asyncGet(final Callback, R> callback, String userId) { - if (uri.contains("users") && !uri.get(uri.size() - 1).equals(userId)) { - uri.add(userId); - } - - final JerseyRequest request = request(); - RequestExecution task = new RequestExecution(new Runnable() { - @Override - public void run() { - callback.execute(request.get()); - } - }); - ThreadPoolUtil.runAsynchronously(task); - return task; - } - - /** - * @deprecated Replaced by {@link SingleUserRequestAdapter#createOrUpdate(ClientUser)}. - */ - public OperationResult updateOrCreate(ClientUser user) { - uri.add(user.getUsername()); - if ((!uri.toString().contains("organizations")) && (user.getTenantId() != null)) { - uri.add(0, "organizations"); - uri.add(1,user.getTenantId()); - } - return request().put(user); - } - - /** - * @deprecated Replaced by {@link SingleUserRequestAdapter#asyncCreateOrUpdate(ClientUser, Callback)}. - */ - public RequestExecution asyncCreateOrUpdate(final ClientUser user, final Callback, R> callback, final String userId) { - if (uri.contains("users")) { - uri.add(userId); - } - final JerseyRequest request = request(); - RequestExecution task = new RequestExecution(new Runnable() { - @Override - public void run() { - callback.execute(request.put(user)); - } - }); - ThreadPoolUtil.runAsynchronously(task); - return task; - } - - /** - * @deprecated Replaced by {@link SingleUserRequestAdapter#delete()}. - */ - public OperationResult delete(String userId) { - uri.add(userId); - return request().delete(); - } - - /** - * @deprecated Replaced by {@link SingleUserRequestAdapter#delete()}. - */ - public OperationResult delete(ClientUser user) { - uri.add(user.getUsername()); - return request().delete(); - } - - /** - * @deprecated Replaced by {@link SingleUserRequestAdapter#asyncDelete(Callback)}. - */ - public RequestExecution asyncDelete(final Callback, R> callback, String userId) { - uri.add(userId); - final JerseyRequest request = request(); - RequestExecution task = new RequestExecution(new Runnable() { - @Override - public void run() { - callback.execute(request.delete()); - } - }); - ThreadPoolUtil.runAsynchronously(task); - return task; - } - } diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/users/UsersParameter.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/users/UsersParameter.java index 88cb19bf..9d898ece 100644 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/users/UsersParameter.java +++ b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/users/UsersParameter.java @@ -23,21 +23,6 @@ public enum UsersParameter { - /** - * max quantity of results - * @deprecated Use common approach instead. - */ - @Deprecated - MAX_RECORDS("maxRecords"), - - /** - * Allows to search roles, may work in conjunction with any - * other param. - * @deprecated Use common approach instead. - */ - @Deprecated - SEARCH("search"), - /** * If hasAllRequiredRoles is true then users should contain all * requiredRole specified in query ( think as AND operation) diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/users/UsersService.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/users/UsersService.java index df63163e..877ae1a3 100644 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/users/UsersService.java +++ b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/users/UsersService.java @@ -68,34 +68,6 @@ public BatchUsersRequestAdapter allUsers() { return new BatchUsersRequestAdapter(sessionStorage, organizationId); } - /** - * @deprecated Replaced by {@link UsersService#forOrganization(String)} or {@link UsersService#forOrganization(ClientTenant)}. - */ - public UsersService organization(String organizationId) { - if ("".equals(organizationId) || "/".equals(organizationId)) { - throw new IllegalArgumentException("'organizationId' mustn't be an empty string"); - } - this.organizationId = organizationId; - return this; - } - - /** - * @deprecated Replaced by {@link UsersService#user(String)} or {@link UsersService#user(ClientUser)}. - */ - public SingleUserRequestAdapter username(String username) { - if ("".equals(username) || "/".equals(username)) { - throw new IllegalArgumentException("'username' mustn't be an empty string"); - } - return new SingleUserRequestAdapter(sessionStorage, organizationId, username); - } - - /** - * @deprecated Replaced by {@link UsersService#user(String)} or {@link UsersService#user(ClientUser)}. - */ - public SingleUserRequestAdapter user() { - return new SingleUserRequestAdapter(sessionStorage, organizationId); - } - } diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/connections/ConnectionsService.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/connections/ConnectionsService.java deleted file mode 100644 index 69b76ac4..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/connections/ConnectionsService.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.jaspersoft.jasperserver.jaxrs.client.apiadapters.connections; - -import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.AbstractAdapter; -import com.jaspersoft.jasperserver.jaxrs.client.core.SessionStorage; - -/** - *

- *

- * - * @author tetiana.iefimenko - * @version $Id$ - * @see - * - * @deprecated Replaced by {@link com.jaspersoft.jasperserver.jaxrs.client.apiadapters.context.ContextService} - */ -public class ConnectionsService extends AbstractAdapter { - - public ConnectionsService(SessionStorage sessionStorage) { - super(sessionStorage); - } - public SingleConnectionsAdapter connection(Class connectionClass, String connectionMimeType) { - return new SingleConnectionsAdapter(sessionStorage, connectionClass, connectionMimeType); - } - - public SingleConnectionsAdapter connection(Class connectionClass, String connectionMimeType, String uuId) { - return new SingleConnectionsAdapter(sessionStorage, connectionClass, connectionMimeType, uuId); - } - - public SingleConnectionsAdapter connection(String uuId, Class metadataClass, String metadataMimeType) { - return new SingleConnectionsAdapter(sessionStorage, uuId, metadataClass, metadataMimeType); - } - - public SingleConnectionsAdapter connection(Class connection, String connectionMimeType, - Class metadataClass, - String metadataMimeType) { - return new SingleConnectionsAdapter(sessionStorage, connection, connectionMimeType, metadataClass, metadataMimeType); - } - - public SingleConnectionsAdapter connection(String uuId) { - return new SingleConnectionsAdapter(sessionStorage, uuId); - } - -} \ No newline at end of file diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/connections/SingleConnectionsAdapter.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/connections/SingleConnectionsAdapter.java deleted file mode 100644 index 3df4139d..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/connections/SingleConnectionsAdapter.java +++ /dev/null @@ -1,155 +0,0 @@ -package com.jaspersoft.jasperserver.jaxrs.client.apiadapters.connections; - -import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.AbstractAdapter; -import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.connections.query.SingleQueryAdapter; -import com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest; -import com.jaspersoft.jasperserver.jaxrs.client.core.MimeTypeUtil; -import com.jaspersoft.jasperserver.jaxrs.client.core.SessionStorage; -import com.jaspersoft.jasperserver.jaxrs.client.core.exceptions.MandatoryParameterNotFoundException; -import com.jaspersoft.jasperserver.jaxrs.client.core.exceptions.handling.DefaultErrorHandler; -import com.jaspersoft.jasperserver.jaxrs.client.core.operationresult.OperationResult; - -/** - *

- *

- * - * @author tetiana.iefimenko - * @version $Id$ - * @see - * @deprecated Replaced by {@link com.jaspersoft.jasperserver.jaxrs.client.apiadapters.context.SingleContextAdapter} - */ -public class SingleConnectionsAdapter extends AbstractAdapter { - - public static final String SERVICE_URI = "connections"; - - private String uuId; - private Class connectionClass; - private String connectionMimeType; - private Class metadataClass; - private String metadataMimeType; - - public SingleConnectionsAdapter(SessionStorage sessionStorage, Class connectionClass, - String connectionMimeType, - Class metadataClass, - String metadataMimeType, - String uuId) { - super(sessionStorage); - this.uuId = uuId; - this.connectionClass = connectionClass; - this.connectionMimeType = connectionMimeType; - this.metadataClass = metadataClass; - this.metadataMimeType = metadataMimeType; - } - - public SingleConnectionsAdapter(SessionStorage sessionStorage, Class connectionClass, - String connectionMimeType) { - this(sessionStorage, connectionClass, connectionMimeType, null, null, null); - } - - public SingleConnectionsAdapter(SessionStorage sessionStorage, Class connectionClass, - String connectionMimeType, String uuId) { - this(sessionStorage, connectionClass, connectionMimeType, null, null, uuId); - } - - public SingleConnectionsAdapter(SessionStorage sessionStorage, String uuId, Class metadataClass, - String metadataMimeType) { - this(sessionStorage, null, null, metadataClass, metadataMimeType, uuId); - } - - public SingleConnectionsAdapter(SessionStorage sessionStorage, Class connectionClass, - String connectionMimeType, - Class metadataClass, - String metadataMimeType) { - this(sessionStorage, connectionClass, connectionMimeType, metadataClass, metadataMimeType, null); - } - - public SingleConnectionsAdapter(SessionStorage sessionStorage, String uuId) { - this(sessionStorage, (Class) Object.class, null, null, null, uuId); - } - - @SuppressWarnings("unchecked") - public OperationResult create(C connection) { - if (connection == null) { - throw new MandatoryParameterNotFoundException("Connection is null"); - } - JerseyRequest jerseyRequest = JerseyRequest.buildRequest(this.sessionStorage - , connectionClass - , new String[]{SERVICE_URI} - , new DefaultErrorHandler()); - if (connectionMimeType != null) { - jerseyRequest - .setContentType(MimeTypeUtil.toCorrectContentMime(sessionStorage.getConfiguration(), - connectionMimeType + "+{mime}")); - } - return jerseyRequest.post(connection); - } - - public OperationResult get() { - JerseyRequest jerseyRequest = buildRequest(); - return jerseyRequest.get(); - } - - public OperationResult update(C connection) { - if (connection == null) { - throw new MandatoryParameterNotFoundException("Connection is null"); - } - JerseyRequest jerseyRequest = buildRequest(); - if (connectionMimeType != null) { - jerseyRequest - .setContentType(MimeTypeUtil.toCorrectContentMime(sessionStorage.getConfiguration() - , connectionMimeType + "+{mime}")); - } - return jerseyRequest.put(connection); - } - - public OperationResult delete() { - return buildRequest().delete(); - } - - protected JerseyRequest buildRequest() { - if (uuId == null || uuId.isEmpty()) { - throw new MandatoryParameterNotFoundException("Uuid of the connection must be specified"); - } - return JerseyRequest.buildRequest(this.sessionStorage - , connectionClass - , new String[]{SERVICE_URI, uuId} - , new DefaultErrorHandler()); - } - - public OperationResult metadata() { - if (uuId == null || uuId.isEmpty()) { - throw new MandatoryParameterNotFoundException("Uuid of the connection must be specified"); - } - JerseyRequest jerseyRequest = JerseyRequest.buildRequest( - sessionStorage, - metadataClass, - new String[]{SERVICE_URI, uuId, "metadata"}, - new DefaultErrorHandler() - ); - jerseyRequest.setAccept(MimeTypeUtil.toCorrectAcceptMime(sessionStorage.getConfiguration() - , metadataMimeType + "+{mime}")); - return jerseyRequest.get(); - } - - public OperationResult createAndGetMetadata(C connection) { - if (connection == null) { - throw new MandatoryParameterNotFoundException("Connection is null"); - } - JerseyRequest jerseyRequest = JerseyRequest.buildRequest(this.sessionStorage - , metadataClass - , new String[]{SERVICE_URI} - , new DefaultErrorHandler()); - jerseyRequest - .setContentType(MimeTypeUtil.toCorrectContentMime(sessionStorage.getConfiguration() - , connectionMimeType + "+{mime}")); - jerseyRequest - .setAccept(MimeTypeUtil.toCorrectAcceptMime(sessionStorage.getConfiguration() - , metadataMimeType + "+{mime}")); - return jerseyRequest.post(connection); - } - - - public SingleQueryAdapter query(String query, Class queryResponseClass) { - return new SingleQueryAdapter(sessionStorage, uuId, query, queryResponseClass); - } -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/dashboard/DashboardExecutionsAdapter.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/dashboard/DashboardExecutionsAdapter.java new file mode 100644 index 00000000..1cddfd59 --- /dev/null +++ b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/dashboard/DashboardExecutionsAdapter.java @@ -0,0 +1,161 @@ +/* + * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. + * http://www.jaspersoft.com. + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program.  If not, see . + */ + +package com.jaspersoft.jasperserver.jaxrs.client.apiadapters.dashboard; + +import com.jaspersoft.jasperserver.dto.dashboard.DashboardExportExecution; +import com.jaspersoft.jasperserver.dto.dashboard.DashboardExportExecutionListWrapper; +import com.jaspersoft.jasperserver.dto.dashboard.DashboardExportExecutionStatus; +import com.jaspersoft.jasperserver.dto.dashboard.DashboardParameters; +import com.jaspersoft.jasperserver.dto.reports.ReportParameter; +import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.AbstractAdapter; +import com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest; +import com.jaspersoft.jasperserver.jaxrs.client.core.SessionStorage; +import com.jaspersoft.jasperserver.jaxrs.client.core.exceptions.handling.DefaultErrorHandler; +import com.jaspersoft.jasperserver.jaxrs.client.core.operationresult.OperationResult; + +import java.util.ArrayList; +import java.util.List; + +import static com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest.buildRequest; +import static java.util.Arrays.asList; + +public class DashboardExecutionsAdapter extends AbstractAdapter { + + public static final String DASHBOARD_EXECUTIONS_URI = "dashboardExecutions"; + public static final String STATUS_URI = "status"; + + private DashboardExportExecution executionRequest; + private String executionId; + private final ArrayList path = new ArrayList<>(); + + public DashboardExecutionsAdapter(SessionStorage sessionStorage, DashboardExportExecution executionRequest) { + super(sessionStorage); + this.executionRequest = executionRequest; + this.path.add(DASHBOARD_EXECUTIONS_URI); + } + + public DashboardExecutionsAdapter(SessionStorage sessionStorage, String executionId) { + super(sessionStorage); + this.executionId = executionId; + this.path.add(DASHBOARD_EXECUTIONS_URI); + } + + public DashboardExecutionsAdapter(SessionStorage sessionStorage) { + super(sessionStorage); + this.path.add(DASHBOARD_EXECUTIONS_URI); + this.executionRequest = new DashboardExportExecution(); + } + + public DashboardExecutionsAdapter outputFormat(DashboardExportExecution.ExportFormat outputFormat) { + this.executionRequest.setFormat(outputFormat); + return this; + } + + public DashboardExecutionsAdapter dashboardUri(String dashboardUri) { + this.executionRequest.setUri(dashboardUri); + return this; + } + + public DashboardExecutionsAdapter detailed(Boolean value) { + this.executionRequest.setDetailed(value); + return this; + } + + public DashboardExecutionsAdapter dashboardParameters(DashboardParameters dashboardParameters) { + this.executionRequest.setParameters(dashboardParameters); + return this; + } + + public DashboardExecutionsAdapter dashboardParameter(String name, String... values) { + this.dashboardParameter(new ReportParameter().setName(name).setValues(asList(values))); + return this; + } + + public DashboardExecutionsAdapter dashboardParameter(ReportParameter reportParameter) { + if (executionRequest.getParameters() == null) { + executionRequest.setParameters(new DashboardParameters(new ArrayList<>())); + } + final DashboardParameters parameters = executionRequest.getParameters(); + List dashboardParametersList = parameters.getDashboardParameters(); + if (dashboardParametersList == null) { + dashboardParametersList = new ArrayList<>(); + } + dashboardParametersList.add(reportParameter); + return this; + } + + public DashboardOutputResourceAdapter outputResource() { + return new DashboardOutputResourceAdapter(sessionStorage, executionId); + } + + public OperationResult search() { + JerseyRequest request = JerseyRequest.buildRequest( + sessionStorage, + DashboardExportExecutionListWrapper.class, + path.toArray(new String[0]), + new DefaultErrorHandler()); + return request.get(); + } + + public OperationResult details() { + path.add(executionId); + JerseyRequest request = JerseyRequest.buildRequest( + sessionStorage, + DashboardExportExecution.class, + path.toArray(new String[0]), + new DefaultErrorHandler()); + return request.get(); + } + + public OperationResult status() { + path.add(executionId); + path.add(STATUS_URI); + JerseyRequest request = JerseyRequest.buildRequest( + sessionStorage, + DashboardExportExecutionStatus.class, + path.toArray(new String[0]), + new DefaultErrorHandler()); + + return request.get(); + } + + public OperationResult delete() { + path.add(executionId); + JerseyRequest request = JerseyRequest.buildRequest( + sessionStorage, + Object.class, + path.toArray(new String[0]), + new DefaultErrorHandler()); + + return request.delete(); + } + + public OperationResult run() { + JerseyRequest jerseyRequest = buildRequest(sessionStorage, + DashboardExportExecution.class, + new String[]{DASHBOARD_EXECUTIONS_URI}, + new DefaultErrorHandler()); + return jerseyRequest + .post(executionRequest); + } + +} \ No newline at end of file diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/dashboard/DashboardOutputResourceAdapter.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/dashboard/DashboardOutputResourceAdapter.java new file mode 100644 index 00000000..20e03b4e --- /dev/null +++ b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/dashboard/DashboardOutputResourceAdapter.java @@ -0,0 +1,211 @@ +/* + * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. + * http://www.jaspersoft.com. + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program.  If not, see . + */ + +package com.jaspersoft.jasperserver.jaxrs.client.apiadapters.dashboard; + +import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.AbstractAdapter; +import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting.util.PageRange; +import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting.util.ReportOutputFormat; +import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting.util.RunReportErrorHandler; +import com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest; +import com.jaspersoft.jasperserver.jaxrs.client.core.MimeTypeUtil; +import com.jaspersoft.jasperserver.jaxrs.client.core.SessionStorage; +import com.jaspersoft.jasperserver.jaxrs.client.core.operationresult.OperationResult; +import com.jaspersoft.jasperserver.jaxrs.client.dto.reports.ExportExecution; +import com.jaspersoft.jasperserver.jaxrs.client.dto.reports.ExportExecutionOptions; +import com.jaspersoft.jasperserver.jaxrs.client.dto.reports.OutputResourceDescriptor; +import com.jaspersoft.jasperserver.jaxrs.client.dto.reports.ReportExecutionStatusEntity; +import org.apache.commons.lang3.StringUtils; + +import javax.ws.rs.core.MultivaluedHashMap; +import javax.ws.rs.core.MultivaluedMap; +import java.io.InputStream; +import java.util.ArrayList; + +import static com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest.buildRequest; +import static java.util.Arrays.asList; + +public class DashboardOutputResourceAdapter extends AbstractAdapter { + + public static final String REPORT_EXECUTIONS_URI = "reportExecutions"; + public static final String EXPORTS_URI = "exports"; + public static final String STATUS_URI = "status"; + private static final String ATTACHMENTS_URI = "attachments"; + private String OUTPUT_RESOURCES_URI = "outputResource"; + + private ExportExecutionOptions executionOptions; + private String executionId; + private String exportId; + private Boolean withErrorDescriptor = Boolean.FALSE; + private ArrayList path = new ArrayList(); + private final MultivaluedMap params = new MultivaluedHashMap<>(); + + public DashboardOutputResourceAdapter(SessionStorage sessionStorage, String executionId) { + super(sessionStorage); + this.path.add(REPORT_EXECUTIONS_URI); + this.executionId = executionId; + this.executionOptions = new ExportExecutionOptions(); + } + + public DashboardOutputResourceAdapter(SessionStorage sessionStorage, String executionId, String exportId) { + super(sessionStorage); + path.add(REPORT_EXECUTIONS_URI); + this.executionId = executionId; + this.exportId = exportId; + } + + public DashboardOutputResourceAdapter withOptions(ExportExecutionOptions options) { + this.executionOptions = options; + return this; + } + + public DashboardOutputResourceAdapter outputFormat(ReportOutputFormat outputFormat) { + this.executionOptions.setOutputFormat(outputFormat.name().toLowerCase()); + return this; + } + + public DashboardOutputResourceAdapter outputFormat(String outputFormat) { + this.executionOptions.setOutputFormat(outputFormat); + return this; + } + + public DashboardOutputResourceAdapter attachmentsPrefix(String attachmentPrefix) { + this.executionOptions.setAttachmentsPrefix(attachmentPrefix); + return this; + } + + public DashboardOutputResourceAdapter pages(String pages) { + this.executionOptions.setPages(pages); + return this; + } + + public DashboardOutputResourceAdapter pages(Integer... pages) { + this.executionOptions.setPages(StringUtils.join(asList(pages), ",")); + return this; + } + + public DashboardOutputResourceAdapter pages(PageRange pages) { + this.executionOptions.setPages(pages.getRange()); + return this; + } + + public DashboardOutputResourceAdapter baseUrl(String uri) { + this.executionOptions.setBaseUrl(uri); + return this; + } + + public DashboardOutputResourceAdapter allowInlineScripts(Boolean value) { + this.executionOptions.setAllowInlineScripts(value); + return this; + } + + public DashboardOutputResourceAdapter markupType(String markupType) { + this.executionOptions.setMarkupType(markupType); + return this; + } + + public DashboardOutputResourceAdapter ignorePagination(Boolean value) { + this.executionOptions.setIgnorePagination(value); + return this; + } + + public DashboardOutputResourceAdapter withErrordescriptor(Boolean value) { + this.withErrorDescriptor = value; + return this; + } + + public OperationResult run() { + path.add(executionId); + path.add(EXPORTS_URI); + JerseyRequest jerseyRequest = buildRequest(sessionStorage, + ExportExecution.class, + path.toArray(new String[path.size()]), + new RunReportErrorHandler()); + + return jerseyRequest + .post(executionOptions); + } + + public OperationResult status() { + path.add(executionId); + path.add(EXPORTS_URI); + path.add(exportId); + path.add(STATUS_URI); + JerseyRequest jerseyRequest = buildRequest(sessionStorage, + ReportExecutionStatusEntity.class, + path.toArray(new String[path.size()]), + new RunReportErrorHandler()); + if (withErrorDescriptor) + jerseyRequest.setAccept(MimeTypeUtil.toCorrectContentMime(sessionStorage.getConfiguration(), "application/status+{mime}")); + return jerseyRequest.get(); + } + + public DashboardOutputResourceAdapter suppressContentDisposition(Boolean value) { + this.params.add("suppressContentDisposition", value.toString()); + return this; + } + + public OperationResult getOutputResource() { + path.add(executionId); + path.add(EXPORTS_URI); + path.add(exportId); + path.add(OUTPUT_RESOURCES_URI); + JerseyRequest jerseyRequest = buildRequest(sessionStorage, + InputStream.class, + path.toArray(new String[path.size()]), + new RunReportErrorHandler()); + jerseyRequest.addParams(params); + return jerseyRequest.get(); + } + + public OperationResult getOutputResourceAsText() { + path.add(executionId); + path.add(EXPORTS_URI); + path.add(exportId); + path.add(OUTPUT_RESOURCES_URI); + JerseyRequest jerseyRequest = buildRequest(sessionStorage, + String.class, + path.toArray(new String[path.size()]), + new RunReportErrorHandler()); + jerseyRequest.addParams(params); + return jerseyRequest.get(); + } + + public OperationResult getOutputResourceAttachment(OutputResourceDescriptor attachmentDescriptor) { + path.add(executionId); + path.add(EXPORTS_URI); + path.add(exportId); + path.add(ATTACHMENTS_URI); + path.add(attachmentDescriptor.getFileName()); + JerseyRequest jerseyRequest = buildRequest(sessionStorage, + InputStream.class, + path.toArray(new String[path.size()]), + new RunReportErrorHandler()); + jerseyRequest.addParams(params); + jerseyRequest.setAccept(attachmentDescriptor.getContentType()); + return jerseyRequest.get(); + } + + public OperationResult getOutputResourceAttachment(String atachmentName, String mediaType) { + return this.getOutputResourceAttachment(new OutputResourceDescriptor().setFileName(atachmentName).setContentType(mediaType)); + } + +} \ No newline at end of file diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/jaxb/wrappers/DaysSortedSetWrapper.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/dashboard/DashboardsAdapter.java similarity index 51% rename from src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/jaxb/wrappers/DaysSortedSetWrapper.java rename to src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/dashboard/DashboardsAdapter.java index ce52ea2a..7af9574c 100644 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/jaxb/wrappers/DaysSortedSetWrapper.java +++ b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/dashboard/DashboardsAdapter.java @@ -19,37 +19,27 @@ * along with this program.  If not, see . */ -package com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.jaxb.wrappers; +package com.jaspersoft.jasperserver.jaxrs.client.apiadapters.dashboard; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import java.util.SortedSet; +import com.jaspersoft.jasperserver.dto.dashboard.DashboardExportExecution; +import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.AbstractAdapter; +import com.jaspersoft.jasperserver.jaxrs.client.core.SessionStorage; -/** - * This class is needed because of bug in JAXB. - * @XmlElementWrapper doesn't support @XmlJavaTypeAdapter - * - * @author Yaroslav.Kovalchyk - * @version $Id: DaysSortedSetWrapper.java 22756 2012-03-23 10:39:15Z sergey.prilukin $ - * @deprecated (use server adapter). - */ -@XmlRootElement -public class DaysSortedSetWrapper { +public class DashboardsAdapter extends AbstractAdapter { - private SortedSet days; + private final String dashboardUri; - public DaysSortedSetWrapper(){} - - public DaysSortedSetWrapper(SortedSet days){ - this.days = days; + public DashboardsAdapter(SessionStorage sessionStorage, String dashboardUri) { + super(sessionStorage); + this.dashboardUri = dashboardUri; } - @XmlElement(name = "day") - public SortedSet getDays() { - return days; + + public RunDashboardsAdapter prepareForRun(DashboardExportExecution.ExportFormat format) { + return new RunDashboardsAdapter(sessionStorage, dashboardUri, format.toString()); } - public void setDays(SortedSet days) { - this.days = days; + public RunDashboardsAdapter prepareForRun(String format) { + return new RunDashboardsAdapter(sessionStorage, dashboardUri, format); } } diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/dashboard/DashboardsService.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/dashboard/DashboardsService.java new file mode 100644 index 00000000..f127e385 --- /dev/null +++ b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/dashboard/DashboardsService.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. + * http://www.jaspersoft.com. + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program.  If not, see . + */ + +package com.jaspersoft.jasperserver.jaxrs.client.apiadapters.dashboard; + +import com.jaspersoft.jasperserver.dto.dashboard.DashboardExportExecution; +import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.AbstractAdapter; +import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting.reportexecution.ReportExecutionAdapter; +import com.jaspersoft.jasperserver.jaxrs.client.core.SessionStorage; +import com.jaspersoft.jasperserver.jaxrs.client.dto.reports.ReportExecutionRequest; + +public class DashboardsService extends AbstractAdapter { + + public DashboardsService(SessionStorage sessionStorage) { + super(sessionStorage); + } + + public DashboardsAdapter dashboard(String dashboardUri) { + return new DashboardsAdapter(sessionStorage, dashboardUri); + } + + public DashboardExecutionsAdapter dashboardExecutions() { + return new DashboardExecutionsAdapter(sessionStorage); + } + + public DashboardExecutionsAdapter dashboardExecutions(String dashboardUri, DashboardExportExecution.ExportFormat format) { + return new DashboardExecutionsAdapter(sessionStorage, new DashboardExportExecution() + .setId(dashboardUri) + .setFormat(format)); + } + + public DashboardExecutionsAdapter dashboardExecutions(DashboardExportExecution execution) { + return new DashboardExecutionsAdapter(sessionStorage, execution); + } + + public DashboardExecutionsAdapter dashboardExecutions(String executionId) { + return new DashboardExecutionsAdapter(sessionStorage, executionId); + } + +} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/dashboard/RunDashboardsAdapter.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/dashboard/RunDashboardsAdapter.java new file mode 100644 index 00000000..fe42bb19 --- /dev/null +++ b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/dashboard/RunDashboardsAdapter.java @@ -0,0 +1,92 @@ +/* + * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. + * http://www.jaspersoft.com. + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program.  If not, see . + */ + +package com.jaspersoft.jasperserver.jaxrs.client.apiadapters.dashboard; + +import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.AbstractAdapter; +import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting.util.RunReportErrorHandler; +import com.jaspersoft.jasperserver.jaxrs.client.core.Callback; +import com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest; +import com.jaspersoft.jasperserver.jaxrs.client.core.RequestExecution; +import com.jaspersoft.jasperserver.jaxrs.client.core.SessionStorage; +import com.jaspersoft.jasperserver.jaxrs.client.core.ThreadPoolUtil; +import com.jaspersoft.jasperserver.jaxrs.client.core.UrlUtils; +import com.jaspersoft.jasperserver.jaxrs.client.core.operationresult.OperationResult; + +import javax.ws.rs.core.MultivaluedHashMap; +import javax.ws.rs.core.MultivaluedMap; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class RunDashboardsAdapter extends AbstractAdapter { + + public static final String SERVICE_URI = "dashboards"; + private final MultivaluedMap params; + private final String dashboardUri; + private final String format; + private final ArrayList path = new ArrayList<>(); + + public RunDashboardsAdapter(SessionStorage sessionStorage, String dashboardUri, String format) { + super(sessionStorage); + this.params = new MultivaluedHashMap<>(); + this.dashboardUri = dashboardUri; + this.format = format.toLowerCase(); + } + + public RunDashboardsAdapter parameter(String name, String... value) { + params.addAll(name, UrlUtils.encode(Arrays.asList(value))); + return this; + } + + public RunDashboardsAdapter parameter(String name, List values) { + params.addAll(name, UrlUtils.encode(values)); + return this; + + } + + public OperationResult run() { + JerseyRequest request = prepareRunRequest(); + return request.get(); + } + + public RequestExecution asyncRun(final Callback, R> callback) { + final JerseyRequest request = prepareRunRequest(); + RequestExecution task = new RequestExecution(() -> callback.execute(request.get())); + ThreadPoolUtil.runAsynchronously(task); + return task; + } + + private JerseyRequest prepareRunRequest() { + path.add(SERVICE_URI); + path.addAll(Arrays.asList((dashboardUri + "." + format).split("/"))); + JerseyRequest request = JerseyRequest.buildRequest( + sessionStorage, + InputStream.class, + path.toArray(new String[0]), + new RunReportErrorHandler()); + + request.addParams(params); + return request; + } + +} \ No newline at end of file diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/favorites/FavoritesService.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/favorites/FavoritesService.java new file mode 100644 index 00000000..0e604ff0 --- /dev/null +++ b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/favorites/FavoritesService.java @@ -0,0 +1,72 @@ +/* + * Copyright © 2014-2022. TIBCO Software Inc. All Rights Reserved. Confidential & Proprietary. + */ +package com.jaspersoft.jasperserver.jaxrs.client.apiadapters.favorites; + +import com.jaspersoft.jasperserver.dto.favorite.FavoriteResource; +import com.jaspersoft.jasperserver.dto.favorite.FavoriteResourceListWrapper; +import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.AbstractAdapter; +import com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest; +import com.jaspersoft.jasperserver.jaxrs.client.core.SessionStorage; +import com.jaspersoft.jasperserver.jaxrs.client.core.exceptions.handling.DefaultErrorHandler; +import com.jaspersoft.jasperserver.jaxrs.client.core.operationresult.OperationResult; + +import javax.ws.rs.core.MediaType; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +/** + * @author Tetyana Matveyeva + */ +public class FavoritesService extends AbstractAdapter { + public static final String SERVICE_URI = "favorites"; + public static final String DELETE_URI = "delete"; + private List resourceUris; + + public FavoritesService(SessionStorage sessionStorage) { + super(sessionStorage); + } + + public FavoritesService forResource(String uri) { + resourceUris = new ArrayList<>(); + resourceUris.add(uri); + return this; + } + + public FavoritesService forResources(List uris) { + resourceUris = new ArrayList<>(); + resourceUris.addAll(uris); + return this; + } + + public OperationResult add() { + JerseyRequest request = buildAddRequest(); + FavoriteResourceListWrapper body = new FavoriteResourceListWrapper() + .setFavorites(resourceUris.stream().map(FavoriteResource::new).collect(Collectors.toList())); + return request.post(body); + } + + public OperationResult delete() { + JerseyRequest request = buildDeleteRequest(); + FavoriteResourceListWrapper body = new FavoriteResourceListWrapper() + .setFavorites(resourceUris.stream().map(FavoriteResource::new).collect(Collectors.toList())); + return request.post(body); + } + + private JerseyRequest buildAddRequest() { + JerseyRequest request = + JerseyRequest.buildRequest(sessionStorage, FavoriteResourceListWrapper.class, new String[]{SERVICE_URI}, new DefaultErrorHandler()); + request.setAccept(MediaType.APPLICATION_JSON); + request.setContentType(MediaType.APPLICATION_JSON); + return request; + } + + private JerseyRequest buildDeleteRequest() { + JerseyRequest request = + JerseyRequest.buildRequest(sessionStorage, Object.class, new String[]{SERVICE_URI, DELETE_URI}, new DefaultErrorHandler()); + request.setAccept(MediaType.APPLICATION_JSON); + return request; + } + +} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/importexport/exportservice/ExportParameter.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/importexport/exportservice/ExportParameter.java index b06965cd..0384e426 100644 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/importexport/exportservice/ExportParameter.java +++ b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/importexport/exportservice/ExportParameter.java @@ -89,13 +89,19 @@ public enum ExportParameter { * datasource) will be exported. */ SKIP_DEPENDENT_RESOURCES("skip-dependent-resources"), + + /** + * Skip favorite resources + */ + SKIP_FAVORITES("skip-favorite-resources"), + /** * Pagination. Start index for requested pate. */ OFFSET("offset"), /** - * Pagination. Resources count per page + * Pagination. Resources count per page */ LIMIT("limit"); diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/importexport/exportservice/ExportRequestAdapter.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/importexport/exportservice/ExportRequestAdapter.java index f1ac69d5..e33123be 100644 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/importexport/exportservice/ExportRequestAdapter.java +++ b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/importexport/exportservice/ExportRequestAdapter.java @@ -99,67 +99,6 @@ public void run() { return task; } - /** - * @deprecated Replaced by {@link ExportRequestAdapter#fetch(long)} - */ - @Deprecated - public OperationResult fetch() { - - return fetch(500); - } - - @Deprecated - public OperationResult fetch(long interval) { - State state; - while (!"finished".equals((state = state().getEntity()).getPhase())) { - if ("failed".equals(state.getPhase())) { - if (state.getError() != null) { - throw new ExportFailedException(state.getError().getMessage(), Arrays.asList(state.getError())); - } else { - throw new ExportFailedException(state.getMessage()); - } - } - try { - Thread.sleep(interval); - } catch (InterruptedException ignored) { - // NOP - } - } - JerseyRequest request = buildRequest(sessionStorage, InputStream.class, new String[]{SERVICE_URI, taskId, EXPORT_FILE});//eeeee - request.setAccept("application/zip"); - return request.get(); - } - - @Deprecated - public RequestExecution asyncFetch(final Callback, R> callback) { - final JerseyRequest request = buildRequest(sessionStorage, InputStream.class, new String[]{SERVICE_URI, taskId, EXPORT_FILE}); - request.setAccept("application/zip"); - RequestExecution task = new RequestExecution(new Runnable() { - @Override - public void run() { - State state; - while (!"finished".equals((state = state().getEntity()).getPhase())) { - if ("failed".equals(state.getPhase())) { - if (state.getError() != null) { - throw new ExportFailedException(state.getError().getMessage(), Arrays.asList(state.getError())); - } else { - throw new ExportFailedException(state.getMessage()); - } - } - try { - Thread.sleep(500); - } catch (InterruptedException ignored) { - // NOP - } - } - callback.execute(request.get()); - } - }); - ThreadPoolUtil.runAsynchronously(task); - return task; - } - - public OperationResult fetchToFile(String fileName) { JerseyRequest request = buildRequest(sessionStorage, InputStream.class, new String[]{SERVICE_URI, taskId, fileName});//eeeee diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/importexport/exportservice/ExportService.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/importexport/exportservice/ExportService.java index 43123069..df8bf4aa 100644 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/importexport/exportservice/ExportService.java +++ b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/importexport/exportservice/ExportService.java @@ -30,14 +30,6 @@ public ExportService(SessionStorage sessionStorage) { super(sessionStorage); } - /*** - * @deprecated use {@link #newTask(ExportTask)} - */ - @Deprecated - public ExportTaskAdapter newTask() { - return new ExportTaskAdapter(sessionStorage); - } - public ExportRequestAdapter newTask(ExportTask exportTask) { return new ExportRequestAdapter(sessionStorage, exportTask); } diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/importexport/exportservice/ExportTaskAdapter.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/importexport/exportservice/ExportTaskAdapter.java deleted file mode 100644 index 610d698f..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/importexport/exportservice/ExportTaskAdapter.java +++ /dev/null @@ -1,198 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.apiadapters.importexport.exportservice; - -import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.AbstractAdapter; -import com.jaspersoft.jasperserver.jaxrs.client.core.*; -import com.jaspersoft.jasperserver.jaxrs.client.core.exceptions.handling.DefaultErrorHandler; -import com.jaspersoft.jasperserver.jaxrs.client.core.operationresult.OperationResult; -import com.jaspersoft.jasperserver.dto.importexport.ExportTask; -import com.jaspersoft.jasperserver.dto.importexport.State; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import static com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest.buildRequest; - -/** - * @Deprecated use @Link {@link com.jaspersoft.jasperserver.jaxrs.client.apiadapters.importexport.exportservice.ExportRequestAdapter} - * and setters of @Link {@link com.jaspersoft.jasperserver.dto.importexport.ExportTask} - * */ -@Deprecated -public class ExportTaskAdapter extends AbstractAdapter { - - public static final String SERVICE_URI = "export"; - private final ExportTask exportTask; - - public ExportTaskAdapter(SessionStorage sessionStorage) { - super(sessionStorage); - this.exportTask = new ExportTask(); - } - - public ExportTaskAdapter role(String role) { - if (role != null && !role.isEmpty()) { - if (exportTask.getRoles() == null) { - exportTask.setRoles(new ArrayList()); - } - exportTask.getRoles().add(role); - } - return this; - } - - public ExportTaskAdapter roles(List roles) { - if (roles != null && !roles.isEmpty()) { - for (String singleRole : roles) { - this.role(singleRole); - } - } - return this; - } - - - public ExportTaskAdapter allRoles() { - exportTask.setRoles(Collections.emptyList()); - return this; - } - - public ExportTaskAdapter user(String user) { - if (user != null && !user.isEmpty()) { - if (exportTask.getUsers() == null) { - exportTask.setUsers(new ArrayList()); - } - exportTask.getUsers().add(user); - } - return this; - } - - public ExportTaskAdapter users(List users) { - if (users != null && !users.isEmpty()) { - for (String singleUser : users) { - this.user(singleUser); - } - } - return this; - } - - public ExportTaskAdapter allUsers() { - exportTask.setUsers(new ArrayList()); - return this; - } - - public ExportTaskAdapter uri(String uri) { - if (uri != null && !uri.isEmpty()) { - if (exportTask.getUris() == null) { - exportTask.setUris(new ArrayList()); - } - exportTask.getUris().add(uri); - } - return this; - } - - public ExportTaskAdapter uris(List uris) { - if (uris != null && !uris.isEmpty() ) { - for (String singleUri : uris) { - this.uri(singleUri); - } - } - return this; - } - - public ExportTaskAdapter scheduledJob(String scheduledJob) { - - if (scheduledJob != null && !scheduledJob.isEmpty()) { - if (exportTask.getScheduledJobs() == null) { - exportTask.setScheduledJobs(new ArrayList()); - } - exportTask.getScheduledJobs().add(scheduledJob); - } - return this; - } - - public ExportTaskAdapter scheduledJobs(List scheduledJobs) { - if (scheduledJobs != null && !scheduledJobs.isEmpty()) { - for (String singleJob : scheduledJobs) { - this.scheduledJob(singleJob); - } - } - return this; - } - - public ExportTaskAdapter resourceType(String resourceType) { - if (resourceType != null && !resourceType.isEmpty()) { - if (exportTask.getResourceTypes() == null) { - exportTask.setResourceTypes(new ArrayList()); - } - exportTask.getResourceTypes().add(resourceType); - } - return this; - } - - public ExportTaskAdapter resourceTypes(List resourceTypes) { - if (resourceTypes != null && !resourceTypes.isEmpty()) { - for (String singleResourceType : resourceTypes) { - this.resourceType(singleResourceType); - } - } - return this; - } - - public ExportTaskAdapter parameter(ExportParameter parameter) { - if (exportTask.getParameters() == null) { - exportTask.setParameters(new ArrayList()); - } - exportTask.getParameters().add(parameter.getParamName()); - return this; - } - - public ExportTaskAdapter parameters(List parameters) { - for (ExportParameter exportParameter : parameters) { - parameter(exportParameter); - } - return this; - } - - public ExportTaskAdapter organization(String organizationId) { - exportTask.setOrganization(organizationId); - return this; - } - - public OperationResult create() { - return buildRequest(sessionStorage, State.class, new String[]{SERVICE_URI}, - new DefaultErrorHandler()).post(exportTask); - } - - public RequestExecution asyncCreate(final Callback, R> callback) { - final JerseyRequest request = buildRequest(sessionStorage, State.class, new String[]{SERVICE_URI}); - request.setAccept("application/zip"); - // Guarantee that exportTask won't be modified from another thread - final ExportTask localCopy = new ExportTask(exportTask); - RequestExecution task = new RequestExecution(new Runnable() { - @Override - public void run() { - callback.execute(request.post(localCopy)); - } - }); - ThreadPoolUtil.runAsynchronously(task); - return task; - } -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/importexport/importservice/ImportRequestAdapter.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/importexport/importservice/ImportRequestAdapter.java index 35041bfd..b1c1e382 100644 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/importexport/importservice/ImportRequestAdapter.java +++ b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/importexport/importservice/ImportRequestAdapter.java @@ -84,42 +84,6 @@ public ImportRequestAdapter parameter(ImportParameter parameter, BrokenDependenc return this; } - /** - * @Deprecated use setters {@link com.jaspersoft.jasperserver.dto.importexport.ImportTask} - */ - @Deprecated - public ImportRequestAdapter parameter(String parameter) { - importTask.getParameters().add(parameter); - return this; - } - - /** - * @Deprecated use setters {@link com.jaspersoft.jasperserver.dto.importexport.ImportTask} - */ - @Deprecated - public ImportRequestAdapter parameters(List parameters) { - importTask.getParameters().addAll(parameters); - return this; - } - - /** - * @Deprecated use setters {@link com.jaspersoft.jasperserver.dto.importexport.ImportTask} - */ - @Deprecated - public ImportRequestAdapter organization(String organizationId) { - importTask.setOrganization(organizationId); - return this; - } - - /** - * @Deprecated use setters {@link com.jaspersoft.jasperserver.dto.importexport.ImportTask} - */ - @Deprecated - public ImportRequestAdapter brokenDependensies(BrokenDependenciesParameter parameter) { - importTask.setBrokenDependencies(parameter.getValueName()); - return this; - } - public OperationResult create() { return (useMultiPart) ? buildMultiPartRequest().post(prepareForm()) : buildCreateRequest().post(file); } @@ -181,14 +145,6 @@ public OperationResult restartTask(ImportTask task) { return buildTaskRequest().put(task); } - /** - * @Deprecated use {@link #cancel()} - */ - @Deprecated - public OperationResult cancelTask() { - return buildRequest(sessionStorage, Object.class, new String[]{IMPORT_SERVICE_URI, taskId}).delete(); - } - public OperationResult cancel() { return buildRequest(sessionStorage, Object.class, new String[]{IMPORT_SERVICE_URI, taskId}).delete(); } diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/importexport/importservice/ImportService.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/importexport/importservice/ImportService.java index 612cb71a..7226be61 100644 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/importexport/importservice/ImportService.java +++ b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/importexport/importservice/ImportService.java @@ -31,12 +31,6 @@ public ImportService(SessionStorage sessionStorage) { super(sessionStorage); } - @Deprecated - public ImportTaskRequestAdapter newTask() { - return new ImportTaskRequestAdapter(sessionStorage); - } - - public ImportRequestAdapter newImport(File file) { return new ImportRequestAdapter(sessionStorage, file, false); } diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/importexport/importservice/ImportTaskRequestAdapter.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/importexport/importservice/ImportTaskRequestAdapter.java deleted file mode 100644 index 650fcbd7..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/importexport/importservice/ImportTaskRequestAdapter.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.apiadapters.importexport.importservice; - -import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.AbstractAdapter; -import com.jaspersoft.jasperserver.jaxrs.client.core.Callback; -import com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest; -import com.jaspersoft.jasperserver.jaxrs.client.core.RequestExecution; -import com.jaspersoft.jasperserver.jaxrs.client.core.SessionStorage; -import com.jaspersoft.jasperserver.jaxrs.client.core.ThreadPoolUtil; -import com.jaspersoft.jasperserver.jaxrs.client.core.UrlUtils; -import com.jaspersoft.jasperserver.jaxrs.client.core.exceptions.handling.DefaultErrorHandler; -import com.jaspersoft.jasperserver.jaxrs.client.core.operationresult.OperationResult; -import com.jaspersoft.jasperserver.dto.importexport.State; - -import javax.ws.rs.core.MultivaluedHashMap; -import javax.ws.rs.core.MultivaluedMap; -import java.io.File; -import java.io.InputStream; - -import static com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest.buildRequest; - -@Deprecated -public class ImportTaskRequestAdapter extends AbstractAdapter { - - public static final String SERVICE_URI = "import"; - private final MultivaluedMap params; - - public ImportTaskRequestAdapter(SessionStorage sessionStorage) { - super(sessionStorage); - this.params = new MultivaluedHashMap(); - } - - public ImportTaskRequestAdapter parameter(ImportParameter parameter, boolean value) { - params.add(parameter.getParamName(), Boolean.toString(value)); - return this; - } - - public ImportTaskRequestAdapter parameter(ImportParameter parameter, String value) { - params.add(parameter.getParamName(), UrlUtils.encode(value)); - return this; - } - - public ImportTaskRequestAdapter parameter(ImportParameter parameter, BrokenDependenciesParameter value) { - params.add(parameter.getParamName(), value.getValueName()); - return this; - } - - public OperationResult create(File zipArchive) { - return createImport(zipArchive); - } - - public OperationResult create(InputStream zipArchive) { - return createImport(zipArchive); - } - - public RequestExecution asyncCreate(final File zipArchive, final Callback, R> callback) { - return asyncCreateImport(zipArchive, callback); - } - - public RequestExecution asyncCreate(final InputStream zipArchive, final Callback, R> callback) { - return asyncCreateImport(zipArchive, callback); - } - - private OperationResult createImport(Object zipArchive) { - JerseyRequest request = buildRequest(sessionStorage, State.class, new String[]{SERVICE_URI}, new DefaultErrorHandler()); - request.setContentType("application/zip").addParams(params); - return request.post(zipArchive); - } - - private RequestExecution asyncCreateImport(final Object zipArchive, final Callback, R> callback) { - final JerseyRequest request = buildRequest(sessionStorage, State.class, new String[]{SERVICE_URI}); - request.setContentType("application/zip").addParams(params); - RequestExecution task = new RequestExecution(new Runnable() { - @Override - public void run() { - callback.execute(request.post(zipArchive)); - } - }); - - ThreadPoolUtil.runAsynchronously(task); - return task; - } -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/inputControls/InputControlsAdapter.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/inputControls/InputControlsAdapter.java index 8214141b..d5813b62 100644 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/inputControls/InputControlsAdapter.java +++ b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/inputControls/InputControlsAdapter.java @@ -25,17 +25,9 @@ public class InputControlsAdapter extends AbstractAdapter { public InputControlsAdapter(SessionStorage sessionStorage, String reportUnitUri) { super(sessionStorage); - this.container(reportUnitUri); + this.forReport(reportUnitUri); } - @Deprecated - public InputControlsAdapter container(String uri) { - if (uri == null) { - throw new MandatoryParameterNotFoundException("Uri of container should be specified"); - } - this.containerUri = uri; - return this; - } public InputControlsAdapter forReport(String uri) { if (uri == null) { diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/inputControls/InputControlsValuesAdapter.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/inputControls/InputControlsValuesAdapter.java index d1c533f2..9f317514 100644 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/inputControls/InputControlsValuesAdapter.java +++ b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/inputControls/InputControlsValuesAdapter.java @@ -50,18 +50,6 @@ public InputControlsValuesAdapter includeFullStructure(Boolean value) { return this; } - @Deprecated - public InputControlsValuesAdapter parameter(String name, String value) { - this.inputControlsValues.add(name, value); - return this; - } - - @Deprecated - public InputControlsValuesAdapter parameter(String name, String... values) { - this.inputControlsValues.addAll(name, values); - return this; - } - public InputControlsValuesAdapter forInputControl(String name) { this.inputControlsValues.add(name, null); return this; @@ -82,17 +70,6 @@ public InputControlsPaginationValuesAdapter pagination() { return new InputControlsPaginationValuesAdapter(sessionStorage, containerUri, ids.toString()); } - @Deprecated - public OperationResult run() { - if (inputControlsValues.size() == 0) { - throw new MandatoryParameterNotFoundException(); - } - if (!includeFullStructure) { - ids.append(StringUtils.join(inputControlsValues.keySet(), ";")); - } - return buildRequest().post(valuesToArrays()); - } - public OperationResult update(MultivaluedHashMap inputControlsValues) { this.inputControlsValues = inputControlsValues; return this.update(); diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/jobs/BatchJobsOperationsAdapter.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/jobs/BatchJobsOperationsAdapter.java index 31934d6f..2787b542 100644 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/jobs/BatchJobsOperationsAdapter.java +++ b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/jobs/BatchJobsOperationsAdapter.java @@ -20,6 +20,11 @@ */ package com.jaspersoft.jasperserver.jaxrs.client.apiadapters.jobs; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.AnnotationIntrospector; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.type.TypeFactory; +import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector; import com.jaspersoft.jasperserver.dto.job.ClientReportJob; import com.jaspersoft.jasperserver.dto.job.model.ClientReportJobModel; import com.jaspersoft.jasperserver.dto.job.wrappers.ClientJobIdListWrapper; @@ -33,26 +38,16 @@ import com.jaspersoft.jasperserver.jaxrs.client.core.UrlUtils; import com.jaspersoft.jasperserver.jaxrs.client.core.enums.MimeType; import com.jaspersoft.jasperserver.jaxrs.client.core.operationresult.OperationResult; -import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.Job; -import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.JobIdListWrapper; -import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.jaxb.wrappers.JobSummaryListWrapper; -import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.reportjobmodel.ReportJobModel; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.codehaus.jackson.map.AnnotationIntrospector; -import org.codehaus.jackson.map.ObjectMapper; -import org.codehaus.jackson.map.SerializationConfig; -import org.codehaus.jackson.map.annotate.JsonSerialize; -import org.codehaus.jackson.xc.JaxbAnnotationIntrospector; - import javax.ws.rs.core.MultivaluedHashMap; import javax.ws.rs.core.MultivaluedMap; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Marshaller; import java.io.IOException; import java.io.StringWriter; -import java.net.URLEncoder; import java.util.ArrayList; import java.util.List; @@ -60,7 +55,7 @@ public class BatchJobsOperationsAdapter extends AbstractAdapter { - private static final Log log = LogFactory.getLog(BatchJobsOperationsAdapter.class); + private static final Logger log = LogManager.getLogger(BatchJobsOperationsAdapter.class); public static final String SERVICE_URI = "jobs"; public static final String PAUSE = "pause"; public static final String RESUME = "resume"; @@ -131,14 +126,12 @@ private JerseyRequest prepareSearchRequest(Client } private String buildJson(Object object) { - ObjectMapper mapper = new ObjectMapper(); - SerializationConfig serializationConfig = mapper.getSerializationConfig(); - serializationConfig = serializationConfig.withSerializationInclusion(JsonSerialize.Inclusion.NON_NULL); - AnnotationIntrospector introspector = new JaxbAnnotationIntrospector(); - mapper.setSerializationConfig(serializationConfig); + mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); + AnnotationIntrospector introspector = new JaxbAnnotationIntrospector(TypeFactory.defaultInstance()); mapper.setAnnotationIntrospector(introspector); + try { return mapper.writeValueAsString(object); } catch (IOException e) { @@ -161,11 +154,6 @@ private String buildXml(ClientReportJobModel reportJobModel) { } } - @Deprecated - public OperationResult updateWithProcessedParameters(ClientReportJobModel jobModel) { - throw new UnsupportedOperationException("Operation is not supported."); - } - /** * Updates all jobs which ids were specified. Updates only set fields, other fields are ignored. */ @@ -269,171 +257,6 @@ public void run() { return task; } - /** - * @deprecated Replaced by {@link BatchJobsOperationsAdapter#searchJobs()}. - */ - public OperationResult search() { - return search(null); - } - - /** - * @deprecated Replaced by {@link BatchJobsOperationsAdapter#searchJobs(com.jaspersoft.jasperserver.dto.job.ClientReportJob)}. - */ - public OperationResult search(Job searchCriteria) { - JerseyRequest request = prepareSearchRequest(searchCriteria); - return request.get(); - } - - /** - * @deprecated Replaced by {@link BatchJobsOperationsAdapter#asyncSearchJobs(com.jaspersoft.jasperserver.dto.job.ClientReportJob, com.jaspersoft.jasperserver.jaxrs.client.core.Callback)}. - */ - public RequestExecution asyncSearch(final Job searchCriteria, final Callback, R> callback) { - final JerseyRequest request = prepareSearchRequest(searchCriteria); - RequestExecution task = new RequestExecution(new Runnable() { - @Override - public void run() { - callback.execute(request.get()); - } - }); - ThreadPoolUtil.runAsynchronously(task); - return task; - } - - /** - * @deprecated Replaced by {@link BatchJobsOperationsAdapter#prepareSearchRequest(com.jaspersoft.jasperserver.dto.job.ClientReportJob)}. - */ - private JerseyRequest prepareSearchRequest(Job searchCriteria) { - JerseyRequest request = buildRequest(sessionStorage, JobSummaryListWrapper.class, new String[]{SERVICE_URI}); - request.addParams(params); - if (searchCriteria != null) { - String criteriaJson = buildJson(searchCriteria); - request.addParam("example", URLEncoder.encode(criteriaJson), "UTF-8"); - } - return request; - } - - /** - * @deprecated Replaced by {@link BatchJobsOperationsAdapter#update(com.jaspersoft.jasperserver.dto.job.model.ClientReportJobModel)}. - */ - public OperationResult update(ReportJobModel jobModel) { - JerseyRequest request = buildRequest(sessionStorage, JobIdListWrapper.class, new String[]{SERVICE_URI}); - request.addParams(params); - String content; - - if (sessionStorage.getConfiguration().getContentMimeType() == MimeType.JSON) { - content = buildJson(jobModel); - } else { - content = buildXml(jobModel); - } - return request.post(content); - } - - /** - * @deprecated Replaced by {@link BatchJobsOperationsAdapter#buildXml(com.jaspersoft.jasperserver.dto.job.model.ClientReportJobModel)}. - */ - private String buildXml(ReportJobModel reportJobModel) { - try { - StringWriter writer = new StringWriter(); - JAXBContext jaxbContext = JAXBContext.newInstance(ReportJobModel.class); - Marshaller jaxbMarshaller = jaxbContext.createMarshaller(); - jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); - jaxbMarshaller.marshal(reportJobModel, writer); - return writer.toString(); - } catch (JAXBException e) { - log.warn("Can't marshal report job model."); - throw new RuntimeException("Failed inFolder build report job model xml.", e); - } - } - - /** - * @deprecated Replaced by {@link BatchJobsOperationsAdapter#asyncUpdate(com.jaspersoft.jasperserver.dto.job.model.ClientReportJobModel, com.jaspersoft.jasperserver.jaxrs.client.core.Callback)}. - */ - public RequestExecution asyncUpdate(final ReportJobModel jobModel, final Callback, R> callback) { - final JerseyRequest request = buildRequest(sessionStorage, JobIdListWrapper.class, new String[]{SERVICE_URI}); - request.addParams(params); - final String jobJson = buildJson(jobModel); - RequestExecution task = new RequestExecution(new Runnable() { - @Override - public void run() { - callback.execute(request.post(jobJson)); - } - }); - ThreadPoolUtil.runAsynchronously(task); - return task; - } - - /** - * @deprecated Replaced by {@link com.jaspersoft.jasperserver.jaxrs.client.apiadapters.jobs.BatchJobsOperationsAdapter#pauseJobs()}. - */ - public OperationResult pause() { - JobIdListWrapper jobIdListWrapper = new JobIdListWrapper(getIds()); - return buildRequest(sessionStorage, JobIdListWrapper.class, new String[]{SERVICE_URI, PAUSE}).post(jobIdListWrapper); - } - - /** - * @deprecated Replaced by {@link BatchJobsOperationsAdapter#asyncPauseJobs(com.jaspersoft.jasperserver.jaxrs.client.core.Callback)}. - */ - public RequestExecution asyncPause(final Callback, R> callback) { - final JobIdListWrapper jobIdListWrapper = new JobIdListWrapper(getIds()); - final JerseyRequest request = buildRequest(sessionStorage, JobIdListWrapper.class, new String[]{SERVICE_URI, PAUSE}); - RequestExecution task = new RequestExecution(new Runnable() { - @Override - public void run() { - callback.execute(request.post(jobIdListWrapper)); - } - }); - ThreadPoolUtil.runAsynchronously(task); - return task; - } - - /** - * @deprecated Replaced by {@link com.jaspersoft.jasperserver.jaxrs.client.apiadapters.jobs.BatchJobsOperationsAdapter#resumeJobs()}. - */ - public OperationResult resume() { - JobIdListWrapper jobIdListWrapper = new JobIdListWrapper(getIds()); - return buildRequest(sessionStorage, JobIdListWrapper.class, new String[]{SERVICE_URI, RESUME}).post(jobIdListWrapper); - } - - /** - * @deprecated Replaced by {@link BatchJobsOperationsAdapter#asyncResumeJobs(com.jaspersoft.jasperserver.jaxrs.client.core.Callback)}. - */ - public RequestExecution asyncResume(final Callback, R> callback) { - final JobIdListWrapper jobIdListWrapper = new JobIdListWrapper(getIds()); - final JerseyRequest request = buildRequest(sessionStorage, JobIdListWrapper.class, new String[]{SERVICE_URI, RESUME}); - RequestExecution task = new RequestExecution(new Runnable() { - @Override - public void run() { - callback.execute(request.post(jobIdListWrapper)); - } - }); - ThreadPoolUtil.runAsynchronously(task); - return task; - } - - /** - * @deprecated Replaced by {@link com.jaspersoft.jasperserver.jaxrs.client.apiadapters.jobs.BatchJobsOperationsAdapter#restartJobs()}. - */ - public OperationResult restart() { - JobIdListWrapper jobIdListWrapper = new JobIdListWrapper(getIds()); - return buildRequest(sessionStorage, JobIdListWrapper.class, new String[]{SERVICE_URI, RESTART}).post(jobIdListWrapper); - } - - /** - * @deprecated Replaced by {@link BatchJobsOperationsAdapter#asyncRestartJobs(com.jaspersoft.jasperserver.jaxrs.client.core.Callback)}. - */ - public RequestExecution asyncRestart(final Callback, R> callback) { - final JobIdListWrapper jobIdListWrapper = new JobIdListWrapper(getIds()); - final JerseyRequest request = buildRequest(sessionStorage, JobIdListWrapper.class, new String[]{SERVICE_URI, RESTART}); - RequestExecution task = new RequestExecution(new Runnable() { - @Override - public void run() { - callback.execute(request.post(jobIdListWrapper)); - } - }); - ThreadPoolUtil.runAsynchronously(task); - return task; - } - public OperationResult delete() { JerseyRequest jerseyRequest = buildRequest(sessionStorage, ClientJobIdListWrapper.class, new String[]{SERVICE_URI}); addIdsToQueryParams(); diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/jobs/JobsParameter.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/jobs/JobsParameter.java index df78aa79..5d7d0ddd 100644 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/jobs/JobsParameter.java +++ b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/jobs/JobsParameter.java @@ -42,7 +42,13 @@ public enum JobsParameter { SEARCH_LABEL("label"), /** - * Reserved, not implemented + * This argument defines the current state of a job. + * The parameter accepts multiple values: + * NORMAL + * EXECUTING + * PAUSED + * COMPLETE + * ERROR */ SEARCH_STATE("state"), @@ -80,6 +86,7 @@ public enum JobsParameter { * SORTBY_STATUS * SORTBY_LASTRUN * SORTBY_NEXTRUN + * SORTBY_RESOURCELABEL */ SEARCH_SORT_TYPE("sortType"), @@ -90,6 +97,50 @@ public enum JobsParameter { */ SEARCH_IS_ASCENDING("isAscending"), + /** + * This argument defines the job id; jobID should be integer/long + */ + SEARCH_JOB_ID("jobID"), + + /** + * This argument defines the start of a range of time that matches if the job was previously triggered during this time. + * Specify the date and time in the following pattern: `yyyy-MM-dd'T'HH:mm:ss.SSSZ`. + */ + SEARCH_PREVIOUS_FIRE_TIME_FROM("previousFireTimeFrom"), + + /** + * This argument defines the end of a range of time that matches if the job was previously triggered during this time. + * Specify the date and time in the following pattern: `yyyy-MM-dd'T'HH:mm:ss.SSSZ`. + */ + SEARCH_PREVIOUS_FIRE_TIME_TO("previousFireTimeTo"), + + /** + * This argument defines the start of a range of time that matches if the job that is currently running was triggered during this time. + * Specify the date and time in the following pattern: `yyyy-MM-dd'T'HH:mm:ss.SSSZ`. + */ + SEARCH_NEST_FIRE_TIME_FROM("nextFireTimeFrom"), + + /** + * This argument defines the end of a range of time that matches if the job that is currently running was triggered during this time. + * Specify the date and time in the following pattern: `yyyy-MM-dd'T'HH:mm:ss.SSSZ`. + */ + SEARCH_NEST_FIRE_TIME_TO("nextFireTimeTo"), + + /** + * This argument defines the job label. + */ + SEARCH_JOB_LABEL("jobLabel"), + + /** + * This argument defines the Resource label. + */ + SEARCH_JOB_RESOURCE_LABEL("resourceLabel"), + + /** + * This argument defines the job description. + */ + SEARCH_JOB_DESCRIPTION("description"), + /** * Can be used multiple times inFolder createInFolder a list of jobIDs inFolder update */ diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/jobs/JobsService.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/jobs/JobsService.java index b78de09a..b53788d5 100644 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/jobs/JobsService.java +++ b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/jobs/JobsService.java @@ -25,18 +25,13 @@ import com.jaspersoft.jasperserver.dto.job.ClientReportJob; import com.jaspersoft.jasperserver.dto.job.wrappers.ClientCalendarNameListWrapper; import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.AbstractAdapter; -import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.jobs.calendar.CalendarType; import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.jobs.calendar.SingleCalendarOperationsAdapter; import com.jaspersoft.jasperserver.jaxrs.client.core.Callback; import com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest; -import com.jaspersoft.jasperserver.jaxrs.client.core.MimeTypeUtil; import com.jaspersoft.jasperserver.jaxrs.client.core.RequestExecution; import com.jaspersoft.jasperserver.jaxrs.client.core.SessionStorage; import com.jaspersoft.jasperserver.jaxrs.client.core.ThreadPoolUtil; -import com.jaspersoft.jasperserver.jaxrs.client.core.enums.JRSVersion; import com.jaspersoft.jasperserver.jaxrs.client.core.operationresult.OperationResult; -import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.Job; -import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.jaxb.wrappers.CalendarNameListWrapper; import static com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest.buildRequest; @@ -64,40 +59,9 @@ public SingleJobOperationsAdapter job(long jobId) { public SingleJobOperationsAdapter job(ClientReportJob reportJob) { return new SingleJobOperationsAdapter(sessionStorage, reportJob); } -@Deprecated - public OperationResult scheduleReport(ClientReportJob report) { - JerseyRequest request = buildRequest(sessionStorage, ClientReportJob.class, new String[]{SERVICE_URI}, new JobValidationErrorHandler()); - if (sessionStorage.getConfiguration().getJrsVersion().compareTo(JRSVersion.v5_5_0) > 0) { - request.setContentType(MimeTypeUtil.toCorrectContentMime(sessionStorage.getConfiguration(), "application/job+{mime}")); - request.setAccept(MimeTypeUtil.toCorrectAcceptMime(sessionStorage.getConfiguration(), "application/job+{mime}")); - } else { - request.setContentType("application/job+json"); - request.setAccept("application/job+json"); - } - return request.put(report); - } -@Deprecated - public RequestExecution asyncScheduleReport(final ClientReportJob report, final Callback, R> callback) { - final JerseyRequest request = buildRequest(sessionStorage, ClientReportJob.class, new String[]{SERVICE_URI}, new JobValidationErrorHandler()); - if (sessionStorage.getConfiguration().getJrsVersion().compareTo(JRSVersion.v5_5_0) > 0) { - request.setContentType(MimeTypeUtil.toCorrectContentMime(sessionStorage.getConfiguration(), "application/job+{mime}")); - request.setAccept(MimeTypeUtil.toCorrectAcceptMime(sessionStorage.getConfiguration(), "application/job+{mime}")); - } else { - request.setContentType("application/job+json"); - request.setAccept("application/job+json"); - } - RequestExecution task = new RequestExecution(new Runnable() { - @Override - public void run() { - callback.execute(request.put(report)); - } - }); - ThreadPoolUtil.runAsynchronously(task); - return task; - } public OperationResult allCalendars() { - return calendar((ClientJobCalendar.Type )null); + return calendar((ClientJobCalendar.Type) null); } public RequestExecution asyncCalendar(final Callback, R> callback) { @@ -134,81 +98,4 @@ public SingleCalendarOperationsAdapter calendar(String calendarName) { return new SingleCalendarOperationsAdapter(sessionStorage, calendarName); } - - /** - * @deprecated Replaced by {@link com.jaspersoft.jasperserver.jaxrs.client.apiadapters.jobs.JobsService#scheduleReport(com.jaspersoft.jasperserver.dto.job.ClientReportJob)}. - */ - public OperationResult scheduleReport(Job report) { - JerseyRequest request = buildRequest(sessionStorage, Job.class, new String[]{SERVICE_URI}, new JobValidationErrorHandler()); - if (sessionStorage.getConfiguration().getJrsVersion().compareTo(JRSVersion.v5_5_0) > 0) { - request.setContentType(MimeTypeUtil.toCorrectContentMime(sessionStorage.getConfiguration(), "application/job+{mime}")); - request.setAccept(MimeTypeUtil.toCorrectAcceptMime(sessionStorage.getConfiguration(), "application/job+{mime}")); - } else { - request.setContentType("application/job+json"); - request.setAccept("application/job+json"); - } - return request.put(report); - } - /** - * @deprecated Replaced by {@link com.jaspersoft.jasperserver.jaxrs.client.apiadapters.jobs.JobsService#asyncScheduleReport(com.jaspersoft.jasperserver.dto.job.ClientReportJob, com.jaspersoft.jasperserver.jaxrs.client.core.Callback)}. - */ - public RequestExecution asyncScheduleReport(final Job report, final Callback, R> callback) { - final JerseyRequest request = buildRequest(sessionStorage, Job.class, new String[]{SERVICE_URI}, new JobValidationErrorHandler()); - if (sessionStorage.getConfiguration().getJrsVersion().compareTo(JRSVersion.v5_5_0) > 0) { - request.setContentType(MimeTypeUtil.toCorrectContentMime(sessionStorage.getConfiguration(), "application/job+{mime}")); - request.setAccept(MimeTypeUtil.toCorrectAcceptMime(sessionStorage.getConfiguration(), "application/job+{mime}")); - } else { - request.setContentType("application/job+json"); - request.setAccept("application/job+json"); - } - RequestExecution task = new RequestExecution(new Runnable() { - @Override - public void run() { - callback.execute(request.put(report)); - } - }); - ThreadPoolUtil.runAsynchronously(task); - return task; - } - /** - * @deprecated Replaced by {@link JobsService#allCalendars()}. - */ - public OperationResult calendars() { - return calendars(null); - } - - /** - * @deprecated Replaced by {@link JobsService#asyncCalendar(com.jaspersoft.jasperserver.jaxrs.client.core.Callback)}. - */ - public RequestExecution asyncCalendars(final Callback, R> callback) { - return asyncCalendars(null, callback); - } - /** - * @deprecated Replaced by {@link JobsService#calendar(com.jaspersoft.jasperserver.dto.job.ClientJobCalendar.Type)}. - */ - public OperationResult calendars(CalendarType type) { - JerseyRequest request = buildRequest(sessionStorage, CalendarNameListWrapper.class, new String[]{SERVICE_URI, CALENDARS}); - if (type != null) { - request.addParam("calendarType", type.name().toLowerCase()); - } - return request.get(); - } - - /** - * @deprecated Replaced by {@link JobsService#asyncCalendar(com.jaspersoft.jasperserver.dto.job.ClientJobCalendar.Type, com.jaspersoft.jasperserver.jaxrs.client.core.Callback)}. - */ - public RequestExecution asyncCalendars(final CalendarType type, final Callback, R> callback) { - final JerseyRequest request = buildRequest(sessionStorage, CalendarNameListWrapper.class, new String[]{SERVICE_URI, CALENDARS}); - if (type != null) { - request.addParam("calendarType", type.name().toLowerCase()); - } - RequestExecution task = new RequestExecution(new Runnable() { - @Override - public void run() { - callback.execute(request.get()); - } - }); - ThreadPoolUtil.runAsynchronously(task); - return task; - } } diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/jobs/SingleJobOperationsAdapter.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/jobs/SingleJobOperationsAdapter.java index dcc57468..338ae084 100644 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/jobs/SingleJobOperationsAdapter.java +++ b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/jobs/SingleJobOperationsAdapter.java @@ -32,8 +32,6 @@ import com.jaspersoft.jasperserver.jaxrs.client.core.ThreadPoolUtil; import com.jaspersoft.jasperserver.jaxrs.client.core.enums.JRSVersion; import com.jaspersoft.jasperserver.jaxrs.client.core.operationresult.OperationResult; -import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.Job; -import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.JobState; import static com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest.buildRequest; @@ -172,93 +170,4 @@ public void run() { ThreadPoolUtil.runAsynchronously(task); return task; } - - /** - * @deprecated Replaced by {@link SingleJobOperationsAdapter#update(com.jaspersoft.jasperserver.dto.job.ClientReportJob)}. - */ - public OperationResult update(Job job) { - JerseyRequest request = buildRequest(sessionStorage, Job.class, new String[]{SERVICE_URI, jobId}, new JobValidationErrorHandler()); - if (sessionStorage.getConfiguration().getJrsVersion().compareTo(JRSVersion.v5_5_0) > 0) { - request.setContentType(MimeTypeUtil.toCorrectContentMime(sessionStorage.getConfiguration(), "application/job+{mime}")); - request.setAccept(MimeTypeUtil.toCorrectAcceptMime(sessionStorage.getConfiguration(), "application/job+{mime}")); - } else { - request.setContentType("application/job+json"); - request.setAccept("application/job+json"); - } - return request.post(job); - } - /** - * @deprecated Replaced by {@link SingleJobOperationsAdapter#asyncUpdate(com.jaspersoft.jasperserver.dto.job.ClientReportJob, com.jaspersoft.jasperserver.jaxrs.client.core.Callback)}. - */ - public RequestExecution asyncUpdate(final Job job, final Callback, R> callback) { - final JerseyRequest request = buildRequest(sessionStorage, Job.class, new String[]{SERVICE_URI, jobId}, new JobValidationErrorHandler()); - if (sessionStorage.getConfiguration().getJrsVersion().compareTo(JRSVersion.v5_5_0) > 0) { - request.setContentType(MimeTypeUtil.toCorrectContentMime(sessionStorage.getConfiguration(), "application/job+{mime}")); - request.setAccept(MimeTypeUtil.toCorrectAcceptMime(sessionStorage.getConfiguration(), "application/job+{mime}")); - } else { - request.setContentType("application/job+json"); - request.setAccept("application/job+json"); - } - RequestExecution task = new RequestExecution(new Runnable() { - @Override - public void run() { - callback.execute(request.post(job)); - } - }); - ThreadPoolUtil.runAsynchronously(task); - return task; - } - - /** - * @deprecated Replaced by {@link SingleJobOperationsAdapter#asyncJobState(com.jaspersoft.jasperserver.jaxrs.client.core.Callback)}. - */ - public RequestExecution asyncState(final Callback, R> callback) { - final JerseyRequest request = buildRequest(sessionStorage, JobState.class, new String[]{SERVICE_URI, jobId, STATE}); - RequestExecution task = new RequestExecution(new Runnable() { - @Override - public void run() { - callback.execute(request.get()); - } - }); - ThreadPoolUtil.runAsynchronously(task); - return task; - } - /** - * @deprecated Replaced by {@link com.jaspersoft.jasperserver.jaxrs.client.apiadapters.jobs.SingleJobOperationsAdapter#jobState()}. - */ - public OperationResult state() { - return buildRequest(sessionStorage, JobState.class, new String[]{SERVICE_URI, jobId, STATE}).get(); - } - - /** - * @deprecated Replaced by {@link SingleJobOperationsAdapter#asyncGetJob(com.jaspersoft.jasperserver.jaxrs.client.core.Callback)}. - */ - public RequestExecution asyncGet(final Callback, R> callback) { - final JerseyRequest request = buildRequest(sessionStorage, Job.class, new String[]{SERVICE_URI, jobId}); - if (sessionStorage.getConfiguration().getJrsVersion().compareTo(JRSVersion.v5_5_0) > 0) { - request.setAccept(MimeTypeUtil.toCorrectAcceptMime(sessionStorage.getConfiguration(), "application/job+{mime}")); - } else { - request.setAccept("application/job+json"); - } - RequestExecution task = new RequestExecution(new Runnable() { - @Override - public void run() { - callback.execute(request.get()); - } - }); - ThreadPoolUtil.runAsynchronously(task); - return task; - } - /** - * @deprecated Replaced by {@link com.jaspersoft.jasperserver.jaxrs.client.apiadapters.jobs.SingleJobOperationsAdapter#getJob()}. - */ - public OperationResult get() { - JerseyRequest request = buildRequest(sessionStorage, Job.class, new String[]{SERVICE_URI, jobId}); - if (sessionStorage.getConfiguration().getJrsVersion().compareTo(JRSVersion.v5_5_0) > 0) { - request.setAccept(MimeTypeUtil.toCorrectAcceptMime(sessionStorage.getConfiguration(), "application/job+{mime}")); - } else { - request.setAccept("application/job+json"); - } - return request.get(); - } } diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/jobs/calendar/SingleCalendarOperationsAdapter.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/jobs/calendar/SingleCalendarOperationsAdapter.java index b2dffc3e..5fd4369f 100644 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/jobs/calendar/SingleCalendarOperationsAdapter.java +++ b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/jobs/calendar/SingleCalendarOperationsAdapter.java @@ -29,8 +29,7 @@ import com.jaspersoft.jasperserver.jaxrs.client.core.ThreadPoolUtil; import com.jaspersoft.jasperserver.jaxrs.client.core.UrlUtils; import com.jaspersoft.jasperserver.jaxrs.client.core.operationresult.OperationResult; -import com.jaspersoft.jasperserver.jaxrs.client.core.operationresult.WithEntityOperationResult; -import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.ReportJobCalendar; + import javax.ws.rs.core.MultivaluedHashMap; import javax.ws.rs.core.MultivaluedMap; @@ -46,7 +45,7 @@ public class SingleCalendarOperationsAdapter extends AbstractAdapter { public SingleCalendarOperationsAdapter(SessionStorage sessionStorage, String calendarName) { super(sessionStorage); this.calendarName = calendarName; - params = new MultivaluedHashMap(); + params = new MultivaluedHashMap<>(); } public SingleCalendarOperationsAdapter parameter(CalendarParameter parameter, String value) { @@ -106,126 +105,4 @@ public void run() { return task; } - /** - * @deprecated Replaced by {@link com.jaspersoft.jasperserver.jaxrs.client.apiadapters.jobs.calendar.SingleCalendarOperationsAdapter#getCalendar()} . - */ - public OperationResult get() { - OperationResult result = buildRequest(sessionStorage, ReportJobCalendar.class, new String[]{JOBS, CALENDARS, calendarName}).get(); - return convertToLocalCalendarType(result); - } - - /** - * @deprecated Replaced by {@link SingleCalendarOperationsAdapter#asyncGetCalendar(com.jaspersoft.jasperserver.jaxrs.client.core.Callback)} . - */ - public RequestExecution asyncGet(final Callback, R> callback) { - final JerseyRequest request = buildRequest(sessionStorage, ReportJobCalendar.class, new String[]{JOBS, CALENDARS, calendarName}); - RequestExecution task = new RequestExecution(new Runnable() { - @Override - public void run() { - callback.execute(convertToLocalCalendarType(request.get())); - } - }); - ThreadPoolUtil.runAsynchronously(task); - return task; - } - - /** - * @deprecated Replaced by {@link SingleCalendarOperationsAdapter#createNewCalendar(com.jaspersoft.jasperserver.dto.job.ClientJobCalendar)} . - */ - public OperationResult createNew(com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.calendars.Calendar calendarDescriptor) { - JerseyRequest request = buildRequest(sessionStorage, ReportJobCalendar.class, new String[]{JOBS, CALENDARS, calendarName}); - request.addParams(params); - return request.put(calendarDescriptor); - } - /** - * @deprecated Replaced by {@link SingleCalendarOperationsAdapter#asyncCreateNewCalendar(com.jaspersoft.jasperserver.dto.job.ClientJobCalendar, com.jaspersoft.jasperserver.jaxrs.client.core.Callback)} . - */ - public RequestExecution asyncCreateNew(final com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.calendars.Calendar calendarDescriptor, final Callback, R> callback) { - final JerseyRequest request = buildRequest(sessionStorage, ReportJobCalendar.class, new String[]{JOBS, CALENDARS, calendarName}); - request.addParams(params); - RequestExecution task = new RequestExecution(new Runnable() { - @Override - public void run() { - callback.execute(request.put(calendarDescriptor)); - } - }); - ThreadPoolUtil.runAsynchronously(task); - return task; - } - /** - * @deprecated Use server DTO. - */ - private void setCommonCalendarFields(com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.calendars.Calendar target, ReportJobCalendar src) { - target.setCalendarType(CalendarType.valueOf(src.getCalendarType())); - target.setDescription(src.getDescription()); - target.setTimeZone(src.getTimeZone()); - } - /** - * @deprecated Use server DTO. - */ - private OperationResult convertToLocalCalendarType(OperationResult source) { - ReportJobCalendar reportJobCalendar = source.getEntity(); - CalendarType calendarType = CalendarType.valueOf(reportJobCalendar.getCalendarType()); - com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.calendars.Calendar localCalendar = null; - switch (calendarType) { - case annual: { - com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.calendars.AnnualCalendar annualCalendar = new com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.calendars.AnnualCalendar(); - setCommonCalendarFields(annualCalendar, reportJobCalendar); - annualCalendar.setDataSorted(reportJobCalendar.isDataSorted()); - annualCalendar.setExcludeDays(reportJobCalendar.getExcludeDays()); - localCalendar = annualCalendar; - break; - } - case base: { - com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.calendars.BaseCalendar baseCalendar = new com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.calendars.BaseCalendar(); - setCommonCalendarFields(baseCalendar, reportJobCalendar); - localCalendar = baseCalendar; - break; - } - case cron: { - com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.calendars.CronCalendar cronCalendar = new com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.calendars.CronCalendar(); - setCommonCalendarFields(cronCalendar, reportJobCalendar); - cronCalendar.setCronExpression(reportJobCalendar.getCronExpression()); - localCalendar = cronCalendar; - break; - } - case daily: { - com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.calendars.DailyCalendar dailyCalendar = new com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.calendars.DailyCalendar(); - setCommonCalendarFields(dailyCalendar, reportJobCalendar); - dailyCalendar.setInvertTimeRange(reportJobCalendar.isInvertTimeRange()); - dailyCalendar.setRangeEndingCalendar(reportJobCalendar.getRangeEndingCalendar()); - dailyCalendar.setRangeStartingCalendar(reportJobCalendar.getRangeStartingCalendar()); - localCalendar = dailyCalendar; - break; - } - case holiday: { - com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.calendars.HolidayCalendar holidayCalendar = new com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.calendars.HolidayCalendar(); - setCommonCalendarFields(holidayCalendar, reportJobCalendar); - holidayCalendar.setDataSorted(reportJobCalendar.isDataSorted()); - holidayCalendar.setExcludeDays(reportJobCalendar.getExcludeDays()); - localCalendar = holidayCalendar; - break; - } - case monthly: { - com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.calendars.MonthlyCalendar monthlyCalendar = new com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.calendars.MonthlyCalendar(); - setCommonCalendarFields(monthlyCalendar, reportJobCalendar); - monthlyCalendar.setExcludeDaysFlags(reportJobCalendar.getExcludeDaysFlags()); - localCalendar = monthlyCalendar; - break; - } - case weekly: { - com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.calendars.WeeklyCalendar weeklyCalendar = new com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.calendars.WeeklyCalendar(); - setCommonCalendarFields(weeklyCalendar, reportJobCalendar); - weeklyCalendar.setExcludeDaysFlags(reportJobCalendar.getExcludeDaysFlags()); - localCalendar = weeklyCalendar; - break; - } - } - final com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.calendars.Calendar finalLocalCalendar = localCalendar; - return new WithEntityOperationResult(source.getResponse(), com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.calendars.Calendar.class) {{ - this.entity = finalLocalCalendar; - }}; - } - - } diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/permissions/PermissionResourceRequestAdapter.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/permissions/PermissionResourceRequestAdapter.java deleted file mode 100644 index ff0a48f6..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/permissions/PermissionResourceRequestAdapter.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ -package com.jaspersoft.jasperserver.jaxrs.client.apiadapters.permissions; - -import com.jaspersoft.jasperserver.dto.permissions.RepositoryPermissionListWrapper; -import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.AbstractAdapter; -import com.jaspersoft.jasperserver.jaxrs.client.core.Callback; -import com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest; -import com.jaspersoft.jasperserver.jaxrs.client.core.MimeTypeUtil; -import com.jaspersoft.jasperserver.jaxrs.client.core.RequestExecution; -import com.jaspersoft.jasperserver.jaxrs.client.core.SessionStorage; -import com.jaspersoft.jasperserver.jaxrs.client.core.ThreadPoolUtil; -import com.jaspersoft.jasperserver.jaxrs.client.core.UrlUtils; -import com.jaspersoft.jasperserver.jaxrs.client.core.operationresult.OperationResult; - -import javax.ws.rs.core.MultivaluedHashMap; -import javax.ws.rs.core.MultivaluedMap; -import java.util.ArrayList; -import java.util.Arrays; - -/** - * @deprecated Replaced with @Link {@link com.jaspersoft.jasperserver.jaxrs.client.apiadapters.permissions.BatchPermissionsAdapter} - * and @Link {@link com.jaspersoft.jasperserver.jaxrs.client.apiadapters.permissions.SinglePermissionsAdapter} - */ -@Deprecated -public class PermissionResourceRequestAdapter extends AbstractAdapter { - - public static final String PERMISSIONS_URI = "permissions"; - private ArrayList path = new ArrayList(); - private final String resourceUri; - private final MultivaluedMap params; - - public PermissionResourceRequestAdapter(SessionStorage sessionStorage, String resourceUri) { - super(sessionStorage); - this.resourceUri = resourceUri; - params = new MultivaluedHashMap(); - } - - public SinglePermissionRecipientRequestAdapter permissionRecipient(PermissionRecipient recipient, String name) { - String protocol = recipient.getProtocol(); - String uri = protocol + ":%2F" + name; - return new SinglePermissionRecipientRequestAdapter(sessionStorage, resourceUri, uri); - } - - public OperationResult createOrUpdate(RepositoryPermissionListWrapper permissions) { - JerseyRequest request = buildRequest(); - request.setContentType(MimeTypeUtil.toCorrectContentMime(sessionStorage.getConfiguration(), "application/collection+{mime}")); - return request.put(permissions); - } - - public RequestExecution asyncCreateOrUpdate(final RepositoryPermissionListWrapper permissions, final Callback, R> callback) { - final JerseyRequest request = buildRequest(); - request.setContentType(MimeTypeUtil.toCorrectContentMime(sessionStorage.getConfiguration(), "application/collection+{mime}")); - RequestExecution task = new RequestExecution(new Runnable() { - @Override - public void run() { - callback.execute(request.put(permissions)); - } - }); - ThreadPoolUtil.runAsynchronously(task); - return task; - } - - - - public PermissionResourceRequestAdapter param(PermissionResourceParameter resourceParam, String value) { - params.add(resourceParam.getParamName(), UrlUtils.encode(value)); - return this; - } - - public OperationResult get(){ - JerseyRequest request = buildRequest(); - request.addParams(params); - return request.get(); - } - - public RequestExecution asyncGet(final Callback, R> callback) { - final JerseyRequest request = buildRequest(); - request.addParams(params); - RequestExecution task = new RequestExecution(new Runnable() { - @Override - public void run() { - callback.execute(request.get()); - } - }); - ThreadPoolUtil.runAsynchronously(task); - return task; - } - - public OperationResult delete(){ - return buildRequest().delete(); - } - - public RequestExecution asyncDelete(final Callback, R> callback) { - final JerseyRequest request = buildRequest(); - RequestExecution task = new RequestExecution(new Runnable() { - @Override - public void run() { - callback.execute(request.delete()); - } - }); - ThreadPoolUtil.runAsynchronously(task); - return task; - } - - protected JerseyRequest buildRequest() { - path.add(PERMISSIONS_URI); - path.addAll(Arrays.asList(resourceUri.split("/"))); - return JerseyRequest.buildRequest(sessionStorage, RepositoryPermissionListWrapper.class, path.toArray(new String[path.size()])); - } -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/permissions/PermissionsService.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/permissions/PermissionsService.java index 0d64c057..53cc82b5 100644 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/permissions/PermissionsService.java +++ b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/permissions/PermissionsService.java @@ -36,7 +36,6 @@ public class PermissionsService extends AbstractAdapter { - public static final String SERVICE_URI = "/permissions"; public String resourceUri; public PermissionsService(SessionStorage sessionStorage) { @@ -51,17 +50,6 @@ public PermissionsService forResource(String resourceUri) { return this; } - /** - * @deprecated Use forResource(resourceUri).permission(permission) API - */ - @Deprecated - public PermissionResourceRequestAdapter resource(String resourceUri) { - if ("".equals(resourceUri)) { - throw new IllegalArgumentException("'resourceUri' mustn't be an empty string"); - } - return new PermissionResourceRequestAdapter(sessionStorage, resourceUri); - } - public SinglePermissionsAdapter permission() { return new SinglePermissionsAdapter(sessionStorage, resourceUri); @@ -80,55 +68,4 @@ public SinglePermissionsAdapter permission(RepositoryPermission permission) { public BatchPermissionsAdapter permissions(RepositoryPermissionListWrapper permissions) { return new BatchPermissionsAdapter(sessionStorage, permissions); } - - /** - * @deprecated - */ - @Deprecated - public OperationResult createNew(RepositoryPermission permission) { - return buildRequest(sessionStorage, Object.class, new String[]{SERVICE_URI}, new DefaultErrorHandler()).post(permission); - } - - /** - * @deprecated - */ - @Deprecated - public RequestExecution asyncCreateNew(final RepositoryPermission permission, final Callback callback) { - final JerseyRequest request = buildRequest(sessionStorage, Object.class, new String[]{SERVICE_URI}); - RequestExecution task = new RequestExecution(new Runnable() { - @Override - public void run() { - callback.execute(request.post(permission)); - } - }); - ThreadPoolUtil.runAsynchronously(task); - return task; - } - - /** - * @deprecated - */ - @Deprecated - public OperationResult createNew(RepositoryPermissionListWrapper permissions) { - JerseyRequest request = buildRequest(sessionStorage, Object.class, new String[]{SERVICE_URI}); - request.setContentType(MimeTypeUtil.toCorrectContentMime(sessionStorage.getConfiguration(), "application/collection+{mime}")); - return request.post(permissions); - } - - /** - * @deprecated - */ - @Deprecated - public RequestExecution asyncCreateNew(final RepositoryPermissionListWrapper permissions, final Callback callback) { - final JerseyRequest request = buildRequest(sessionStorage, Object.class, new String[]{SERVICE_URI}); - request.setContentType(MimeTypeUtil.toCorrectContentMime(sessionStorage.getConfiguration(), "application/collection+{mime}")); - RequestExecution task = new RequestExecution(new Runnable() { - @Override - public void run() { - callback.execute(request.post(permissions)); - } - }); - ThreadPoolUtil.runAsynchronously(task); - return task; - } } diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/permissions/SinglePermissionRecipientRequestAdapter.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/permissions/SinglePermissionRecipientRequestAdapter.java deleted file mode 100644 index f08cadbe..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/permissions/SinglePermissionRecipientRequestAdapter.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ -package com.jaspersoft.jasperserver.jaxrs.client.apiadapters.permissions; - -import com.jaspersoft.jasperserver.dto.permissions.RepositoryPermission; -import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.AbstractAdapter; -import com.jaspersoft.jasperserver.jaxrs.client.core.*; -import com.jaspersoft.jasperserver.jaxrs.client.core.operationresult.OperationResult; -import java.util.ArrayList; - -import static com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest.buildRequest; -import static java.util.Arrays.asList; - -/** - * @deprecated Replaced with @Link {@link com.jaspersoft.jasperserver.jaxrs.client.apiadapters.permissions.BatchPermissionsAdapter} - * and @Link {@link com.jaspersoft.jasperserver.jaxrs.client.apiadapters.permissions.SinglePermissionsAdapter} - */ -public class SinglePermissionRecipientRequestAdapter extends AbstractAdapter { - public static final String SERVICE_URI = "permissions"; - private final String recipient; - private ArrayList path = new ArrayList(); - - public SinglePermissionRecipientRequestAdapter(SessionStorage sessionStorage, String resourceUri, String recipient) { - super(sessionStorage); - this.path.add(SERVICE_URI); - this.path.addAll(asList(resourceUri.split("/"))); - this.recipient = recipient; - } - - public OperationResult get() { - return getBuilder(RepositoryPermission.class).get(); - } - - public RequestExecution asyncGet(final Callback, R> callback) { - final JerseyRequest request = getBuilder(RepositoryPermission.class); - RequestExecution task = new RequestExecution(new Runnable() { - @Override - public void run() { - callback.execute(request.get()); - } - }); - ThreadPoolUtil.runAsynchronously(task); - return task; - } - - public OperationResult createOrUpdate(RepositoryPermission permission) { - return getBuilder(RepositoryPermission.class).put(permission); - } - - public RequestExecution asyncCreateOrUpdate(final RepositoryPermission permission, final Callback, R> callback) { - final JerseyRequest request = getBuilder(RepositoryPermission.class); - RequestExecution task = new RequestExecution(new Runnable() { - @Override - public void run() { - callback.execute(request.put(permission)); - } - }); - ThreadPoolUtil.runAsynchronously(task); - return task; - } - - public OperationResult delete() { - return getBuilder(Object.class).delete(); - } - - public RequestExecution asyncDelete(final Callback callback) { - final JerseyRequest request = getBuilder(Object.class); - RequestExecution task = new RequestExecution(new Runnable() { - @Override - public void run() { - callback.execute(request.delete()); - } - }); - ThreadPoolUtil.runAsynchronously(task); - return task; - } - - private JerseyRequest getBuilder(Class responseClass) { - - JerseyRequest request = buildRequest(sessionStorage, responseClass, path.toArray(new String[path.size()])); - request.addMatrixParam("recipient", recipient); - return request; - } -} \ No newline at end of file diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/ExportExecutionRequestBuilder.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/ExportExecutionRequestBuilder.java deleted file mode 100644 index b48d630b..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/ExportExecutionRequestBuilder.java +++ /dev/null @@ -1,212 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting; - -import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.AbstractAdapter; -import com.jaspersoft.jasperserver.jaxrs.client.core.Callback; -import com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest; -import com.jaspersoft.jasperserver.jaxrs.client.core.RequestExecution; -import com.jaspersoft.jasperserver.jaxrs.client.core.SessionStorage; -import com.jaspersoft.jasperserver.jaxrs.client.core.ThreadPoolUtil; -import com.jaspersoft.jasperserver.jaxrs.client.core.exceptions.JSClientException; -import com.jaspersoft.jasperserver.jaxrs.client.core.operationresult.OperationResult; -import com.jaspersoft.jasperserver.jaxrs.client.dto.reports.Attachment; -import com.jaspersoft.jasperserver.jaxrs.client.dto.reports.AttachmentDescriptor; -import com.jaspersoft.jasperserver.jaxrs.client.dto.reports.ExportDescriptor; -import com.jaspersoft.jasperserver.jaxrs.client.dto.reports.HtmlReport; -import com.jaspersoft.jasperserver.jaxrs.client.dto.reports.ReportExecutionStatusEntity; -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.List; - -import static com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest.buildRequest; -@Deprecated -public class ExportExecutionRequestBuilder extends AbstractAdapter { - - public static final String REPORT_EXECUTIONS = "reportExecutions"; - public static final String EXPORTS = "exports"; - public static final String OUTPUT_RESOURCE = "outputResource"; - public static final String ATTACHMENTS = "attachments"; - public static final String STATUS = "status"; - private String requestId; - private String exportId; - - public ExportExecutionRequestBuilder(SessionStorage sessionStorage, String requestId, String exportId) { - super(sessionStorage); - this.requestId = requestId; - this.exportId = exportId; - } - - /** - * OperationResult should be parametrized with String if you're exporting HTML, - * in other cases it should be parametrized with InputStream - */ - private OperationResult outputResource(boolean isHtmlExport) { - return buildRequest(sessionStorage, isHtmlExport ? String.class : InputStream.class, - new String[]{REPORT_EXECUTIONS, requestId, EXPORTS, exportId, OUTPUT_RESOURCE}) - .get(); - } - - public OperationResult outputResource() { - return outputResource(false); - } - - public RequestExecution asyncOutputResource(final Callback, R> callback) { - final JerseyRequest request = - buildRequest(sessionStorage, InputStream.class, - new String[]{REPORT_EXECUTIONS, requestId, EXPORTS, exportId, OUTPUT_RESOURCE}); - - RequestExecution task = new RequestExecution(new Runnable() { - @Override - public void run() { - callback.execute(request.get()); - } - }); - - ThreadPoolUtil.runAsynchronously(task); - return task; - } - - public OperationResult attachment(String attachmentId) { - - if ("".equals(attachmentId) || "/".equals(attachmentId)) - throw new IllegalArgumentException("'attachmentId' mustn't be an empty string"); - - while (!"ready".equals(status().getEntity().getValue())) { - try { - Thread.sleep(500); - } catch (InterruptedException ignored) { - } - } - - return buildRequest(sessionStorage, InputStream.class, - new String[]{REPORT_EXECUTIONS, requestId, EXPORTS, exportId, ATTACHMENTS, attachmentId}) - .get(); - } - - public RequestExecution asyncAttachment(final String attachmentId, final Callback, R> callback) { - - if ("".equals(attachmentId) || "/".equals(attachmentId)) - throw new IllegalArgumentException("'attachmentId' mustn't be an empty string"); - - final JerseyRequest request = - buildRequest(sessionStorage, InputStream.class, - new String[]{REPORT_EXECUTIONS, requestId, EXPORTS, exportId, ATTACHMENTS, attachmentId}); - - RequestExecution task = new RequestExecution(new Runnable() { - @Override - public void run() { - while (!"ready".equals(status().getEntity().getValue())) { - try { - Thread.sleep(500); - } catch (InterruptedException ignored) { - } - } - callback.execute(request.get()); - } - }); - - ThreadPoolUtil.runAsynchronously(task); - return task; - } - - public OperationResult status() { - return buildRequest(sessionStorage, ReportExecutionStatusEntity.class, - new String[]{REPORT_EXECUTIONS, requestId, EXPORTS, exportId, STATUS}) - .get(); - } - - public RequestExecution asyncStatus(final Callback, R> callback) { - final JerseyRequest request = - buildRequest(sessionStorage, ReportExecutionStatusEntity.class, - new String[]{REPORT_EXECUTIONS, requestId, EXPORTS, exportId, STATUS}); - - RequestExecution task = new RequestExecution(new Runnable() { - @Override - public void run() { - callback.execute(request.get()); - } - }); - - ThreadPoolUtil.runAsynchronously(task); - return task; - } - - public HtmlReport htmlReport(ExportDescriptor htmlExport) { - //if (exportId.toLowerCase().startsWith("html") && htmlExport.getId().toLowerCase().startsWith("html")) { - HtmlReport htmlReport = new HtmlReport(htmlExport.getId()); - - OperationResult markup = outputResource(true); - htmlReport.setHtml(markup.getEntity()); - - List attachments = htmlExport.getAttachments(); - if (attachments != null) { - for (AttachmentDescriptor attachmentDescriptor : attachments) { - String fileName = attachmentDescriptor.getFileName(); - OperationResult streamOperationResult = attachment(fileName); - - Attachment attachment = new Attachment(); - attachment.setName(attachmentDescriptor.getFileName()); - attachment.setMimeType(attachmentDescriptor.getContentType()); - attachment.setContent(toByteArray(streamOperationResult.getEntity())); - - htmlReport.addAttachment(attachment); - } - } - - return htmlReport; - //} - //throw new JSClientException("Output format is not 'HTML'"); - } - - public RequestExecution asyncHtmlReport(final ExportDescriptor htmlExport, final Callback callback) { - RequestExecution task = new RequestExecution(new Runnable() { - @Override - public void run() { - callback.execute(htmlReport(htmlExport)); - } - }); - - ThreadPoolUtil.runAsynchronously(task); - return task; - } - - private byte[] toByteArray(InputStream is) { - try { - List bytes = new ArrayList(); - byte[] buff = new byte[1024]; - while (is.read(buff) != -1) { - for (byte b : buff) - bytes.add(b); - } - - byte[] result = new byte[bytes.size()]; - for (int i = 0; i < bytes.size(); i++) { - result[i] = bytes.get(i); - } - return result; - } catch (IOException e) { - throw new JSClientException("Error while reading thumbnail content", e); - } - } -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/PageRange.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/PageRange.java deleted file mode 100644 index 1a00b229..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/PageRange.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting; -/*** - * @deprecated use @Link {@link com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting.util.PageRange} - * */ -@Deprecated -public class PageRange { - - private final long startIndex; - private final long endIndex; - - public PageRange(long startIndex, long endIndex){ - this.startIndex = startIndex; - this.endIndex = endIndex; - } - - public String getRange(){ - if (startIndex == endIndex) - return String.valueOf(startIndex); - return startIndex + "-" + endIndex; - } -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/ReportAndJobSearchParameter.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/ReportAndJobSearchParameter.java deleted file mode 100644 index 8ecade4b..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/ReportAndJobSearchParameter.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting; -/*** - * @deprecated use @Link {@link com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting.util.ReportSearchParameter} - * */ -@Deprecated -public enum ReportAndJobSearchParameter { - - /** - * This string matches the repository URI of the running thumbnail, relative the - * currently logged-in user’s organization. - */ - REPORT_URI("reportURI"), - - /** - * For scheduler jobs, this argument matches the ID of the job that triggered - * the running thumbnail. - */ - JOB_ID("jobID"), - - /** - * For scheduler jobs, this argument matches the name of the job that - * triggered the running thumbnail. - */ - JOB_LABEL("jobLabel"), - - /** - * For scheduler jobs, this argument matches the user ID that created the job. - */ - USER_NAME("userName"), - - /** - * For scheduler jobs, the fire time arguments define a range of time that - * matches if the job that is currently running was triggered during this time. - * You can specify either or both of the arguments. Specify the date and time - * in the following pattern: fireTimeTo yyyy-MM-dd'T'HH:mmZ. - */ - FIRE_TIME_FROM("fireTimeFrom"), - - /** - * For scheduler jobs, the fire time arguments define a range of time that - * matches if the job that is currently running was triggered during this time. - * You can specify either or both of the arguments. Specify the date and time - * in the following pattern: fireTimeTo yyyy-MM-dd'T'HH:mmZ. - */ - FIRE_TIME_TO("fireTimeTo") - - ; - - private String name; - - private ReportAndJobSearchParameter(String name){ - this.name = name; - } - - public String getName() { - return name; - } -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/ReportExecutionRequestBuilder.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/ReportExecutionRequestBuilder.java deleted file mode 100644 index 8ce8cc67..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/ReportExecutionRequestBuilder.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting; - -import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.AbstractAdapter; -import com.jaspersoft.jasperserver.jaxrs.client.core.*; -import com.jaspersoft.jasperserver.jaxrs.client.core.operationresult.OperationResult; -import com.jaspersoft.jasperserver.jaxrs.client.dto.reports.ExportExecutionDescriptor; -import com.jaspersoft.jasperserver.jaxrs.client.dto.reports.ExportExecutionOptions; -import com.jaspersoft.jasperserver.jaxrs.client.dto.reports.ReportExecutionDescriptor; -import com.jaspersoft.jasperserver.jaxrs.client.dto.reports.ReportExecutionStatusEntity; - -import static com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest.buildRequest; -@Deprecated -public class ReportExecutionRequestBuilder extends AbstractAdapter { - - public static final String REPORT_EXECUTIONS_URI = "reportExecutions"; - public static final String STATUS_URI = "status"; - public static final String EXPORTS_URI = "exports"; - private final String requestId; - - public ReportExecutionRequestBuilder(SessionStorage sessionStorage, String requestId) { - super(sessionStorage); - this.requestId = requestId; - } - - public OperationResult status() { - return buildRequest(sessionStorage, ReportExecutionStatusEntity.class, new String[]{REPORT_EXECUTIONS_URI, requestId, STATUS_URI}) - .get(); - } - - public RequestExecution asyncStatus(final Callback, R> callback) { - final JerseyRequest request = - buildRequest(sessionStorage, ReportExecutionStatusEntity.class, new String[]{REPORT_EXECUTIONS_URI, requestId, STATUS_URI}); - - RequestExecution task = new RequestExecution(new Runnable() { - @Override - public void run() { - callback.execute(request.get()); - } - }); - - ThreadPoolUtil.runAsynchronously(task); - return task; - } - - public OperationResult executionDetails() { - return buildRequest(sessionStorage, ReportExecutionDescriptor.class, new String[]{REPORT_EXECUTIONS_URI, requestId}) - .get(); - } - - public RequestExecution asyncExecutionDetails(final Callback, R> callback) { - final JerseyRequest request = - buildRequest(sessionStorage, ReportExecutionDescriptor.class, new String[]{REPORT_EXECUTIONS_URI, requestId}); - - RequestExecution task = new RequestExecution(new Runnable() { - @Override - public void run() { - callback.execute(request.get()); - } - }); - - ThreadPoolUtil.runAsynchronously(task); - return task; - } - - public OperationResult cancelExecution() { - ReportExecutionStatusEntity statusEntity = new ReportExecutionStatusEntity(); - statusEntity.setValue("cancelled"); - return buildRequest(sessionStorage, ReportExecutionStatusEntity.class, new String[]{REPORT_EXECUTIONS_URI, requestId, STATUS_URI}) - .put(statusEntity); - } - - public RequestExecution asyncCancelExecution(final Callback, R> callback) { - final ReportExecutionStatusEntity statusEntity = new ReportExecutionStatusEntity(); - statusEntity.setValue("cancelled"); - final JerseyRequest request = - buildRequest(sessionStorage, ReportExecutionStatusEntity.class, new String[]{REPORT_EXECUTIONS_URI, requestId, STATUS_URI}); - - RequestExecution task = new RequestExecution(new Runnable() { - @Override - public void run() { - callback.execute(request.put(statusEntity)); - } - }); - - ThreadPoolUtil.runAsynchronously(task); - return task; - } - - public ExportExecutionRequestBuilder export(String exportId) { - return new ExportExecutionRequestBuilder(sessionStorage, requestId, exportId); - } - - public OperationResult runExport(ExportExecutionOptions exportExecutionOptions) { - return buildRequest(sessionStorage, ExportExecutionDescriptor.class, new String[]{REPORT_EXECUTIONS_URI, requestId, EXPORTS_URI}) - .post(exportExecutionOptions); - } - - public RequestExecution asyncRunExport(final ExportExecutionOptions exportExecutionOptions, - final Callback, R> callback) { - final JerseyRequest request = - buildRequest(sessionStorage, ExportExecutionDescriptor.class, new String[]{REPORT_EXECUTIONS_URI, requestId, EXPORTS_URI}); - - RequestExecution task = new RequestExecution(new Runnable() { - @Override - public void run() { - callback.execute(request.post(exportExecutionOptions)); - } - }); - - ThreadPoolUtil.runAsynchronously(task); - return task; - } - -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/ReportOutputFormat.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/ReportOutputFormat.java deleted file mode 100644 index 46795945..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/ReportOutputFormat.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting; -/*** - * @deprecated use @Link {@link com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting.util.ReportOutputFormat} - * */ -@Deprecated -public enum ReportOutputFormat { - - PDF, HTML, XLS, XLSX, RTF, CSV, XML, DOCX, ODT, - ODS, JRPRINT -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/ReportingService.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/ReportingService.java index c252cca0..961d9186 100644 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/ReportingService.java +++ b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/ReportingService.java @@ -23,51 +23,14 @@ import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.AbstractAdapter; import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting.reportexecution.ReportExecutionAdapter; -import com.jaspersoft.jasperserver.jaxrs.client.core.*; -import com.jaspersoft.jasperserver.jaxrs.client.core.operationresult.OperationResult; -import com.jaspersoft.jasperserver.jaxrs.client.dto.reports.ReportExecutionDescriptor; +import com.jaspersoft.jasperserver.jaxrs.client.core.SessionStorage; import com.jaspersoft.jasperserver.jaxrs.client.dto.reports.ReportExecutionRequest; -import static com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest.buildRequest; - public class ReportingService extends AbstractAdapter { - public static final String REPORT_EXECUTIONS_URI = "reportExecutions"; - public ReportingService(SessionStorage sessionStorage) { super(sessionStorage); } -@Deprecated - public OperationResult newReportExecutionRequest(ReportExecutionRequest request) { - JerseyRequest jerseyRequest = buildRequest(sessionStorage, - ReportExecutionDescriptor.class, - new String[]{REPORT_EXECUTIONS_URI}); - if (request.getTimeZone() != null) { - jerseyRequest.addHeader("Accept-Timezone", request.getTimeZone().getID()); - } - return jerseyRequest - .post(request); - } - @Deprecated - public RequestExecution asyncNewReportExecutionRequest(final ReportExecutionRequest reportExecutionRequest, final Callback, R> callback) { - final JerseyRequest request = buildRequest(sessionStorage, ReportExecutionDescriptor.class, new String[]{REPORT_EXECUTIONS_URI}); - RequestExecution task = new RequestExecution(new Runnable() { - @Override - public void run() { - callback.execute(request.post(reportExecutionRequest)); - } - }); - ThreadPoolUtil.runAsynchronously(task); - return task; - } - @Deprecated - public ReportExecutionRequestBuilder reportExecutionRequest(String requestId) { - return new ReportExecutionRequestBuilder(sessionStorage, requestId); - } - @Deprecated - public ReportsAndJobsSearchAdapter runningReportsAndJobs() { - return new ReportsAndJobsSearchAdapter(sessionStorage); - } public ReportsAdapter report(String reportUnitUri) { return new ReportsAdapter(sessionStorage, reportUnitUri); diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/ReportsAdapter.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/ReportsAdapter.java index d01e0a91..a08f3d4a 100644 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/ReportsAdapter.java +++ b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/ReportsAdapter.java @@ -24,18 +24,11 @@ import com.jaspersoft.jasperserver.dto.reports.ReportParameter; import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.AbstractAdapter; import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.inputControls.InputControlsAdapter; -import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting.reportexecution.ReportExecutionAdapter; import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting.reportoptions.ReportOptionsAdapter; import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting.reportoptions.ReportOptionsUtil; -import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting.reportparameters.ReorderingReportParametersAdapter; -import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting.reportparameters.ReportParametersAdapter; -import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting.reportparameters.ReportParametersUtils; import com.jaspersoft.jasperserver.jaxrs.client.core.SessionStorage; -import com.jaspersoft.jasperserver.jaxrs.client.dto.reports.ReportExecutionRequest; import javax.ws.rs.core.MultivaluedHashMap; -import java.util.ArrayList; -import java.util.Arrays; import java.util.List; public class ReportsAdapter extends AbstractAdapter { @@ -47,15 +40,6 @@ public ReportsAdapter(SessionStorage sessionStorage, String reportUnitUri) { this.reportUnitUri = reportUnitUri; } - @Deprecated - public ReorderingReportParametersAdapter reportParameters() { - return new ReorderingReportParametersAdapter(sessionStorage, reportUnitUri); - } - - public ReportExecutionAdapter reportExecutions() { - return new ReportExecutionAdapter(sessionStorage, new ReportExecutionRequest().setReportUnitUri(reportUnitUri)); - } - public ReportOptionsAdapter reportOptions() { return new ReportOptionsAdapter(sessionStorage, reportUnitUri); } @@ -76,13 +60,6 @@ public InputControlsAdapter inputControls() { return new InputControlsAdapter(sessionStorage, reportUnitUri); } - @Deprecated - public ReportParametersAdapter reportParameters(String mandatoryId, String... otherIds) { - List ids = new ArrayList(Arrays.asList(otherIds)); - ids.add(0, mandatoryId); - return new ReportParametersAdapter(sessionStorage, reportUnitUri, ReportParametersUtils.toPathSegment(ids)); - } - public RunReportAdapter prepareForRun(com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting.util.ReportOutputFormat format, Integer... pages) { return new RunReportAdapter(sessionStorage, reportUnitUri, format.toString().toLowerCase(), pages); } diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/ReportsAndJobsSearchAdapter.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/ReportsAndJobsSearchAdapter.java deleted file mode 100644 index 970dec87..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/ReportsAndJobsSearchAdapter.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting; - -import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.AbstractAdapter; -import com.jaspersoft.jasperserver.jaxrs.client.core.*; -import com.jaspersoft.jasperserver.jaxrs.client.core.operationresult.OperationResult; -import com.jaspersoft.jasperserver.jaxrs.client.dto.reports.ReportExecutionListWrapper; - -import javax.ws.rs.core.MultivaluedHashMap; -import javax.ws.rs.core.MultivaluedMap; -@Deprecated -public class ReportsAndJobsSearchAdapter extends AbstractAdapter { - - public static final String REPORT_EXECUTIONS_URI = "reportExecutions"; - private final MultivaluedMap params; - - public ReportsAndJobsSearchAdapter(SessionStorage sessionStorage) { - super(sessionStorage); - this.params = new MultivaluedHashMap(); - } - - public ReportsAndJobsSearchAdapter parameter(ReportAndJobSearchParameter param, String value) { - params.add(param.getName(), UrlUtils.encode(value)); - return this; - } - - public OperationResult find(){ - JerseyRequest request = - buildRequest(); - request.addParams(params); - return request.get(); - } - - public RequestExecution asyncFind(final Callback, R> callback) { - final JerseyRequest request = - buildRequest(); - request.addParams(params); - - RequestExecution task = new RequestExecution(new Runnable() { - @Override - public void run() { - callback.execute(request.get()); - } - }); - - ThreadPoolUtil.runAsynchronously(task); - return task; - } - - protected JerseyRequest buildRequest() { - return JerseyRequest.buildRequest(sessionStorage, - ReportExecutionListWrapper.class, - new String[]{REPORT_EXECUTIONS_URI}); - } - -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/RunReportAdapter.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/RunReportAdapter.java index b8046cce..ea491fef 100644 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/RunReportAdapter.java +++ b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/RunReportAdapter.java @@ -22,6 +22,7 @@ package com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting; import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.AbstractAdapter; +import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting.util.RunReportErrorHandler; import com.jaspersoft.jasperserver.jaxrs.client.core.Callback; import com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest; import com.jaspersoft.jasperserver.jaxrs.client.core.RequestExecution; @@ -35,7 +36,6 @@ import java.io.InputStream; import java.util.ArrayList; import java.util.Arrays; -import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.TimeZone; @@ -50,9 +50,9 @@ public class RunReportAdapter extends AbstractAdapter { private final MultivaluedMap params; private final String reportUnitUri; private final String format; - private TimeZone timeZone; + private TimeZone timeZone; private String[] pages = new String[0]; - private ArrayList path = new ArrayList<>(); + private final ArrayList path = new ArrayList<>(); public RunReportAdapter(SessionStorage sessionStorage, String reportUnitUri, String format) { super(sessionStorage); @@ -69,16 +69,10 @@ public RunReportAdapter(SessionStorage sessionStorage, String reportUnitUri, Str } } - private Integer[] validArray (Integer[] pages) { - List list = new LinkedList(Arrays.asList(pages)); - Iterator iterator = list.iterator(); - while (iterator.hasNext()) { - Integer next = iterator.next(); - if (next <= 0) { - iterator.remove(); - } - } - return list.toArray(new Integer[list.size()]); + private Integer[] validArray(Integer[] pages) { + List list = new LinkedList<>(Arrays.asList(pages)); + list.removeIf(next -> next <= 0); + return list.toArray(new Integer[0]); } public RunReportAdapter(SessionStorage sessionStorage, String reportUnitUri, String format, @@ -119,12 +113,7 @@ public OperationResult run() { public RequestExecution asyncRun(final Callback, R> callback) { final JerseyRequest request = prepareRunRequest(); - RequestExecution task = new RequestExecution(new Runnable() { - @Override - public void run() { - callback.execute(request.get()); - } - }); + RequestExecution task = new RequestExecution(() -> callback.execute(request.get())); ThreadPoolUtil.runAsynchronously(task); return task; @@ -136,7 +125,7 @@ private JerseyRequest prepareRunRequest() { JerseyRequest request = JerseyRequest.buildRequest( sessionStorage, InputStream.class, - path.toArray(new String[path.size()]), + path.toArray(new String[0]), new RunReportErrorHandler()); request.addParams(params); diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/RunReportErrorHandler.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/RunReportErrorHandler.java deleted file mode 100644 index 0b221b6c..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/RunReportErrorHandler.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting; - -import com.jaspersoft.jasperserver.jaxrs.client.core.exceptions.handling.DefaultErrorHandler; - -import javax.ws.rs.core.Response; -/*** - * @deprecated use @Link {@link com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting.util.RunReportErrorHandler} - * */ -@Deprecated -public class RunReportErrorHandler extends DefaultErrorHandler { - - @Override - protected void handleBodyError(Response response) { - String jasperServerError = response.getHeaderString("JasperServerError"); - if (jasperServerError != null && jasperServerError.equals("true")){ - String errorMessage = readBody(response, String.class); - handleStatusCodeError(response, errorMessage); - } - - super.handleBodyError(response); - } -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/reportexecution/ReportExecutionAdapter.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/reportexecution/ReportExecutionAdapter.java index 62acea51..643550be 100644 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/reportexecution/ReportExecutionAdapter.java +++ b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/reportexecution/ReportExecutionAdapter.java @@ -58,7 +58,7 @@ public class ReportExecutionAdapter extends AbstractAdapter { private ReportExecutionRequest executionRequest; private String executionId; - private ArrayList path = new ArrayList(); + private final ArrayList path = new ArrayList<>(); private final MultivaluedMap params = new MultivaluedHashMap<>(); public ReportExecutionAdapter(SessionStorage sessionStorage, ReportExecutionRequest executionRequest) { @@ -178,7 +178,7 @@ public ReportExecutionAdapter reportParameter(ReportParameter reportParameter) { if(executionRequest.getParameters() == null) executionRequest.setParameters(new ReportParameters(new ArrayList())); final ReportParameters parameters = executionRequest.getParameters(); final List reportParametersList = parameters.getReportParameters(); - if(reportParametersList == null) parameters.setReportParameters(new ArrayList()); + if(reportParametersList == null) parameters.setReportParameters(new ArrayList<>()); reportParametersList.add(reportParameter); return this; } @@ -199,7 +199,7 @@ public OperationResult search() { JerseyRequest request = JerseyRequest.buildRequest( sessionStorage, ReportExecutionsSetWrapper.class, - path.toArray(new String[path.size()]), + path.toArray(new String[0]), new RunReportErrorHandler()); request.addParams(params); @@ -211,7 +211,7 @@ public OperationResult details() { JerseyRequest request = JerseyRequest.buildRequest( sessionStorage, ReportExecution.class, - path.toArray(new String[path.size()]), + path.toArray(new String[0]), new RunReportErrorHandler()); return request.get(); @@ -223,7 +223,7 @@ public OperationResult status() { JerseyRequest request = JerseyRequest.buildRequest( sessionStorage, ReportExecutionStatusObject.class, - path.toArray(new String[path.size()]), + path.toArray(new String[0]), new RunReportErrorHandler()); return request.get(); @@ -247,7 +247,7 @@ public OperationResult updateParameters(List reportParameters) JerseyRequest request = JerseyRequest.buildRequest( sessionStorage, Object.class, - path.toArray(new String[path.size()]), + path.toArray(new String[0]), new RunReportErrorHandler()); request.addParams(params); return request.post(reportParameters); @@ -259,7 +259,7 @@ public OperationResult cancel() { JerseyRequest request = JerseyRequest.buildRequest( sessionStorage, ReportExecutionStatusEntity.class, - path.toArray(new String[path.size()]), + path.toArray(new String[0]), new RunReportErrorHandler()); return request.put(new ReportExecutionStatusEntity()); @@ -270,7 +270,7 @@ public OperationResult delete() { JerseyRequest request = JerseyRequest.buildRequest( sessionStorage, Object.class, - path.toArray(new String[path.size()]), + path.toArray(new String[0]), new RunReportErrorHandler()); return request.delete(); diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/reportparameters/ReorderingReportParametersAdapter.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/reportparameters/ReorderingReportParametersAdapter.java deleted file mode 100644 index e8dda866..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/reportparameters/ReorderingReportParametersAdapter.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting.reportparameters; - -import com.jaspersoft.jasperserver.dto.reports.inputcontrols.ReportInputControl; -import com.jaspersoft.jasperserver.dto.reports.inputcontrols.ReportInputControlsListWrapper; -import com.jaspersoft.jasperserver.jaxrs.client.core.*; -import com.jaspersoft.jasperserver.jaxrs.client.core.operationresult.OperationResult; - -import java.util.List; - -import static com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest.buildRequest; -/** - * @deprecated Replaced by {@link com.jaspersoft.jasperserver.jaxrs.client.apiadapters.inputControls.InputControlsAdapter}. - */ -public class ReorderingReportParametersAdapter extends ReportParametersAdapter { - - public static final String REPORTS_URI = "reports"; - public static final String INPUT_CONTROLS_URI = "inputControls"; - - public ReorderingReportParametersAdapter(SessionStorage sessionStorage, String reportUnitUri) { - super(sessionStorage, reportUnitUri); - } - - public OperationResult reorder(List inputControls){ - ReportInputControlsListWrapper wrapper = new ReportInputControlsListWrapper(inputControls); - return buildRequest(sessionStorage, ReportInputControlsListWrapper.class, new String[]{REPORTS_URI, reportUnitUri, INPUT_CONTROLS_URI}) - .put(wrapper); - } - - public RequestExecution asyncReorder(final List inputControls, - final Callback, R> callback) { - final ReportInputControlsListWrapper wrapper = new ReportInputControlsListWrapper(inputControls); - final JerseyRequest request = - buildRequest(sessionStorage, ReportInputControlsListWrapper.class, new String[]{REPORTS_URI, reportUnitUri, INPUT_CONTROLS_URI}); - - RequestExecution task = new RequestExecution(new Runnable() { - @Override - public void run() { - callback.execute(request.put(wrapper)); - } - }); - - ThreadPoolUtil.runAsynchronously(task); - return task; - } -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/reportparameters/ReportParametersAdapter.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/reportparameters/ReportParametersAdapter.java deleted file mode 100644 index 3fd680da..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/reportparameters/ReportParametersAdapter.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting.reportparameters; - -import com.jaspersoft.jasperserver.dto.reports.ReportParameters; -import com.jaspersoft.jasperserver.dto.reports.inputcontrols.ReportInputControlsListWrapper; -import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.AbstractAdapter; -import com.jaspersoft.jasperserver.jaxrs.client.core.*; -import com.jaspersoft.jasperserver.jaxrs.client.core.exceptions.handling.DefaultErrorHandler; -import com.jaspersoft.jasperserver.jaxrs.client.core.operationresult.OperationResult; - -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.MultivaluedHashMap; -import javax.ws.rs.core.MultivaluedMap; - -import static com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest.buildRequest; -/** - * @deprecated Replaced by {@link com.jaspersoft.jasperserver.jaxrs.client.apiadapters.inputControls.InputControlsAdapter}. - */ -public class ReportParametersAdapter extends AbstractAdapter { - - public static final String REPORTS_URI = "reports"; - public static final String INPUT_CONTROLS_URI = "inputControls"; - protected final String reportUnitUri; - protected final MultivaluedMap params; - private String idsPathSegment; - - public ReportParametersAdapter(SessionStorage sessionStorage, String reportUnitUri){ - super(sessionStorage); - this.params = new MultivaluedHashMap(); - this.reportUnitUri = reportUnitUri; - } - - public ReportParametersAdapter(SessionStorage sessionStorage, String reportUnitUri, String idsPathSegment) { - this(sessionStorage, reportUnitUri); - this.idsPathSegment = idsPathSegment; - } - - public ReportParametersAdapter parameter(String name, String value){ - params.add(name, value); - return this; - } - - public OperationResult get(){ - JerseyRequest request = prepareRequest(); - return request.post(ReportParametersUtils.toReportParameters(params)); - } - - public RequestExecution asyncGet(final Callback, R> callback) { - final JerseyRequest request = prepareRequest(); - final ReportParameters reportParameters = ReportParametersUtils.toReportParameters(params); - - RequestExecution task = new RequestExecution(new Runnable() { - @Override - public void run() { - callback.execute(request.post(reportParameters)); - } - }); - - ThreadPoolUtil.runAsynchronously(task); - return task; - } - - private JerseyRequest prepareRequest(){ - JerseyRequest request = - buildRequest(sessionStorage, ReportInputControlsListWrapper.class, - new String[]{REPORTS_URI, reportUnitUri, INPUT_CONTROLS_URI}, new DefaultErrorHandler()); - request.setContentType(MediaType.APPLICATION_XML); - request.setAccept(MediaType.APPLICATION_XML); - if (idsPathSegment != null){ - request.setPath(idsPathSegment); - } - return request; - } - - public ReportParametersValuesAdapter values(){ - return new ReportParametersValuesAdapter(sessionStorage, reportUnitUri, idsPathSegment, params); - } - -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/reportparameters/ReportParametersConverter.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/reportparameters/ReportParametersConverter.java deleted file mode 100644 index 06638884..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/reportparameters/ReportParametersConverter.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting.reportparameters; - -import com.jaspersoft.jasperserver.dto.reports.ReportParameter; -import com.jaspersoft.jasperserver.dto.reports.ReportParameters; -import com.jaspersoft.jasperserver.dto.reports.inputcontrols.InputControlOption; -import com.jaspersoft.jasperserver.dto.reports.inputcontrols.InputControlState; - -import java.util.*; - -/** - * @deprecated Replaced by {@link com.jaspersoft.jasperserver.jaxrs.client.apiadapters.inputControls.InputControlsValuesAdapter}. - */ -public class ReportParametersConverter { - - public static Map getValueMapFromInputControlStates(List states) { - Map valueMap = new HashMap(states.size()); - for (InputControlState state : states) { - if (state != null) - valueMap.put(state.getId(), getValueFromInputControlState(state)); - } - - return valueMap; - } - - public static ReportParameters toReportParameters(List states){ - List reportParameterList = new ArrayList(); - for (InputControlState inputControlState : states) { - ReportParameter parameter = new ReportParameter(); - parameter.setName(inputControlState.getId()); - parameter.setValues(Arrays.asList(getValueFromInputControlState(inputControlState))); - - reportParameterList.add(parameter); - } - return new ReportParameters(reportParameterList); - } - - protected static String[] getValueFromInputControlState(InputControlState state) { - if (state.getValue() != null) { - return new String[]{state.getValue()}; - } else if (state.getOptions() != null) { - List values = new ArrayList(state.getOptions().size()); - for (InputControlOption option : state.getOptions()) { - if (option.isSelected()) { - values.add(option.getValue()); - } - } - return values.toArray(new String[values.size()]); - } else { - return new String[0]; - } - } - -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/reportparameters/ReportParametersUtils.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/reportparameters/ReportParametersUtils.java deleted file mode 100644 index 7a65dfb6..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/reportparameters/ReportParametersUtils.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting.reportparameters; - -import com.jaspersoft.jasperserver.dto.reports.ReportParameter; -import com.jaspersoft.jasperserver.dto.reports.ReportParameters; - -import javax.ws.rs.core.MultivaluedMap; -import java.util.ArrayList; -import java.util.List; - -/** - * @deprecated Replaced by {@link com.jaspersoft.jasperserver.jaxrs.client.apiadapters.inputControls.InputControlsValuesAdapter}. - */ -public class ReportParametersUtils { - - public static ReportParameters toReportParameters(MultivaluedMap params){ - - List parameters = new ArrayList(); - - for (MultivaluedMap.Entry> entry : params.entrySet()){ - ReportParameter parameter = new ReportParameter(); - parameter.setName(entry.getKey()); - parameter.setValues(entry.getValue()); - parameters.add(parameter); - } - - return new ReportParameters(parameters); - } - - public static String toPathSegment(List inputControlsIds){ - StringBuilder request = new StringBuilder(); - for (String id : inputControlsIds) - request.append(id) - .append(";"); - - return request.toString(); - } - -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/reportparameters/ReportParametersValuesAdapter.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/reportparameters/ReportParametersValuesAdapter.java deleted file mode 100644 index d87d2694..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/reportparameters/ReportParametersValuesAdapter.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting.reportparameters; - -import com.jaspersoft.jasperserver.dto.reports.ReportParameters; -import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.AbstractAdapter; -import com.jaspersoft.jasperserver.jaxrs.client.core.*; -import com.jaspersoft.jasperserver.jaxrs.client.core.exceptions.handling.DefaultErrorHandler; -import com.jaspersoft.jasperserver.jaxrs.client.core.operationresult.OperationResult; -import com.jaspersoft.jasperserver.jaxrs.client.dto.reports.inputcontrols.InputControlStateListWrapper; - -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.MultivaluedMap; - -import static com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest.buildRequest; - -/** - * @deprecated Replaced by {@link com.jaspersoft.jasperserver.jaxrs.client.apiadapters.inputControls.InputControlsValuesAdapter}. - */ -public class ReportParametersValuesAdapter extends AbstractAdapter { - - public static final String REPORTS_URI = "reports"; - public static final String INPUT_CONTROLS_URI = "inputControls"; - protected final String reportUnitUri; - protected MultivaluedMap params; - private String idsPathSegment; - - public ReportParametersValuesAdapter(SessionStorage sessionStorage, String reportUnitUri) { - super(sessionStorage); - this.reportUnitUri = reportUnitUri; - } - - public ReportParametersValuesAdapter(SessionStorage sessionStorage, String reportUnitUri, String idsPathSegment, - MultivaluedMap params) { - this(sessionStorage, reportUnitUri); - this.idsPathSegment = idsPathSegment; - this.params = params; - } - - public OperationResult get() { - JerseyRequest request = prepareRequest(); - return request.post(ReportParametersUtils.toReportParameters(params)); - } - - public RequestExecution asyncGet(final Callback, R> callback) { - final JerseyRequest request = prepareRequest(); - final ReportParameters reportParameters = ReportParametersUtils.toReportParameters(params); - - RequestExecution task = new RequestExecution(new Runnable() { - @Override - public void run() { - callback.execute(request.post(reportParameters)); - } - }); - - ThreadPoolUtil.runAsynchronously(task); - return task; - } - - private JerseyRequest prepareRequest() { - JerseyRequest request = - buildRequest(sessionStorage, InputControlStateListWrapper.class, - new String[]{REPORTS_URI, reportUnitUri, INPUT_CONTROLS_URI}, new DefaultErrorHandler()); - if (idsPathSegment != null) { - request.setPath(idsPathSegment); - } - request.setPath("values"); - request.setContentType(MediaType.APPLICATION_XML); - request.setAccept(MediaType.APPLICATION_XML); - - return request; - } - -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/resources/ResourceSearchParameter.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/resources/ResourceSearchParameter.java deleted file mode 100644 index 642d847e..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/resources/ResourceSearchParameter.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.apiadapters.resources; -@Deprecated -public enum ResourceSearchParameter { - - /** - * Search for resources having the specified text in the name or description. - * Note that the search string does not match in the ID of resources. - * - * Type/Value: String - */ - Q("q"), - - /** - * The path of the base folder for the search. - * - * Type/Value: String - */ - FOLDER_URI("folderUri"), - - /** - * Indicates whether search should include all sub-folders recursively. When - * omitted, the default behavior is recursive (true). - * - * Type/Value: true|false - */ - RECURSIVE("recursive"), - - /** - * Match only resources of the given type. Valid types are listed inV2 - * Resource Descriptor Types, for example: dataType, jdbcDataSource, - * reportUnit, or file. Multiple type parameters are allowed. Wrong values are - * ignored. - * - * Type/Value: String - */ - TYPE("type"), - - /** - * Filters the results by access events: viewed (by current user) or modified (by - * current user). By default, no access event filter is applied. - * - * Type/Value: viewed|modified - */ - ACCESS_TYPE("accessType"), - - /** - * When set inFolder true, results include nested local resources (in _files) as if they - * were in the repository. For more information, see Local Resources for more - * information. By default, hidden items are not shown (false). - * - * Type/Value: true|false - */ - SHOW_HIDDEN_ITEMS("showHiddenItems"), - - /** - * One of the following strings representing a field in the results inFolder sort by: uri, - * label, description, type, creationDate, updateDate, accessTime, or popularity - * (based on access events). By default, results are sorted alphabetically by - * label. - * - * Type/Value: (optional) String - */ - SORT_BY("sortBy"), - - /** - * Used for pagination inFolder specify the maximum number of resources inFolder return in - * each response. This is equivalent inFolder the number of results per page. The - * default limit is 100. - * - * Type/Value: integer - */ - LIMIT("limit"), - - /** - * Used for pagination inFolder request an offset in the set of results. This is - * equivalent inFolder a specific page number. The default offset is 1 (first page). - * - * Type/Value: integer - */ - OFFSET("offset"), - - /** - * When true, the Total-Count header is set in every paginated response, - * which impacts performance. When false, the default, the header is set in the - * first page only. - * - * Type/Value: true|false - */ - FORCE_TOTAL_COUNT("forceTotalCount"), - - /** - * Specifies a resources inFolder delete. Repeat this paramter inFolder delete multiple - * resources. - * - * Type/Value: String - */ - RESOURCE_URI("resourceUri") - - ; - - private String name; - - private ResourceSearchParameter(String name) { - this.name = name; - } - - public String getName() { - return name; - } - -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/resources/ResourceServiceParameter.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/resources/ResourceServiceParameter.java deleted file mode 100644 index a01e6183..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/resources/ResourceServiceParameter.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.apiadapters.resources; -@Deprecated -public enum ResourceServiceParameter { - - /** - * When true, all nested resources will be given as full descriptors. The default - * behavior, false, has all nested resources given as references. For more - * information, see Local Resources. - * - * Type/Value: true|false - */ - EXPANDED("expanded"), - - /** - * By default, this is true, and the service will createInFolder all parent folders if they - * don't already exist. When set inFolder false, the folders specified in the URL must - * all exist, otherwise the service returns an error. - * - * Type/Value: true|false - */ - CREATE_FOLDERS("createFolders"), - - /** - * When true, the resources given in the URL is overwritten even if it is a - * different type than the resources descriptor in the content. The default is false. - * - * Type/Value: true|false - */ - OVERWRITE("overwrite"); - - private String name; - - ResourceServiceParameter(String name) { - this.name = name; - } - - public String getName() { - return name; - } - - -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/resources/ResourcesService.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/resources/ResourcesService.java index 40122676..20e7409b 100644 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/resources/ResourcesService.java +++ b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/resources/ResourcesService.java @@ -67,19 +67,6 @@ public SingleFileResourceUploadAdapter fileResource(String fileResourceUri) { return new SingleFileResourceUploadAdapter(sessionStorage, fileResourceUri); } - /** - * Additional features to work with such resources as - * - SemanticLayerDataSource - * - ReportUnit - * - MondrianConnection - * - SecureMondrianConnection - */ - @Deprecated - public SemanticLayerResourceBuilder resource(ClientSemanticLayerDataSource resourceDescriptor) { - ClientSemanticLayerDataSource copy = new ClientSemanticLayerDataSource(resourceDescriptor); - return getBuilder(copy, sessionStorage); - } - public SemanticLayerResourceBuilder semanticLayerDataSourceResource(ClientSemanticLayerDataSource resourceDescriptor) { return getBuilder(resourceDescriptor, sessionStorage); } @@ -104,21 +91,4 @@ public SecureMondrianConnectionResourceBuilder secureMondrianConnection(ClientSe return getBuilder(mondrianConnectionDescriptor, sessionStorage); } - @Deprecated - public ReportUnitResourceBuilder resource(ClientReportUnit resourceDescriptor) { - ClientReportUnit copy = new ClientReportUnit(resourceDescriptor); - return getBuilder(copy, sessionStorage); - } - - @Deprecated - public MondrianConnectionResourceBuilder resource(ClientMondrianConnection resourceDescriptor) { - ClientMondrianConnection copy = new ClientMondrianConnection(resourceDescriptor); - return getBuilder(copy, sessionStorage); - } - - @Deprecated - public SecureMondrianConnectionResourceBuilder resource(ClientSecureMondrianConnection resourceDescriptor) { - ClientSecureMondrianConnection copy = new ClientSecureMondrianConnection(resourceDescriptor); - return getBuilder(copy, sessionStorage); - } } diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/resources/SingleResourceAdapter.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/resources/SingleResourceAdapter.java index f2101667..8f5aa687 100644 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/resources/SingleResourceAdapter.java +++ b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/resources/SingleResourceAdapter.java @@ -164,31 +164,11 @@ public void run() { return task; } - @Deprecated - public OperationResult createNew(ClientResource resource) { - return prepareCreateOrUpdateRequest(resource).post(resource); - } - - @SuppressWarnings("unchecked") public > OperationResult create() { return (OperationResult) prepareCreateOrUpdateRequest(resource).post(resource); } - @Deprecated - public RequestExecution asyncCreateNew(final ClientResource resource, final Callback, R> callback) { - final JerseyRequest request = prepareCreateOrUpdateRequest(resource); - RequestExecution task = new RequestExecution(new Runnable() { - @Override - public void run() { - callback.execute(request.post(resource)); - } - }); - ThreadPoolUtil.runAsynchronously(task); - return task; - } - - private > JerseyRequest prepareCreateOrUpdateRequest(T resource) { Class resourceType = ResourcesTypeResolverUtil.getResourceType(resource); JerseyRequest request = buildRequest(resourceType); @@ -199,11 +179,6 @@ private > JerseyRequest prepareCreateOrUpdateRequ return request; } - @Deprecated - public OperationResult copyFrom(String fromUri) { - return copyOrMove(false, fromUri); - } - public OperationResult copy() { return buildCopyMovieRequest().post(null); } @@ -216,15 +191,10 @@ public > OperationResult copy(Class clazz) { return buildCopyMovieRequest(clazz).post(null); } - public >OperationResult move(Class clazz) { + public > OperationResult move(Class clazz) { return buildCopyMovieRequest(clazz).put(""); } - @Deprecated - public OperationResult moveFrom(String fromUri) { - return copyOrMove(true, fromUri); - } - private OperationResult copyOrMove(boolean moving, String fromUri) { JerseyRequest request = prepareCopyOrMoveRequest(fromUri); if (moving) { @@ -291,65 +261,6 @@ public OperationResult putMultipartResource(FormDa return request.put(multipartResource); } - /** - * @deprecated use @Link {@link #detailsForType(Class)} (Class)} - */ - @Deprecated - public > OperationResult get(Class clazz) { - JerseyRequest request = buildRequest(clazz); - request.setAccept(MimeTypeUtil.toCorrectContentMime(sessionStorage.getConfiguration(), - ResourcesTypeResolverUtil.extractClientType(clazz))); - request.addParams(params); - return request.get(); - } - - /** - * @deprecated use @Link {@link #details()} - */ - @Deprecated - public > OperationResult get() { - JerseyRequest request; - if (isRootFolder(resourceUri)) { - request = buildRequest(ClientFolder.class); - request.setAccept(MimeTypeUtil.toCorrectContentMime(sessionStorage.getConfiguration(), - ResourcesTypeResolverUtil.extractClientType(ClientFolder.class))); - } else { - request = buildRequest(ClientFile.class); - request.setAccept(MimeTypeUtil.toCorrectContentMime(sessionStorage.getConfiguration(), - ResourcesTypeResolverUtil.extractClientType(ClientFile.class))); - } - request.addParams(params); - return request.get(); - } - - @Deprecated - public OperationResult uploadFile(File fileContent, - ClientFile.FileType fileType, - String label, - String description) { - FormDataMultiPart form = prepareUploadForm(fileContent, fileType, label, description); - JerseyRequest request = prepareUploadFileRequest(); - return request.post(form); - } - - @Deprecated - public RequestExecution asyncUploadFile(final File fileContent, - final ClientFile.FileType fileType, - final String label, - final String description, - final Callback, R> callback) { - final FormDataMultiPart form = prepareUploadForm(fileContent, fileType, label, description); - final JerseyRequest request = prepareUploadFileRequest(); - RequestExecution task = new RequestExecution(new Runnable() { - @Override - public void run() { - callback.execute(request.post(form)); - } - }); - ThreadPoolUtil.runAsynchronously(task); - return task; - } - private FormDataMultiPart prepareUploadForm(File fileContent, ClientFile.FileType fileType, String label, diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/resources/compexResourcesSupport/builder/MondrianConnectionResourceBuilder.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/resources/compexResourcesSupport/builder/MondrianConnectionResourceBuilder.java index 99702065..12d835d8 100644 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/resources/compexResourcesSupport/builder/MondrianConnectionResourceBuilder.java +++ b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/resources/compexResourcesSupport/builder/MondrianConnectionResourceBuilder.java @@ -39,25 +39,6 @@ public MondrianConnectionResourceBuilder(ClientMondrianConnection entity, Sessio super(storage, entity); } - @Deprecated - public MondrianConnectionResourceBuilder withMondrianSchema(InputStream schema, ClientFile schemaRef) { - multipart.field("schema", schema, new MediaType("application", "olapMondrianSchema+xml")); - super.connection.setSchema(schemaRef); - return this; - } - - @Deprecated - public MondrianConnectionResourceBuilder withMondrianSchema(InputStream schema) { - multipart.field("schema", schema, new MediaType("application", "olapMondrianSchema+xml")); - return this; - } - - @Deprecated - public MondrianConnectionResourceBuilder withUri(String uri) { - super.connection.setUri(uri); - return this; - } - public MondrianConnectionResourceBuilder withMondrianSchema(InputStream schema, String label) { StreamDataBodyPart streamDataBodyPart = new StreamDataBodyPart("schema", schema, label, new MediaType("application", "olapMondrianSchema+xml")); super.multipart.bodyPart(streamDataBodyPart); diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/resources/compexResourcesSupport/builder/ReportUnitResourceBuilder.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/resources/compexResourcesSupport/builder/ReportUnitResourceBuilder.java index 88885f81..e0ce1528 100644 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/resources/compexResourcesSupport/builder/ReportUnitResourceBuilder.java +++ b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/resources/compexResourcesSupport/builder/ReportUnitResourceBuilder.java @@ -44,21 +44,6 @@ public ReportUnitResourceBuilder(ClientReportUnit reportUnit, SessionStorage ses super(reportUnit, sessionStorage); } - @Deprecated - public ReportUnitResourceBuilder withJrxml(InputStream jrxml, ClientFile jrxmlDescriptor) { - multipart.field("jrxml", jrxml, MediaType.APPLICATION_XML_TYPE); - super.reportUnit.setJrxml(jrxmlDescriptor); - return this; - } - - @Deprecated - public ReportUnitResourceBuilder withJrxml(String jrxml, ClientFile jrxmlDescriptor) { - multipart.field("jrxml", jrxml, MediaType.APPLICATION_XML_TYPE); - super.reportUnit.setJrxml(jrxmlDescriptor); - return this; - } - - public ReportUnitResourceBuilder withJrxml(String jrxmlContent) { super.multipart.field("jrxml", jrxmlContent, new MediaType("application", "jrxml")); return this; @@ -76,44 +61,6 @@ public ReportUnitResourceBuilder withJrxml(File jrxml) { return this; } - @Deprecated - public ReportUnitResourceBuilder withNewFile(String content, String fileName, ClientFile fileDescriptor) { - multipart.field("files." + fileName, content, MediaType.TEXT_PLAIN_TYPE); - Map files = super.reportUnit.getFiles(); - if (files != null) { - super.reportUnit.getFiles().put(fileName, fileDescriptor); - } else { - super.reportUnit.setFiles(new HashMap()); - super.reportUnit.getFiles().put(fileName, fileDescriptor); - } - return this; - } - - @Deprecated - public ReportUnitResourceBuilder withNewFile(InputStream content, String fileName, ClientFile fileDescriptor) { - multipart.field("files." + fileName, content, MediaType.TEXT_PLAIN_TYPE); - Map files = super.reportUnit.getFiles(); - if (files != null) { - super.reportUnit.getFiles().put(fileName, fileDescriptor); - } else { - super.reportUnit.setFiles(new HashMap()); - super.reportUnit.getFiles().put(fileName, fileDescriptor); - } - return this; - } - - @Deprecated - public ReportUnitResourceBuilder withNewFileReference(String fileName, ClientReference fileDescriptor) { - Map files = super.reportUnit.getFiles(); - if (files != null) { - super.reportUnit.getFiles().put(fileName, fileDescriptor); - } else { - super.reportUnit.setFiles(new HashMap()); - super.reportUnit.getFiles().put(fileName, fileDescriptor); - } - return this; - } - public ReportUnitResourceBuilder withFile(InputStream fileData, String label, ClientFile.FileType fileType) { StreamDataBodyPart streamDataBodyPart = new StreamDataBodyPart("files." + label, fileData, diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/resources/compexResourcesSupport/builder/SecureMondrianConnectionResourceBuilder.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/resources/compexResourcesSupport/builder/SecureMondrianConnectionResourceBuilder.java index fb4be2c1..b0966f0b 100644 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/resources/compexResourcesSupport/builder/SecureMondrianConnectionResourceBuilder.java +++ b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/resources/compexResourcesSupport/builder/SecureMondrianConnectionResourceBuilder.java @@ -44,45 +44,6 @@ public SecureMondrianConnectionResourceBuilder(ClientSecureMondrianConnection en super(storage, entity); } - @Deprecated - public SecureMondrianConnectionResourceBuilder withMondrianSchema(InputStream schema, ClientFile schemaDescriptor) { - multipart.field("schema", schema, new MediaType("application", "olapMondrianSchema+xml")); - super.connection.setSchema(schemaDescriptor); - return this; - } - - @Deprecated - public SecureMondrianConnectionResourceBuilder withMondrianSchema(String schema, ClientFile schemaDescriptor) { - multipart.field("schema", schema, new MediaType("application", "olapMondrianSchema+xml")); - super.connection.setSchema(schemaDescriptor); - return this; - } - - @Deprecated - public SecureMondrianConnectionResourceBuilder withAccessGrantSchemasAsStream(List schemas, List schemaDescriptors) { - super.connection.setAccessGrants(schemaDescriptors); - for (InputStream schema : schemas) { - multipart.field("accessGrantSchemas.accessGrantSchema[" + schemaCounter + "]", schema, new MediaType("application", "accessGrantSchema+xml")); - } - return this; - } - - @Deprecated - public SecureMondrianConnectionResourceBuilder withAccessGrantSchemasAsString(List schemas, List schemaDescriptors) { - super.connection.setAccessGrants(schemaDescriptors); - for (String schema : schemas) { - multipart.field("accessGrantSchemas.accessGrantSchema[" + schemaCounter + "]", schema, new MediaType("application", "accessGrantSchema+xml")); - } - return this; - } - - @Deprecated - public SecureMondrianConnectionResourceBuilder withUri(String uri) { - super.connection.setUri(uri); - return this; - } - - public SecureMondrianConnectionResourceBuilder withMondrianSchema(InputStream schema, String label) { StreamDataBodyPart streamDataBodyPart = new StreamDataBodyPart("schema", schema, label, new MediaType("application", "olapMondrianSchema+xml")); super.multipart.bodyPart(streamDataBodyPart); diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/resources/compexResourcesSupport/builder/SemanticLayerResourceBuilder.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/resources/compexResourcesSupport/builder/SemanticLayerResourceBuilder.java index d1a39136..b46e3421 100644 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/resources/compexResourcesSupport/builder/SemanticLayerResourceBuilder.java +++ b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/resources/compexResourcesSupport/builder/SemanticLayerResourceBuilder.java @@ -45,20 +45,6 @@ public SemanticLayerResourceBuilder(ClientSemanticLayerDataSource domain, Sessio super(sessionStorage, domain); } - @Deprecated - public SemanticLayerResourceBuilder withSchema(String schema, ClientFile schemaRef) { - super.multipart.field("schema", schema, MediaType.APPLICATION_XML_TYPE); - super.domain.setSchema(schemaRef); - return this; - } - - @Deprecated - public SemanticLayerResourceBuilder withSchema(InputStream schema, ClientFile schemaRef) { - super.multipart.field("schema", schema, MediaType.APPLICATION_XML_TYPE); - super.domain.setSchema(schemaRef); - return this; - } - public SemanticLayerResourceBuilder withSchema(String schemaContent) { super.multipart.field("schema", schemaContent, MediaType.APPLICATION_XML_TYPE); return this; @@ -76,20 +62,6 @@ public SemanticLayerResourceBuilder withSchema(File schema) { return this; } - @Deprecated - public SemanticLayerResourceBuilder withSecurityFile(InputStream securityFile, ClientFile securityFileRef) { - super.multipart.field("securityFile", securityFile, MediaType.APPLICATION_XML_TYPE); - super.domain.setSecurityFile(securityFileRef); - return this; - } - - @Deprecated - public SemanticLayerResourceBuilder withSecurityFile(String securityFile, ClientFile securityFileRef) { - super.multipart.field("securityFile", securityFile, MediaType.APPLICATION_XML_TYPE); - super.domain.setSecurityFile(securityFileRef); - return this; - } - public SemanticLayerResourceBuilder withSecurityFile(InputStream securityFile, String label) { StreamDataBodyPart streamDataBodyPart = new StreamDataBodyPart("securityFile", securityFile, label, MediaType.APPLICATION_XML_TYPE); super.multipart.bodyPart(streamDataBodyPart); @@ -107,33 +79,6 @@ public SemanticLayerResourceBuilder withSecurityFile(String securityFile) { return this; } - @Deprecated - public SemanticLayerResourceBuilder withBundle(InputStream bundle, ClientBundle bundleRef) { - super.multipart.field("bundles.bundle[" + bundleCounter++ + "]", bundle, MediaType.TEXT_PLAIN_TYPE); - List bundles = super.domain.getBundles(); - - if (bundles != null) { - int index = bundles.indexOf(bundleRef); - if (index >= 0) { - bundles.set(index, bundleRef); - } else { - bundles.add(bundleRef); - } - } else { - bundles = new ArrayList(); - bundles.add(bundleRef); - } - - super.domain.setBundles(bundles); - return this; - } - - @Deprecated - public SemanticLayerResourceBuilder withBundle(String bundle, ClientBundle bundleRef) { - super.multipart.field("bundles.bundle[" + bundleCounter++ + "]", bundle, MediaType.TEXT_PLAIN_TYPE); - return this; - } - public SemanticLayerResourceBuilder withBundle(InputStream bundle, String label) { StreamDataBodyPart streamDataBodyPart = new StreamDataBodyPart("bundles.bundle[" + bundleCounter++ + "]", bundle, label, MediaType.TEXT_PLAIN_TYPE); super.multipart.bodyPart(streamDataBodyPart); @@ -151,10 +96,4 @@ public SemanticLayerResourceBuilder withBundle(String bundle) { return this; } - @Deprecated - public SemanticLayerResourceBuilder withUri(String uri) { - super.domain.setUri(uri); - return this; - } - } diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/resources/compexResourcesSupport/decorator/DomainOperationProcessorDecorator.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/resources/compexResourcesSupport/decorator/DomainOperationProcessorDecorator.java index e2b4d3ce..cf4565a1 100644 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/resources/compexResourcesSupport/decorator/DomainOperationProcessorDecorator.java +++ b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/resources/compexResourcesSupport/decorator/DomainOperationProcessorDecorator.java @@ -72,12 +72,6 @@ public OperationResult get() { return processor.get(domain.getUri()); } - @Deprecated - public OperationResult createInFolder(String path) { - return processor.create(multipart, new MediaType("application", "repository.domain+json"), path, params); - } - - public DomainOperationProcessorDecorator inFolder(String parentFolder) { this.path = parentFolder; return this; diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/resources/compexResourcesSupport/decorator/DomainTopicOperationProcessorDecorator.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/resources/compexResourcesSupport/decorator/DomainTopicOperationProcessorDecorator.java index 2d933091..dba83bd0 100644 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/resources/compexResourcesSupport/decorator/DomainTopicOperationProcessorDecorator.java +++ b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/resources/compexResourcesSupport/decorator/DomainTopicOperationProcessorDecorator.java @@ -64,11 +64,6 @@ public DomainTopicOperationProcessorDecorator(ClientDomainTopic domainTopic, Ses this.domainTopic = domainTopic; } - @Deprecated - public OperationResult createInFolder(String path) { - return processor.create(multipart, new MediaType("application", "repository.domainTopic+json"), path, params); - } - public DomainTopicOperationProcessorDecorator inFolder(String parentFolder) { this.path = parentFolder; return this; diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/resources/compexResourcesSupport/decorator/MondrianConnectionResourceOperationProcessorDecorator.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/resources/compexResourcesSupport/decorator/MondrianConnectionResourceOperationProcessorDecorator.java index 1fc2e5fa..c0000c07 100644 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/resources/compexResourcesSupport/decorator/MondrianConnectionResourceOperationProcessorDecorator.java +++ b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/resources/compexResourcesSupport/decorator/MondrianConnectionResourceOperationProcessorDecorator.java @@ -63,11 +63,6 @@ public MondrianConnectionResourceOperationProcessorDecorator(SessionStorage sess this.connection = connection; } - @Deprecated - public OperationResult createInFolder(String path) { - return processor.create(multipart, new MediaType("application", "repository.mondrianConnection+xml"), path, params); - } - public MondrianConnectionResourceOperationProcessorDecorator inFolder(String parentFolder) { this.path = parentFolder; return this; diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/resources/compexResourcesSupport/decorator/ReportUnitResourceOperationProcessorDecorator.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/resources/compexResourcesSupport/decorator/ReportUnitResourceOperationProcessorDecorator.java index e1cdc723..08475e01 100644 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/resources/compexResourcesSupport/decorator/ReportUnitResourceOperationProcessorDecorator.java +++ b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/resources/compexResourcesSupport/decorator/ReportUnitResourceOperationProcessorDecorator.java @@ -64,11 +64,6 @@ public ReportUnitResourceOperationProcessorDecorator(ClientReportUnit reportUnit this.reportUnit = reportUnit; } - @Deprecated - public OperationResult createInFolder(String path) { - return processor.create(multipart, new MediaType("application", "repository.reportUnit+json"), path, params); - } - public ReportUnitResourceOperationProcessorDecorator inFolder(String parentFolder) { this.path = parentFolder; return this; diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/resources/compexResourcesSupport/decorator/SecureMondrianConnectionResourceOperationProcessorDecorator.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/resources/compexResourcesSupport/decorator/SecureMondrianConnectionResourceOperationProcessorDecorator.java index 2f059a38..feebd852 100644 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/resources/compexResourcesSupport/decorator/SecureMondrianConnectionResourceOperationProcessorDecorator.java +++ b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/resources/compexResourcesSupport/decorator/SecureMondrianConnectionResourceOperationProcessorDecorator.java @@ -63,12 +63,6 @@ public SecureMondrianConnectionResourceOperationProcessorDecorator(SessionStorag this.connection = connection; } - @Deprecated - public OperationResult createInFolder(String path) { - return processor.create(multipart, new MediaType("application", "repository.secureMondrianConnection+xml"), path, params); - } - - public SecureMondrianConnectionResourceOperationProcessorDecorator inFolder(String parentFolder) { this.path = parentFolder; return this; diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/resources/compexResourcesSupport/decorator/SemanticLayerResourceOperationProcessorDecorator.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/resources/compexResourcesSupport/decorator/SemanticLayerResourceOperationProcessorDecorator.java index 2e5b3eeb..2e06ff14 100644 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/resources/compexResourcesSupport/decorator/SemanticLayerResourceOperationProcessorDecorator.java +++ b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/resources/compexResourcesSupport/decorator/SemanticLayerResourceOperationProcessorDecorator.java @@ -72,11 +72,6 @@ public OperationResult get() { return processor.get(domain.getUri()); } - @Deprecated - public OperationResult createInFolder(String path) { - return processor.create(multipart, new MediaType("application", "repository.semanticLayerDataSource+json"), path, params); - } - public SemanticLayerResourceOperationProcessorDecorator inFolder(String path) { this.path = path; return this; diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/resources/util/ResourceSearchParameter.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/resources/util/ResourceSearchParameter.java index f35bcc01..0b3d05c0 100644 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/resources/util/ResourceSearchParameter.java +++ b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/resources/util/ResourceSearchParameter.java @@ -26,14 +26,14 @@ public enum ResourceSearchParameter { /** * Search for resources having the specified text in the name or description. * Note that the search string does not match in the ID of resources. - * + *

* Type/Value: String */ Q("q"), /** * The path of the base folder for the search. - * + *

* Type/Value: String */ FOLDER_URI("folderUri"), @@ -41,7 +41,7 @@ public enum ResourceSearchParameter { /** * Indicates whether search should include all sub-folders recursively. When * omitted, the default behavior is recursive (true). - * + *

* Type/Value: true|false */ RECURSIVE("recursive"), @@ -51,7 +51,7 @@ public enum ResourceSearchParameter { * Resource Descriptor Types, for example: dataType, jdbcDataSource, * reportUnit, or file. Multiple type parameters are allowed. Wrong values are * ignored. - * + *

* Type/Value: String */ TYPE("type"), @@ -59,7 +59,7 @@ public enum ResourceSearchParameter { /** * Filters the results by access events: viewed (by current user) or modified (by * current user). By default, no access event filter is applied. - * + *

* Type/Value: viewed|modified */ ACCESS_TYPE("accessType"), @@ -68,7 +68,7 @@ public enum ResourceSearchParameter { * When set inFolder true, results include nested local resources (in _files) as if they * were in the repository. For more information, see Local Resources for more * information. By default, hidden items are not shown (false). - * + *

* Type/Value: true|false */ SHOW_HIDDEN_ITEMS("showHiddenItems"), @@ -78,7 +78,7 @@ public enum ResourceSearchParameter { * label, description, type, creationDate, updateDate, accessTime, or popularity * (based on access events). By default, results are sorted alphabetically by * label. - * + *

* Type/Value: (optional) String */ SORT_BY("sortBy"), @@ -87,7 +87,7 @@ public enum ResourceSearchParameter { * Used for pagination inFolder specify the maximum number of resources inFolder return in * each response. This is equivalent inFolder the number of results per page. The * default limit is 100. - * + *

* Type/Value: integer */ LIMIT("limit"), @@ -95,7 +95,7 @@ public enum ResourceSearchParameter { /** * Used for pagination inFolder request an offset in the set of results. This is * equivalent inFolder a specific page number. The default offset is 1 (first page). - * + *

* Type/Value: integer */ OFFSET("offset"), @@ -104,7 +104,7 @@ public enum ResourceSearchParameter { * When true, the Total-Count header is set in every paginated response, * which impacts performance. When false, the default, the header is set in the * first page only. - * + *

* Type/Value: true|false */ FORCE_TOTAL_COUNT("forceTotalCount"), @@ -112,7 +112,7 @@ public enum ResourceSearchParameter { /** * Specifies a resources inFolder delete. Repeat this paramter inFolder delete multiple * resources. - * + *

* Type/Value: String */ RESOURCE_URI("resourceUri"), @@ -120,9 +120,9 @@ public enum ResourceSearchParameter { /** * Pagination. Setting this parameter to true enables full page pagination. * Depending on the type of search and user permissions, this parameter can cause significant performance delays. - * + *

* In case of forceFullPage=true client should use value of "Next-Offset" HTTP response header for next pagination request. - * + *

* Type/Value: true|false * Default: false */ @@ -131,7 +131,7 @@ public enum ResourceSearchParameter { /** * Resource type to exclude. Multiple Resource types allowed. * If type parameter is specified, then this parameter is ignored. - * + *

* Type/Value: String */ EXCLUDE_TYPE("excludeType"), @@ -139,7 +139,7 @@ public enum ResourceSearchParameter { /** * Folder, results of which should be omitted. In multitenant context works as relative, * i.e. value "/tmp" will exclude results from /tmp, /organizations/organization_1/tmp etc. Multiple allowed. - * + *

* Type/Value: String */ EXCLUDE_FOLDER("excludeFolder"), @@ -148,12 +148,18 @@ public enum ResourceSearchParameter { * Since 6.0 * Search for all resources depending on specific resource. * If this parameter is specified, then all the other parameters except pagination are ignored. - * + *

* Type/Value: String */ - DEPENDS_ON("dependsOn") + DEPENDS_ON("dependsOn"), - ; + /** + * Since 8.? + * Search for all resources that were marked as favorite. + * Type/Value: true|false + * Default: false + */ + FAVORITES("favorites"); private String name; diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/core/EncryptionUtils.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/core/EncryptionUtils.java deleted file mode 100644 index 9e98142a..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/core/EncryptionUtils.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.core; - -import org.apache.commons.lang3.CharEncoding; -import org.bouncycastle.jce.provider.BouncyCastleProvider; -import org.codehaus.jettison.json.JSONException; -import org.codehaus.jettison.json.JSONObject; - -import javax.crypto.Cipher; -import javax.ws.rs.core.Response; -import java.math.BigInteger; -import java.net.URLEncoder; -import java.security.KeyFactory; -import java.security.PublicKey; -import java.security.spec.RSAPublicKeySpec; -import java.util.HashMap; -import java.util.Map; - -public class EncryptionUtils { - -// private static final Log log = LogFactory.getLog(EncryptionUtils.class); - - public static String encryptPassword(String plainPassword, String n, String e) { - String encryptedUtfProPass; - try { - PublicKey publicKey = getPublicKey(n, e); - encryptedUtfProPass = getEncryptedPassword(publicKey, plainPassword); - } catch (Exception ex) { -// log.error("Failed inFolder encrypt password. Possible encryption provider issues."); - throw new RuntimeException("Failed inFolder encrypt password.", ex); - } - return encryptedUtfProPass; - } - - public static Map parseEncryptionParams(Response response) { - Map encryptionParams = new HashMap(); - String encryptionParamsJson = response.readEntity(String.class); - try { - JSONObject json = new JSONObject(encryptionParamsJson); - encryptionParams.put("n", json.getString("n")); - encryptionParams.put("e", json.getString("e")); - } catch (JSONException e1) { -// log.info("Encryption is off."); - return null; - } - return encryptionParams; - } - - private static String byteArrayToHexString(byte[] byteArr) { - StringBuffer sb = new StringBuffer(); - for (int i = 0; i < byteArr.length; i++) { - byte b = byteArr[i]; - int high = (b & 0xF0) >> 4; - int low = b & 0x0F; - sb.append(Character.forDigit(high, 16)); - sb.append(Character.forDigit(low, 16)); - } - return sb.toString(); - } - - private static String getEncryptedPassword(PublicKey publicKey, String pwd) throws Exception { - byte[] encryptedUtfPass; - Cipher enc = Cipher.getInstance("RSA/NONE/NoPadding", new BouncyCastleProvider()); - enc.init(Cipher.ENCRYPT_MODE, publicKey); - String utfPass = URLEncoder.encode(pwd, CharEncoding.UTF_8); - encryptedUtfPass = enc.doFinal(utfPass.getBytes()); - - return byteArrayToHexString(encryptedUtfPass); - } - - private static PublicKey getPublicKey(String n, String e) throws Exception { - KeyFactory keyFactory = KeyFactory.getInstance("RSA"); - int radix = 16; - BigInteger modulus = new BigInteger(n, radix); - BigInteger publicExponent = new BigInteger(e, radix); - RSAPublicKeySpec publicKeySpec = new RSAPublicKeySpec(modulus, publicExponent); - return keyFactory.generatePublic(publicKeySpec); - } -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/core/JerseyRequest.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/core/JerseyRequest.java index 5eafdb4c..494da4b5 100644 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/core/JerseyRequest.java +++ b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/core/JerseyRequest.java @@ -46,6 +46,7 @@ import static javax.ws.rs.core.MediaType.APPLICATION_JSON; import static javax.ws.rs.core.MediaType.APPLICATION_XML; + public class JerseyRequest implements RequestBuilder { private static final int GET = 0; private static final int DELETE = 1; diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/core/RestClientConfiguration.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/core/RestClientConfiguration.java index 8c5d5f87..8b4be8ed 100644 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/core/RestClientConfiguration.java +++ b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/core/RestClientConfiguration.java @@ -24,12 +24,11 @@ import com.jaspersoft.jasperserver.jaxrs.client.core.enums.AuthenticationType; import com.jaspersoft.jasperserver.jaxrs.client.core.enums.JRSVersion; import com.jaspersoft.jasperserver.jaxrs.client.core.enums.MimeType; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import javax.net.ssl.TrustManager; import javax.net.ssl.X509TrustManager; - import java.io.InputStream; import java.security.cert.CertificateException; import java.security.cert.X509Certificate; @@ -39,7 +38,7 @@ public class RestClientConfiguration { - private static final Log log = LogFactory.getLog(RestClientConfiguration.class); + private static final Logger log = LogManager.getLogger(RestClientConfiguration.class); private static final Pattern URL_PATTERN = Pattern.compile("\\b(https?)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]"); private static final Pattern VERSION_PATTERN = Pattern.compile("^v(\\d_){2}\\d$"); private static final Pattern BOOLEAN_PATTERN = Pattern.compile("^(true|false)$", Pattern.CASE_INSENSITIVE); diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/core/Session.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/core/Session.java index c6afc8b5..16e09e8b 100644 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/core/Session.java +++ b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/core/Session.java @@ -25,12 +25,13 @@ import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.authority.organizations.OrganizationsService; import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.authority.roles.RolesService; import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.authority.users.UsersService; -import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.connections.ConnectionsService; import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.context.ContextService; import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.context.domain.DomainContextService; +import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.dashboard.DashboardsService; import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.datadiscovery.DataDiscoveryService; import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.diagnostic.DiagnosticService; import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.domain.DomainService; +import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.favorites.FavoritesService; import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.importexport.exportservice.ExportService; import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.importexport.importservice.ImportService; import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.inputControls.InputControlsService; @@ -42,13 +43,13 @@ import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.thumbnails.ThumbnailsService; import com.jaspersoft.jasperserver.jaxrs.client.core.enums.AuthenticationType; import com.jaspersoft.jasperserver.jaxrs.client.core.exceptions.handling.DefaultErrorHandler; + import javax.ws.rs.client.Client; import javax.ws.rs.client.WebTarget; import javax.ws.rs.core.Response; - -public class Session extends AnonymousSession{ +public class Session extends AnonymousSession { public Session(SessionStorage sessionStorage) { super(sessionStorage); @@ -115,10 +116,6 @@ public DomainService domainService() { return getService(DomainService.class); } - public QueryExecutorService queryExecutorService() { - return getService(QueryExecutorService.class); - } - public ThumbnailsService thumbnailsService() { return getService(ThumbnailsService.class); } @@ -127,21 +124,40 @@ public AttributesService attributesService() { return getService(AttributesService.class); } - public InputControlsService inputControlsService() {return getService(InputControlsService.class);} + public InputControlsService inputControlsService() { + return getService(InputControlsService.class); + } - public DiagnosticService diagnosticService() {return getService(DiagnosticService.class);} + public DiagnosticService diagnosticService() { + return getService(DiagnosticService.class); + } - /** - * - * @deprecated Replaced by {@link Session#contextService()}*/ - public ConnectionsService connectionsService() {return getService(ConnectionsService.class);} + public ContextService contextService() { + return getService(ContextService.class); + } - public ContextService contextService() {return getService(ContextService.class);} + public DomainContextService domainContextService() { + return getService(DomainContextService.class); + } - public DomainContextService domainContextService() {return getService(DomainContextService.class);} + public QueryExecutionService queryExecutionService() { + return getService(QueryExecutionService.class); + } - public QueryExecutionService queryExecutionService() {return getService(QueryExecutionService.class);} + public DataDiscoveryService dataDiscoveryService() { + return getService(DataDiscoveryService.class); + } - public DataDiscoveryService dataDiscoveryService() {return getService(DataDiscoveryService.class);} + public QueryExecutorService queryExecutorService() { + return getService(QueryExecutorService.class); + } + + public FavoritesService favoritesService() { + return getService(FavoritesService.class); + } + + public DashboardsService dashboardsService() { + return getService(DashboardsService.class); + } } \ No newline at end of file diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/core/SessionStorage.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/core/SessionStorage.java index d09debaf..657125c7 100644 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/core/SessionStorage.java +++ b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/core/SessionStorage.java @@ -21,26 +21,26 @@ package com.jaspersoft.jasperserver.jaxrs.client.core; +import com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule; import com.jaspersoft.jasperserver.jaxrs.client.filters.SessionOutputFilter; import com.jaspersoft.jasperserver.jaxrs.client.providers.CustomRepresentationTypeProvider; -import java.security.SecureRandom; -import java.util.Locale; -import java.util.TimeZone; -import java.util.logging.Logger; -import javax.net.ssl.HostnameVerifier; -import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLSession; import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.client.WebTarget; -import org.codehaus.jackson.jaxrs.JacksonJsonProvider; -import org.codehaus.jackson.map.DeserializationConfig; import org.glassfish.jersey.client.ClientProperties; -import org.glassfish.jersey.filter.LoggingFilter; import org.glassfish.jersey.jackson.JacksonFeature; +import org.glassfish.jersey.jackson.internal.jackson.jaxrs.json.JacksonJsonProvider; +import org.glassfish.jersey.logging.LoggingFeature; import org.glassfish.jersey.media.multipart.MultiPartFeature; import org.slf4j.bridge.SLF4JBridgeHandler; +import javax.net.ssl.HostnameVerifier; +import javax.net.ssl.SSLContext; +import java.security.SecureRandom; +import java.util.Locale; +import java.util.TimeZone; +import java.util.logging.Logger; + public class SessionStorage { @@ -55,26 +55,6 @@ public class SessionStorage { private Client client; - /** - * @deprecated - */ - public SessionStorage(RestClientConfiguration configuration, AuthenticationCredentials credentials) { - this.configuration = configuration; - this.credentials = credentials; - init(); - } - - /** - * @deprecated - */ - public SessionStorage(RestClientConfiguration configuration, AuthenticationCredentials credentials, TimeZone userTimeZone) { - this.configuration = configuration; - this.credentials = credentials; - this.userTimeZone = userTimeZone; - init(); - } - - public SessionStorage(RestClientConfiguration configuration, AuthenticationCredentials credentials, Locale userLocale, TimeZone userTimeZone) { this.configuration = configuration; this.credentials = credentials; @@ -95,12 +75,7 @@ protected WebTarget getConfiguredClient() { private void initSSL(ClientBuilder clientBuilder) { try { SSLContext sslContext = SSLContext.getInstance("SSL"); - HostnameVerifier hostnameVerifier = new HostnameVerifier() { - @Override - public boolean verify(String s, SSLSession sslSession) { - return true; - } - }; + HostnameVerifier hostnameVerifier = (s, sslSession) -> true; sslContext.init(null, configuration.getTrustManagers(), new SecureRandom()); clientBuilder.sslContext(sslContext); @@ -135,31 +110,29 @@ private void init() { } protected WebTarget configClient() { - JacksonJsonProvider customRepresentationTypeProvider = new CustomRepresentationTypeProvider() - .configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); - - + JacksonJsonProvider customRepresentationTypeProvider = new CustomRepresentationTypeProvider(); rootTarget = client.target(configuration.getJasperReportsServerUrl()); rootTarget .register(customRepresentationTypeProvider) + .register(JaxbAnnotationModule.class) .register(JacksonFeature.class) .register(MultiPartFeature.class); if (sessionId != null) { rootTarget.register(new SessionOutputFilter(sessionId)); } if (configuration.getLogHttp()) { + rootTarget.property(LoggingFeature.LOGGING_FEATURE_LOGGER_LEVEL, "INFO"); rootTarget.register(initLoggingFilter()); } return rootTarget; } - private LoggingFilter initLoggingFilter() { + private LoggingFeature initLoggingFilter() { Logger logger = Logger.getLogger(this.getClass().getName()); SLF4JBridgeHandler.removeHandlersForRootLogger(); SLF4JBridgeHandler.install(); - - return new LoggingFilter(logger, - configuration.getLogHttpEntity()); + LoggingFeature.Verbosity verbosity = configuration.getLogHttpEntity() ? LoggingFeature.Verbosity.PAYLOAD_ANY : LoggingFeature.Verbosity.HEADERS_ONLY; + return new LoggingFeature(logger, verbosity); } diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/core/exceptions/handling/DefaultErrorHandler.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/core/exceptions/handling/DefaultErrorHandler.java index 326668fd..0fbd64e3 100644 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/core/exceptions/handling/DefaultErrorHandler.java +++ b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/core/exceptions/handling/DefaultErrorHandler.java @@ -21,7 +21,6 @@ package com.jaspersoft.jasperserver.jaxrs.client.core.exceptions.handling; -import javax.ws.rs.core.Response.Status; import com.jaspersoft.jasperserver.jaxrs.client.core.exceptions.AccessDeniedException; import com.jaspersoft.jasperserver.jaxrs.client.core.exceptions.AuthenticationFailedException; import com.jaspersoft.jasperserver.jaxrs.client.core.exceptions.BadRequestException; @@ -48,15 +47,15 @@ public class DefaultErrorHandler implements ErrorHandler { protected static final Map> httpErrorCodeToTypeMap = new HashMap>() {{ - put(Status.BAD_REQUEST, BadRequestException.class); - put(Status.FORBIDDEN, AccessDeniedException.class); - put(Status.NOT_ACCEPTABLE, HttpMethodNotAllowedException.class); - put(Status.INTERNAL_SERVER_ERROR, InternalServerErrorException.class); - put(Status.NOT_ACCEPTABLE, RequestedRepresentationNotAvailableForResourceException.class); - put(Status.NOT_FOUND, ResourceNotFoundException.class); - put(Status.UNAUTHORIZED, AuthenticationFailedException.class); - put(Status.CONFLICT, ConflictException.class); - put(Status.UNSUPPORTED_MEDIA_TYPE, RepresentationalTypeNotSupportedForResourceException.class); + put(Response.Status.BAD_REQUEST, BadRequestException.class); + put(Response.Status.FORBIDDEN, AccessDeniedException.class); + put(Response.Status.NOT_ACCEPTABLE, HttpMethodNotAllowedException.class); + put(Response.Status.INTERNAL_SERVER_ERROR, InternalServerErrorException.class); + put(Response.Status.NOT_ACCEPTABLE, RequestedRepresentationNotAvailableForResourceException.class); + put(Response.Status.NOT_FOUND, ResourceNotFoundException.class); + put(Response.Status.UNAUTHORIZED, AuthenticationFailedException.class); + put(Response.Status.CONFLICT, ConflictException.class); + put(Response.Status.UNSUPPORTED_MEDIA_TYPE, RepresentationalTypeNotSupportedForResourceException.class); }}; @Override diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/CalendarDaysType.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/CalendarDaysType.java deleted file mode 100644 index c9b42aca..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/CalendarDaysType.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.dto.jobs; - -/** - * @deprecated (use server DTO). - */ -public enum CalendarDaysType { - ALL, - WEEK, - MONTH -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/CalendarTrigger.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/CalendarTrigger.java deleted file mode 100644 index 8534665f..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/CalendarTrigger.java +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.dto.jobs; - -import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.jaxb.adapters.DaysByteXmlAdapter; -import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.jaxb.adapters.MonthsByteXmlAdapter; -import java.util.SortedSet; -import java.util.TreeSet; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; -/** - * @deprecated (use server DTO). - */ -@XmlRootElement(name = "calendarTrigger") -public class CalendarTrigger extends JobTrigger { - - private String minutes; - private String hours; - private CalendarDaysType daysType; - private SortedSet weekDays; - private String monthDays; - private SortedSet months; - - public CalendarTrigger() { - super(); - } - - public CalendarTrigger(CalendarTrigger other) { - super(other); - this.minutes = other.minutes; - this.hours = other.hours; - this.daysType = other.daysType; - this.weekDays = (other.weekDays != null) ? new TreeSet(other.weekDays) : null; - this.monthDays = other.monthDays; - this.months = (other.months != null) ? new TreeSet(other.months) : null; - } - - public String getMinutes() { - return minutes; - } - - public CalendarTrigger setMinutes(String minutes) { - this.minutes = minutes; - return this; - } - - public String getHours() { - return hours; - } - - public CalendarTrigger setHours(String hours) { - this.hours = hours; - return this; - } - - public String getMonthDays() { - return monthDays; - } - - public CalendarTrigger setMonthDays(String monthDays) { - this.monthDays = monthDays; - return this; - } - - public CalendarDaysType getDaysType() { - return daysType; - } - - public CalendarTrigger setDaysType(CalendarDaysType daysType) { - this.daysType = daysType; - return this; - } - - @XmlJavaTypeAdapter(DaysByteXmlAdapter.class) - public SortedSet getWeekDays() { - return weekDays; - } - - public CalendarTrigger setWeekDays(SortedSet weekDays) { - this.weekDays = weekDays; - return this; - } - - @XmlJavaTypeAdapter(MonthsByteXmlAdapter.class) - public SortedSet getMonths() { - return months; - } - - public CalendarTrigger setMonths(SortedSet months) { - this.months = months; - return this; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - CalendarTrigger that = (CalendarTrigger) o; - - if (daysType != null ? !daysType.equals(that.daysType) : that.daysType != null) return false; - if (hours != null ? !hours.equals(that.hours) : that.hours != null) return false; - if (minutes != null ? !minutes.equals(that.minutes) : that.minutes != null) return false; - if (monthDays != null ? !monthDays.equals(that.monthDays) : that.monthDays != null) return false; - if (months != null ? !months.equals(that.months) : that.months != null) return false; - if (weekDays != null ? !weekDays.equals(that.weekDays) : that.weekDays != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = minutes != null ? minutes.hashCode() : 0; - result = 31 * result + (hours != null ? hours.hashCode() : 0); - result = 31 * result + (daysType != null ? daysType.hashCode() : 0); - result = 31 * result + (weekDays != null ? weekDays.hashCode() : 0); - result = 31 * result + (monthDays != null ? monthDays.hashCode() : 0); - result = 31 * result + (months != null ? months.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "CalendarTrigger{" + - "minutes='" + minutes + '\'' + - ", hours='" + hours + '\'' + - ", daysType='" + daysType + '\'' + - ", weekDays=" + weekDays + - ", monthDays='" + monthDays + '\'' + - ", months=" + months + - "} " + super.toString(); - } -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/FtpInfo.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/FtpInfo.java deleted file mode 100644 index 8992a1d9..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/FtpInfo.java +++ /dev/null @@ -1,221 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.dto.jobs; - - -import java.util.LinkedHashMap; -import javax.xml.bind.annotation.XmlRootElement; -import java.util.Map; -/** - * @deprecated (use server DTO). - */ -@XmlRootElement(name = "outputFTPInfo") -public class FtpInfo { - - private String userName; - private String password; - private String folderPath; - private String serverName; - private FtpType type; - private String protocol; - private Integer port; - private Boolean implicit; - private Long pbsz; - private String prot; - private Map propertiesMap; - - public FtpInfo() { - } - - public FtpInfo(FtpInfo other) { - this.folderPath = other.folderPath; - this.implicit = other.implicit; - this.password = other.password; - this.pbsz = other.pbsz; - this.port = other.port; - this.propertiesMap = (other.propertiesMap != null) ? new LinkedHashMap(other.propertiesMap) : null; - this.prot = other.prot; - this.protocol = other.protocol; - this.serverName = other.serverName; - this.type = other.type; - this.userName = other.userName; - } - - public String getUserName() { - return userName; - } - - public FtpInfo setUserName(String userName) { - this.userName = userName; - return this; - } - - public Boolean getImplicit() { - return implicit; - } - - public String getPassword() { - return password; - } - - public FtpInfo setPassword(String password) { - this.password = password; - return this; - } - - public String getFolderPath() { - return folderPath; - } - - public FtpInfo setFolderPath(String folderPath) { - this.folderPath = folderPath; - return this; - } - - public String getServerName() { - return serverName; - } - - public FtpInfo setServerName(String serverName) { - this.serverName = serverName; - return this; - } - - public FtpType getType() { - return type; - } - - public FtpInfo setType(FtpType type) { - this.type = type; - return this; - } - - public String getProtocol() { - return protocol; - } - - public FtpInfo setProtocol(String protocol) { - this.protocol = protocol; - return this; - } - - public Integer getPort() { - return port; - } - - public FtpInfo setPort(Integer port) { - this.port = port; - return this; - } - - public Boolean isImplicit() { - return implicit; - } - - public FtpInfo setImplicit(Boolean implicit) { - this.implicit = implicit; - return this; - } - - public Long getPbsz() { - return pbsz; - } - - public FtpInfo setPbsz(Long pbsz) { - this.pbsz = pbsz; - return this; - } - - public String getProt() { - return prot; - } - - public FtpInfo setProt(String prot) { - this.prot = prot; - return this; - } - - public Map getPropertiesMap() { - return propertiesMap; - } - - public FtpInfo setPropertiesMap(Map propertiesMap) { - this.propertiesMap = propertiesMap; - return this; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - FtpInfo ftpInfo = (FtpInfo) o; - - if (folderPath != null ? !folderPath.equals(ftpInfo.folderPath) : ftpInfo.folderPath != null) return false; - if (implicit != null ? !implicit.equals(ftpInfo.implicit) : ftpInfo.implicit != null) return false; - if (password != null ? !password.equals(ftpInfo.password) : ftpInfo.password != null) return false; - if (pbsz != null ? !pbsz.equals(ftpInfo.pbsz) : ftpInfo.pbsz != null) return false; - if (port != null ? !port.equals(ftpInfo.port) : ftpInfo.port != null) return false; - if (propertiesMap != null ? !propertiesMap.equals(ftpInfo.propertiesMap) : ftpInfo.propertiesMap != null) - return false; - if (prot != null ? !prot.equals(ftpInfo.prot) : ftpInfo.prot != null) return false; - if (protocol != null ? !protocol.equals(ftpInfo.protocol) : ftpInfo.protocol != null) return false; - if (serverName != null ? !serverName.equals(ftpInfo.serverName) : ftpInfo.serverName != null) return false; - if (type != null ? !type.equals(ftpInfo.type) : ftpInfo.type != null) return false; - if (userName != null ? !userName.equals(ftpInfo.userName) : ftpInfo.userName != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = userName != null ? userName.hashCode() : 0; - result = 31 * result + (password != null ? password.hashCode() : 0); - result = 31 * result + (folderPath != null ? folderPath.hashCode() : 0); - result = 31 * result + (serverName != null ? serverName.hashCode() : 0); - result = 31 * result + (type != null ? type.hashCode() : 0); - result = 31 * result + (protocol != null ? protocol.hashCode() : 0); - result = 31 * result + (port != null ? port.hashCode() : 0); - result = 31 * result + (implicit != null ? implicit.hashCode() : 0); - result = 31 * result + (pbsz != null ? pbsz.hashCode() : 0); - result = 31 * result + (prot != null ? prot.hashCode() : 0); - result = 31 * result + (propertiesMap != null ? propertiesMap.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "FtpInfo{" + - "userName='" + userName + '\'' + - ", password='" + password + '\'' + - ", folderPath='" + folderPath + '\'' + - ", serverName='" + serverName + '\'' + - ", type='" + type + '\'' + - ", protocol='" + protocol + '\'' + - ", port=" + port + - ", implicit=" + implicit + - ", pbsz=" + pbsz + - ", prot='" + prot + '\'' + - ", propertiesMap=" + propertiesMap + - '}'; - } -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/FtpType.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/FtpType.java deleted file mode 100644 index 9840df8b..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/FtpType.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.dto.jobs; - -/** - * @deprecated (use server DTO). - */ -public enum FtpType { - ftp, ftps -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/IntervalUnitType.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/IntervalUnitType.java deleted file mode 100644 index 2f3aed9d..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/IntervalUnitType.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.dto.jobs; -/** - * @deprecated (use server DTO). - */ -public enum IntervalUnitType { - MINUTE, - HOUR, - DAY, - WEEK -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/Job.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/Job.java deleted file mode 100644 index 7033a0e4..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/Job.java +++ /dev/null @@ -1,295 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.dto.jobs; - -import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.jaxb.adapters.OutputFormatXmlAdapter; -import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.jaxb.adapters.TimestampToStringXmlAdapter; - -import java.util.HashSet; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElements; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; -import java.sql.Timestamp; -import java.util.Set; -/** - * @deprecated (use server DTO). - */ -@XmlRootElement(name = "job") -public class Job { - - private Long id; - private Long version; - private String username; - private String label; - private String description; - private Timestamp creationDate; - private String baseOutputFilename; - private String outputLocale; - private RepositoryDestination repositoryDestination; - private MailNotification mailNotification; - private JobSource source; - private JobAlert alert; - private Set outputFormats; - private JobTrigger trigger; - private String outputTimeZone; - - public Job() { - } - - public Job(Job other) { - this.alert = (other.alert != null) ? new JobAlert(other.alert) : null; - this.baseOutputFilename = other.baseOutputFilename; - this.description = other.description; - this.id = other.id; - this.label = other.label; - this.mailNotification = (other.mailNotification != null) ? new MailNotification(other.mailNotification) : null; - if (other.outputFormats != null) { - this.outputFormats = new HashSet(); - for (OutputFormat outputFormat : other.outputFormats) { - this.outputFormats.add(outputFormat); - } - } - this.outputLocale = other.outputLocale; - this.outputTimeZone = other.outputTimeZone; - this.repositoryDestination = (other.repositoryDestination != null) ? - new RepositoryDestination(other.repositoryDestination) : null; - this.source = (other.source != null) ? new JobSource(other.source) : null; - this.username = other.username; - this.version = other.version; - this.creationDate = new Timestamp(other.creationDate.getTime()); - this.trigger = other.trigger.deepClone(); - } - - public Long getId() { - return id; - } - - public Job setId(Long id) { - this.id = id; - return this; - } - - public Long getVersion() { - return version; - } - - public Job setVersion(Long version) { - this.version = version; - return this; - } - - public String getUsername() { - return username; - } - - public Job setUsername(String username) { - this.username = username; - return this; - } - - public String getLabel() { - return label; - } - - public Job setLabel(String label) { - this.label = label; - return this; - } - - public String getDescription() { - return description; - } - - public Job setDescription(String description) { - this.description = description; - return this; - } - - @XmlJavaTypeAdapter(TimestampToStringXmlAdapter.class) - public Timestamp getCreationDate() { - return creationDate; - } - - public Job setCreationDate(Timestamp creationDate) { - this.creationDate = creationDate; - return this; - } - - public String getBaseOutputFilename() { - return baseOutputFilename; - } - - public Job setBaseOutputFilename(String baseOutputFilename) { - this.baseOutputFilename = baseOutputFilename; - return this; - } - - public String getOutputLocale() { - return outputLocale; - } - - public Job setOutputLocale(String outputLocale) { - this.outputLocale = outputLocale; - return this; - } - - @XmlElement(name = "repositoryDestination") - public RepositoryDestination getRepositoryDestination() { - return repositoryDestination; - } - - public Job setRepositoryDestination(RepositoryDestination repositoryDestination) { - this.repositoryDestination = repositoryDestination; - return this; - } - - @XmlElement(name = "mailNotification") - public MailNotification getMailNotification() { - return mailNotification; - } - - public Job setMailNotification(MailNotification mailNotification) { - this.mailNotification = mailNotification; - return this; - } - - @XmlElement(name = "source") - public JobSource getSource() { - return source; - } - - public Job setSource(JobSource source) { - this.source = source; - return this; - } - - @XmlElement(name = "alert") - public JobAlert getAlert() { - return alert; - } - - public Job setAlert(JobAlert alert) { - this.alert = alert; - return this; - } - - @XmlElements({ - @XmlElement(name = "simpleTrigger", type = SimpleTrigger.class), - @XmlElement(name = "calendarTrigger", type = CalendarTrigger.class)}) - public JobTrigger getTrigger() { - return trigger; - } - - public Job setTrigger(JobTrigger trigger) { - this.trigger = trigger; - return this; - } - - @XmlElement(name = "outputFormats") - @XmlJavaTypeAdapter(OutputFormatXmlAdapter.class) - public Set getOutputFormats() { - return outputFormats; - } - - public Job setOutputFormats(Set outputFormats) { - this.outputFormats = outputFormats; - return this; - } - - public String getOutputTimeZone() { - return outputTimeZone; - } - - public Job setOutputTimeZone(String outputTimeZone) { - this.outputTimeZone = outputTimeZone; - return this; - } - - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Job job = (Job) o; - - if (alert != null ? !alert.equals(job.alert) : job.alert != null) return false; - if (baseOutputFilename != null ? !baseOutputFilename.equals(job.baseOutputFilename) : job.baseOutputFilename != null) - return false; - if (creationDate != null ? !creationDate.equals(job.creationDate) : job.creationDate != null) return false; - if (description != null ? !description.equals(job.description) : job.description != null) return false; - if (id != null ? !id.equals(job.id) : job.id != null) return false; - if (label != null ? !label.equals(job.label) : job.label != null) return false; - if (mailNotification != null ? !mailNotification.equals(job.mailNotification) : job.mailNotification != null) - return false; - if (outputFormats != null ? !outputFormats.equals(job.outputFormats) : job.outputFormats != null) return false; - if (outputLocale != null ? !outputLocale.equals(job.outputLocale) : job.outputLocale != null) return false; - if (repositoryDestination != null ? !repositoryDestination.equals(job.repositoryDestination) : job.repositoryDestination != null) - return false; - if (source != null ? !source.equals(job.source) : job.source != null) return false; - if (trigger != null ? !trigger.equals(job.trigger) : job.trigger != null) return false; - if (username != null ? !username.equals(job.username) : job.username != null) return false; - if (version != null ? !version.equals(job.version) : job.version != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = id != null ? id.hashCode() : 0; - result = 31 * result + (version != null ? version.hashCode() : 0); - result = 31 * result + (username != null ? username.hashCode() : 0); - result = 31 * result + (label != null ? label.hashCode() : 0); - result = 31 * result + (description != null ? description.hashCode() : 0); - result = 31 * result + (creationDate != null ? creationDate.hashCode() : 0); - result = 31 * result + (baseOutputFilename != null ? baseOutputFilename.hashCode() : 0); - result = 31 * result + (outputLocale != null ? outputLocale.hashCode() : 0); - result = 31 * result + (repositoryDestination != null ? repositoryDestination.hashCode() : 0); - result = 31 * result + (mailNotification != null ? mailNotification.hashCode() : 0); - result = 31 * result + (source != null ? source.hashCode() : 0); - result = 31 * result + (alert != null ? alert.hashCode() : 0); - result = 31 * result + (outputFormats != null ? outputFormats.hashCode() : 0); - result = 31 * result + (trigger != null ? trigger.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "Job{" + - "id=" + id + - ", version=" + version + - ", username='" + username + '\'' + - ", label='" + label + '\'' + - ", description='" + description + '\'' + - ", creationDate='" + creationDate + '\'' + - ", baseOutputFilename='" + baseOutputFilename + '\'' + - ", outputLocale='" + outputLocale + '\'' + - ", repositoryDestination=" + repositoryDestination + - ", mailNotification=" + mailNotification + - ", source=" + source + - ", alert=" + alert + - ", outputFormats=" + outputFormats + - ", trigger=" + trigger + - '}'; - } -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/JobAlert.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/JobAlert.java deleted file mode 100644 index 75977c7e..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/JobAlert.java +++ /dev/null @@ -1,213 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.dto.jobs; - -import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.jaxb.adapters.AddressesXmlAdapter; - -import java.util.LinkedList; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; -import java.util.List; -/** - * @deprecated (use server DTO). - */ -@XmlRootElement(name = "reportJobAlert") -public class JobAlert { - - private Long id; - private Integer version; - private JobAlertRecipient recipient; - private JobAlertJobState jobState; - private String messageText; - private String messageTextWhenJobFails; - private String subject; - private Boolean includingStackTrace; - private Boolean includingReportJobInfo; - private List toAddresses; - - public JobAlert() { - } - - public JobAlert(JobAlert other) { - this.id = other.id; - this.includingReportJobInfo = other.includingReportJobInfo; - this.includingStackTrace = other.includingStackTrace; - this.jobState = other.jobState; - this.messageText = other.messageText; - this.messageTextWhenJobFails = other.messageTextWhenJobFails; - this.recipient = other.recipient; - this.subject = other.subject; - this.toAddresses = (other.toAddresses != null) ? new LinkedList(other.toAddresses) : null; - this.version = other.version; - - } - - @XmlElement(name = "toAddresses") - public List getToAddresses() { - return toAddresses; - } - - @XmlJavaTypeAdapter(AddressesXmlAdapter.class) - public JobAlert setToAddresses(List toAddresses) { - this.toAddresses = toAddresses; - return this; - } - - public Long getId() { - return id; - } - - public JobAlert setId(Long id) { - this.id = id; - return this; - } - - public Integer getVersion() { - return version; - } - - public JobAlert setVersion(Integer version) { - this.version = version; - return this; - } - - public JobAlertRecipient getRecipient() { - return recipient; - } - - public JobAlert setRecipient(JobAlertRecipient recipient) { - this.recipient = recipient; - return this; - } - - public JobAlertJobState getJobState() { - return jobState; - } - - public JobAlert setJobState(JobAlertJobState jobState) { - this.jobState = jobState; - return this; - } - - public String getMessageText() { - return messageText; - } - - public JobAlert setMessageText(String messageText) { - this.messageText = messageText; - return this; - } - - public String getMessageTextWhenJobFails() { - return messageTextWhenJobFails; - } - - public JobAlert setMessageTextWhenJobFails(String messageTextWhenJobFails) { - this.messageTextWhenJobFails = messageTextWhenJobFails; - return this; - } - - public String getSubject() { - return subject; - } - - public JobAlert setSubject(String subject) { - this.subject = subject; - return this; - } - - public Boolean isIncludingStackTrace() { - return includingStackTrace; - } - - public JobAlert setIncludingStackTrace(Boolean includingStackTrace) { - this.includingStackTrace = includingStackTrace; - return this; - } - - public Boolean isIncludingReportJobInfo() { - return includingReportJobInfo; - } - - public JobAlert setIncludingReportJobInfo(Boolean includingReportJobInfo) { - this.includingReportJobInfo = includingReportJobInfo; - return this; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - JobAlert jobAlert = (JobAlert) o; - - if (id != null ? !id.equals(jobAlert.id) : jobAlert.id != null) return false; - if (includingReportJobInfo != null ? !includingReportJobInfo.equals(jobAlert.includingReportJobInfo) : jobAlert.includingReportJobInfo != null) - return false; - if (includingStackTrace != null ? !includingStackTrace.equals(jobAlert.includingStackTrace) : jobAlert.includingStackTrace != null) - return false; - if (jobState != null ? !jobState.equals(jobAlert.jobState) : jobAlert.jobState != null) return false; - if (messageText != null ? !messageText.equals(jobAlert.messageText) : jobAlert.messageText != null) - return false; - if (messageTextWhenJobFails != null ? !messageTextWhenJobFails.equals(jobAlert.messageTextWhenJobFails) : jobAlert.messageTextWhenJobFails != null) - return false; - if (recipient != null ? !recipient.equals(jobAlert.recipient) : jobAlert.recipient != null) return false; - if (subject != null ? !subject.equals(jobAlert.subject) : jobAlert.subject != null) return false; - if (toAddresses != null ? !toAddresses.equals(jobAlert.toAddresses) : jobAlert.toAddresses != null) - return false; - if (version != null ? !version.equals(jobAlert.version) : jobAlert.version != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = id != null ? id.hashCode() : 0; - result = 31 * result + (version != null ? version.hashCode() : 0); - result = 31 * result + (recipient != null ? recipient.hashCode() : 0); - result = 31 * result + (jobState != null ? jobState.hashCode() : 0); - result = 31 * result + (messageText != null ? messageText.hashCode() : 0); - result = 31 * result + (messageTextWhenJobFails != null ? messageTextWhenJobFails.hashCode() : 0); - result = 31 * result + (subject != null ? subject.hashCode() : 0); - result = 31 * result + (includingStackTrace != null ? includingStackTrace.hashCode() : 0); - result = 31 * result + (includingReportJobInfo != null ? includingReportJobInfo.hashCode() : 0); - result = 31 * result + (toAddresses != null ? toAddresses.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "JobAlert{" + - "id=" + id + - ", version=" + version + - ", recipient='" + recipient + '\'' + - ", jobState='" + jobState + '\'' + - ", messageText='" + messageText + '\'' + - ", messageTextWhenJobFails='" + messageTextWhenJobFails + '\'' + - ", subject='" + subject + '\'' + - ", includingStackTrace=" + includingStackTrace + - ", includingReportJobInfo=" + includingReportJobInfo + - ", toAddresses=" + toAddresses + - '}'; - } -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/JobAlertJobState.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/JobAlertJobState.java deleted file mode 100644 index c9cc5672..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/JobAlertJobState.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.dto.jobs; -/** - * @deprecated (use server DTO). - */ -public enum JobAlertJobState { - NONE, - ALL, - FAIL_ONLY, - SUCCESS_ONLY -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/JobAlertRecipient.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/JobAlertRecipient.java deleted file mode 100644 index b2ad6028..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/JobAlertRecipient.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.dto.jobs; -/** - * @deprecated (use server DTO). - */ -public enum JobAlertRecipient { - NONE, - OWNER, - ADMIN, - OWNER_AND_ADMIN -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/JobIdListWrapper.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/JobIdListWrapper.java deleted file mode 100644 index a40c5106..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/JobIdListWrapper.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.dto.jobs; - -import java.util.LinkedList; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import java.util.List; - -/** - * @author Yaroslav.Kovalchyk - * @version $Id: JobIdListWrapper.java 38348 2013-09-30 04:57:18Z carbiv $ - * @deprecated (use server DTO). - */ -@XmlRootElement(name = "jobIdList") -public class JobIdListWrapper { - - private List ids; - - public JobIdListWrapper(){ - } - - public JobIdListWrapper(List ids){ - this.ids = ids; - } - - public JobIdListWrapper(JobIdListWrapper other){ - this.ids = new LinkedList(); - for (Long id : other.ids) { - this.ids.add(id); - } - } - - @XmlElement(name = "jobId") - public List getIds() { - return ids; - } - - public JobIdListWrapper setIds(List ids) { - this.ids = ids; - return this; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - JobIdListWrapper that = (JobIdListWrapper) o; - - if (ids != null ? !ids.equals(that.ids) : that.ids != null) return false; - - return true; - } - - @Override - public int hashCode() { - return ids != null ? ids.hashCode() : 0; - } - - @Override - public String toString() { - return "JobIdListWrapper{" + - "ids=" + ids + - '}'; - } -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/JobSource.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/JobSource.java deleted file mode 100644 index 7738f8d7..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/JobSource.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.dto.jobs; - -import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.jaxb.adapters.ReportJobSourceParametersXmlAdapter; -import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.jaxb.wrappers.ValuesCollection; - -import java.util.LinkedHashMap; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlSeeAlso; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; -import java.util.Map; -/** - * @deprecated (use server DTO). - */ -@XmlRootElement(name = "source") -@XmlSeeAlso(ValuesCollection.class) -public class JobSource { - - private String reportUnitURI; - private Map parameters; - - public JobSource() { - } - - public JobSource(JobSource other) { - this.parameters = (other.parameters != null) ? new LinkedHashMap(other.parameters) : null; - this.reportUnitURI = other.reportUnitURI; - } - - public String getReportUnitURI() { - return reportUnitURI; - } - - public JobSource setReportUnitURI(String reportUnitURI) { - this.reportUnitURI = reportUnitURI; - return this; - } - - @XmlJavaTypeAdapter(ReportJobSourceParametersXmlAdapter.class) - public Map getParameters() { - return parameters; - } - - public JobSource setParameters(Map parameters) { - this.parameters = parameters; - return this; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (!(o instanceof JobSource)) return false; - - JobSource source = (JobSource) o; - - if (parameters != null ? !parameters.equals(source.parameters) : source.parameters != null) return false; - if (reportUnitURI != null ? !reportUnitURI.equals(source.reportUnitURI) : source.reportUnitURI != null) - return false; - - return true; - } - - @Override - public int hashCode() { - int result = reportUnitURI != null ? reportUnitURI.hashCode() : 0; - result = 31 * result + (parameters != null ? parameters.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "JobSource{" + - "reportUnitURI='" + reportUnitURI + '\'' + - ", parameters=" + parameters + - '}'; - } -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/JobState.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/JobState.java deleted file mode 100644 index 4d2928d8..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/JobState.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.dto.jobs; - -import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.jaxb.adapters.DateToStringXmlAdapter; - -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; -import java.util.Date; -/** - * @deprecated (use server DTO). - */ -//@XmlAccessorType(XmlAccessType.FIELD) -@XmlRootElement(name = "state") -public class JobState { - - private Date previousFireTime; - private Date nextFireTime; - private JobStateType value; - - public JobState() { - } - - public JobState(JobState other) { - this.nextFireTime = (other.nextFireTime != null) ? new Date(other.nextFireTime.getTime()) : null; - this.previousFireTime = (other.previousFireTime != null) ? new Date(other.previousFireTime.getTime()) : null; - this.value = other.value; - } - - @XmlJavaTypeAdapter(DateToStringXmlAdapter.class) - public Date getPreviousFireTime() { - return previousFireTime; - } - - public JobState setPreviousFireTime(Date previousFireTime) { - this.previousFireTime = previousFireTime; - return this; - } - - @XmlJavaTypeAdapter(DateToStringXmlAdapter.class) - public Date getNextFireTime() { - return nextFireTime; - } - - public JobState setNextFireTime(Date nextFireTime) { - this.nextFireTime = nextFireTime; - return this; - } - - public JobStateType getValue() { - return value; - } - - public JobState setValue(JobStateType value) { - this.value = value; - return this; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (!(o instanceof JobState)) return false; - - JobState jobState = (JobState) o; - - if (nextFireTime != null ? !nextFireTime.equals(jobState.nextFireTime) : jobState.nextFireTime != null) - return false; - if (previousFireTime != null ? !previousFireTime.equals(jobState.previousFireTime) : jobState.previousFireTime != null) - return false; - if (value != null ? !value.equals(jobState.value) : jobState.value != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = previousFireTime != null ? previousFireTime.hashCode() : 0; - result = 31 * result + (nextFireTime != null ? nextFireTime.hashCode() : 0); - result = 31 * result + (value != null ? value.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "JobState{" + - "previousFireTime='" + previousFireTime + '\'' + - ", nextFireTime='" + nextFireTime + '\'' + - ", value='" + value + '\'' + - '}'; - } -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/JobStateType.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/JobStateType.java deleted file mode 100644 index a274b707..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/JobStateType.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.dto.jobs; -/** - * @deprecated (use server DTO). - */ -public enum JobStateType { - - UNKNOWN, - NORMAL, - EXECUTING, - PAUSED, - COMPLETE, - ERROR - -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/JobSummary.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/JobSummary.java deleted file mode 100644 index 931c0c47..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/JobSummary.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.dto.jobs; - -import javax.xml.bind.annotation.XmlRootElement; -/** - * @deprecated (use server DTO). - */ -//@XmlAccessorType(XmlAccessType.FIELD) -@XmlRootElement(name = "jobsummary") -public class JobSummary { - - private Long id; - private String label; - private String reportUnitURI; - private String owner; - private JobState state; - private Long version; - - public JobSummary() { - } - - public JobSummary(JobSummary other) { - this.id = other.id; - this.label = other.label; - this.owner = other.owner; - this.reportUnitURI = other.reportUnitURI; - this.state = (other.state != null) ? new JobState(other.state) : null; - this.version = other.version; - } - - public Long getId() { - return id; - } - - public JobSummary setId(Long id) { - this.id = id; - return this; - } - - public String getLabel() { - return label; - } - - public JobSummary setLabel(String label) { - this.label = label; - return this; - } - - public String getReportUnitURI() { - return reportUnitURI; - } - - public JobSummary setReportUnitURI(String reportUnitURI) { - this.reportUnitURI = reportUnitURI; - return this; - } - - public String getOwner() { - return owner; - } - - public JobSummary setOwner(String owner) { - this.owner = owner; - return this; - } - - public JobState getState() { - return state; - } - - public JobSummary setState(JobState state) { - this.state = state; - return this; - } - - public Long getVersion() { - return version; - } - - public JobSummary setVersion(Long version) { - this.version = version; - return this; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (!(o instanceof JobSummary)) return false; - - JobSummary that = (JobSummary) o; - - if (id != null ? !id.equals(that.id) : that.id != null) return false; - if (label != null ? !label.equals(that.label) : that.label != null) return false; - if (owner != null ? !owner.equals(that.owner) : that.owner != null) return false; - if (reportUnitURI != null ? !reportUnitURI.equals(that.reportUnitURI) : that.reportUnitURI != null) - return false; - if (state != null ? !state.equals(that.state) : that.state != null) return false; - if (version != null ? !version.equals(that.version) : that.version != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = id != null ? id.hashCode() : 0; - result = 31 * result + (label != null ? label.hashCode() : 0); - result = 31 * result + (reportUnitURI != null ? reportUnitURI.hashCode() : 0); - result = 31 * result + (owner != null ? owner.hashCode() : 0); - result = 31 * result + (state != null ? state.hashCode() : 0); - result = 31 * result + (version != null ? version.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "JobSummary{" + - "id=" + id + - ", label='" + label + '\'' + - ", reportUnitURI='" + reportUnitURI + '\'' + - ", owner='" + owner + '\'' + - ", state=" + state + - ", version=" + version + - '}'; - } -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/JobTrigger.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/JobTrigger.java deleted file mode 100644 index bc761910..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/JobTrigger.java +++ /dev/null @@ -1,210 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.dto.jobs; - -import com.jaspersoft.jasperserver.dto.common.DeepCloneable; -import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.jaxb.adapters.NoTimezoneDateToStringXmlAdapter; - -import java.lang.reflect.Constructor; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; -import java.util.Date; -/** - * @deprecated (use server DTO). - */ -public abstract class JobTrigger implements DeepCloneable { - - /** - * Start type that indicates that the job should be scheduled inFolder start - * immediately. - * - * @see #getStartType() - */ - public static final byte START_TYPE_NOW = 1; - - /** - * Start type that indicates that the job should be scheduled inFolder start - * at the specified start date. - * - * @see #getStartType() - * @see #getStartDate() - */ - public static final byte START_TYPE_SCHEDULE = 2; - - private Long id; - private Integer version; - private String timezone; - private String calendarName; - private int startType; - private Date startDate; - private Date endDate; - private Integer misfireInstruction; - - public JobTrigger() { - } - - public JobTrigger(JobTrigger other) { - this.calendarName = other.calendarName; - this.endDate = (other.endDate != null) ? new Date(other.endDate.getTime()) : null; - this.id = other.id; - this.misfireInstruction = other.misfireInstruction; - this.startDate = (other.startDate != null) ? new Date(other.startDate.getTime()) : null; - this.startType = other.startType; - this.timezone = other.timezone; - this.version = other.version; - } - - public Long getId() { - return id; - } - - public JobTrigger setId(Long id) { - this.id = id; - return this; - } - - public Integer getVersion() { - return version; - } - - public JobTrigger setVersion(Integer version) { - this.version = version; - return this; - } - - public String getTimezone() { - return timezone; - } - - public JobTrigger setTimezone(String timezone) { - this.timezone = timezone; - return this; - } - - public String getCalendarName() { - return calendarName; - } - - public JobTrigger setCalendarName(String calendarName) { - this.calendarName = calendarName; - return this; - } - - public int getStartType() { - return startType; - } - - public JobTrigger setStartType(int startType) { - this.startType = startType; - return this; - } - - @XmlJavaTypeAdapter(NoTimezoneDateToStringXmlAdapter.class) - public Date getStartDate() { - return startDate; - } - - public JobTrigger setStartDate(Date startDate) { - this.startDate = startDate; - return this; - } - - @XmlJavaTypeAdapter(NoTimezoneDateToStringXmlAdapter.class) - public Date getEndDate() { - return endDate; - } - - public JobTrigger setEndDate(Date endDate) { - this.endDate = endDate; - return this; - } - - public Integer getMisfireInstruction() { - return misfireInstruction; - } - - public JobTrigger setMisfireInstruction(Integer misfireInstruction) { - this.misfireInstruction = misfireInstruction; - return this; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (!(o instanceof JobTrigger)) return false; - - JobTrigger trigger = (JobTrigger) o; - - if (startType != trigger.startType) return false; - if (calendarName != null ? !calendarName.equals(trigger.calendarName) : trigger.calendarName != null) - return false; - if (endDate != null ? !endDate.equals(trigger.endDate) : trigger.endDate != null) return false; - if (id != null ? !id.equals(trigger.id) : trigger.id != null) return false; - if (misfireInstruction != null ? !misfireInstruction.equals(trigger.misfireInstruction) : trigger.misfireInstruction != null) - return false; - if (startDate != null ? !startDate.equals(trigger.startDate) : trigger.startDate != null) return false; - if (timezone != null ? !timezone.equals(trigger.timezone) : trigger.timezone != null) return false; - if (version != null ? !version.equals(trigger.version) : trigger.version != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = id != null ? id.hashCode() : 0; - result = 31 * result + (version != null ? version.hashCode() : 0); - result = 31 * result + (timezone != null ? timezone.hashCode() : 0); - result = 31 * result + (calendarName != null ? calendarName.hashCode() : 0); - result = 31 * result + startType; - result = 31 * result + (startDate != null ? startDate.hashCode() : 0); - result = 31 * result + (endDate != null ? endDate.hashCode() : 0); - result = 31 * result + (misfireInstruction != null ? misfireInstruction.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "JobTrigger{" + - "id=" + id + - ", version=" + version + - ", timezone='" + timezone + '\'' + - ", calendarName='" + calendarName + '\'' + - ", startType=" + startType + - ", startDate='" + startDate + '\'' + - ", endDate='" + endDate + '\'' + - ", misfireInstruction=" + misfireInstruction + - '}'; - } - - @Override - public JobTrigger deepClone() { - Class thisClass = this.getClass(); - - JobTrigger instance = null; - try { - Constructor constructor = thisClass.getConstructor(thisClass); - instance = constructor.newInstance(this); - } catch (ReflectiveOperationException e) { - e.printStackTrace(); - } - return instance; - } -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/MailNotification.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/MailNotification.java deleted file mode 100644 index 03bcbd99..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/MailNotification.java +++ /dev/null @@ -1,241 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.dto.jobs; - -import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.jaxb.adapters.AddressesXmlAdapter; - -import java.util.LinkedList; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; -import java.util.List; -/** - * @deprecated (use server DTO). - */ -@XmlRootElement(name = "mailNotification") -public class MailNotification { - - - private List bccAddresses; - private List ccAddresses; - private List toAddresses; - private Integer version; - private Long id; - private Boolean includingStackTraceWhenJobFails; - private String messageText; - private MailNotificationSendType resultSendType; - private Boolean skipEmptyReports; - private Boolean skipNotificationWhenJobFails; - private String subject; - private String messageTextWhenJobFails; - - public MailNotification() { - } - - public MailNotification(MailNotification other) { - this.bccAddresses = (other.bccAddresses != null) ? new LinkedList(other.bccAddresses) : null; - this.ccAddresses = (other.ccAddresses != null) ? new LinkedList(other.ccAddresses) : null; - this.toAddresses = (other.toAddresses != null) ? new LinkedList(other.toAddresses) : null; - this.id = other.id; - this.includingStackTraceWhenJobFails = other.includingStackTraceWhenJobFails; - this.messageText = other.messageText; - this.messageTextWhenJobFails = other.messageTextWhenJobFails; - this.resultSendType = other.resultSendType; - this.skipEmptyReports = other.skipEmptyReports; - this.skipNotificationWhenJobFails = other.skipNotificationWhenJobFails; - this.subject = other.subject; - this.version = other.version; - } - - @XmlJavaTypeAdapter(AddressesXmlAdapter.class) - public List getCcAddresses() { - return ccAddresses; - } - - public MailNotification setCcAddresses(List ccAddresses) { - this.ccAddresses = ccAddresses; - return this; - } - - @XmlJavaTypeAdapter(AddressesXmlAdapter.class) - public List getToAddresses() { - return toAddresses; - } - - public MailNotification setToAddresses(List toAddresses) { - this.toAddresses = toAddresses; - return this; - } - - @XmlJavaTypeAdapter(AddressesXmlAdapter.class) - public List getBccAddresses() { - return bccAddresses; - } - - public MailNotification setBccAddresses(List bccAddresses) { - this.bccAddresses = bccAddresses; - return this; - } - - public Integer getVersion() { - return version; - } - - public MailNotification setVersion(Integer version) { - this.version = version; - return this; - } - - public Long getId() { - return id; - } - - public MailNotification setId(Long id) { - this.id = id; - return this; - } - - public Boolean isIncludingStackTraceWhenJobFails() { - return includingStackTraceWhenJobFails; - } - - public MailNotification setIncludingStackTraceWhenJobFails(Boolean includingStackTraceWhenJobFails) { - this.includingStackTraceWhenJobFails = includingStackTraceWhenJobFails; - return this; - } - - public String getMessageText() { - return messageText; - } - - public MailNotification setMessageText(String messageText) { - this.messageText = messageText; - return this; - } - - public Boolean isSkipEmptyReports() { - return skipEmptyReports; - } - - public MailNotification setSkipEmptyReports(Boolean skipEmptyReports) { - this.skipEmptyReports = skipEmptyReports; - return this; - } - - public Boolean isSkipNotificationWhenJobFails() { - return skipNotificationWhenJobFails; - } - - public MailNotification setSkipNotificationWhenJobFails(Boolean skipNotificationWhenJobFails) { - this.skipNotificationWhenJobFails = skipNotificationWhenJobFails; - return this; - } - - public String getSubject() { - return subject; - } - - public MailNotification setSubject(String subject) { - this.subject = subject; - return this; - } - - public String getMessageTextWhenJobFails() { - return messageTextWhenJobFails; - } - - public MailNotification setMessageTextWhenJobFails(String messageTextWhenJobFails) { - this.messageTextWhenJobFails = messageTextWhenJobFails; - return this; - } - - public MailNotificationSendType getResultSendType() { - return resultSendType; - } - - public MailNotification setResultSendType(MailNotificationSendType resultSendType) { - this.resultSendType = resultSendType; - return this; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (!(o instanceof MailNotification)) return false; - - MailNotification that = (MailNotification) o; - - if (bccAddresses != null ? !bccAddresses.equals(that.bccAddresses) : that.bccAddresses != null) return false; - if (ccAddresses != null ? !ccAddresses.equals(that.ccAddresses) : that.ccAddresses != null) return false; - if (id != null ? !id.equals(that.id) : that.id != null) return false; - if (includingStackTraceWhenJobFails != null ? !includingStackTraceWhenJobFails.equals(that.includingStackTraceWhenJobFails) : that.includingStackTraceWhenJobFails != null) - return false; - if (messageText != null ? !messageText.equals(that.messageText) : that.messageText != null) return false; - if (messageTextWhenJobFails != null ? !messageTextWhenJobFails.equals(that.messageTextWhenJobFails) : that.messageTextWhenJobFails != null) - return false; - if (resultSendType != null ? !resultSendType.equals(that.resultSendType) : that.resultSendType != null) - return false; - if (skipEmptyReports != null ? !skipEmptyReports.equals(that.skipEmptyReports) : that.skipEmptyReports != null) - return false; - if (skipNotificationWhenJobFails != null ? !skipNotificationWhenJobFails.equals(that.skipNotificationWhenJobFails) : that.skipNotificationWhenJobFails != null) - return false; - if (subject != null ? !subject.equals(that.subject) : that.subject != null) return false; - if (toAddresses != null ? !toAddresses.equals(that.toAddresses) : that.toAddresses != null) return false; - if (version != null ? !version.equals(that.version) : that.version != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = bccAddresses != null ? bccAddresses.hashCode() : 0; - result = 31 * result + (ccAddresses != null ? ccAddresses.hashCode() : 0); - result = 31 * result + (toAddresses != null ? toAddresses.hashCode() : 0); - result = 31 * result + (version != null ? version.hashCode() : 0); - result = 31 * result + (id != null ? id.hashCode() : 0); - result = 31 * result + (includingStackTraceWhenJobFails != null ? includingStackTraceWhenJobFails.hashCode() : 0); - result = 31 * result + (messageText != null ? messageText.hashCode() : 0); - result = 31 * result + (resultSendType != null ? resultSendType.hashCode() : 0); - result = 31 * result + (skipEmptyReports != null ? skipEmptyReports.hashCode() : 0); - result = 31 * result + (skipNotificationWhenJobFails != null ? skipNotificationWhenJobFails.hashCode() : 0); - result = 31 * result + (subject != null ? subject.hashCode() : 0); - result = 31 * result + (messageTextWhenJobFails != null ? messageTextWhenJobFails.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "MailNotification{" + - "bccAddresses=" + bccAddresses + - ", ccAddresses=" + ccAddresses + - ", toAddresses=" + toAddresses + - ", version=" + version + - ", id=" + id + - ", includingStackTraceWhenJobFails=" + includingStackTraceWhenJobFails + - ", messageText='" + messageText + '\'' + - ", resultSendType='" + resultSendType + '\'' + - ", skipEmptyReports=" + skipEmptyReports + - ", skipNotificationWhenJobFails=" + skipNotificationWhenJobFails + - ", subject='" + subject + '\'' + - ", messageTextWhenJobFails='" + messageTextWhenJobFails + '\'' + - '}'; - } -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/MailNotificationSendType.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/MailNotificationSendType.java deleted file mode 100644 index 7fc1778c..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/MailNotificationSendType.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.dto.jobs; -/** - * @deprecated (use server DTO). - */ -public enum MailNotificationSendType { - - SEND, - SEND_ATTACHMENT, - SEND_ATTACHMENT_NOZIP, - SEND_EMBED, - SEND_ATTACHMENT_ZIP_ALL, - SEND_EMBED_ZIP_ALL_OTHERS - -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/OutputFormat.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/OutputFormat.java deleted file mode 100644 index 6089096f..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/OutputFormat.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.dto.jobs; -/** - * @deprecated (use server DTO). - */ -public enum OutputFormat { - PDF, - HTML, - XLS, - RTF, - CSV, - ODT, - TXT, - DOCX, - ODS, - XLSX, - XLS_NOPAG, - XLSX_NOPAG, - DATA_SNAPSHOT -} \ No newline at end of file diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/ReportJobCalendar.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/ReportJobCalendar.java deleted file mode 100644 index d4b20b17..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/ReportJobCalendar.java +++ /dev/null @@ -1,247 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.dto.jobs; - -import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.jaxb.adapters.ExcludeDaysXmlAdapter; -import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.jaxb.adapters.TimeZoneXmlAdapter; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Calendar; -import java.util.TimeZone; - -/** - * @author Yaroslav.Kovalchyk - * @version $Id: ReportJobCalendar.java 23844 2012-05-22 06:23:41Z ykovalchyk $ - * @deprecated (use server DTO). - */ -@XmlRootElement -public class ReportJobCalendar { - - private String calendarType; - // base fields - private ReportJobCalendar baseCalendar; - private String description; - private TimeZone timeZone; - - //annual calendar's fields - //excludeDays field used for holiday calendar too - private ArrayList excludeDays = new ArrayList(); - // true, if excludeDays is sorted - private Boolean dataSorted; - - //cron calendar's fields - private String cronExpression; - - //daily calendar's fields - private Calendar rangeStartingCalendar; - private Calendar rangeEndingCalendar; - private Boolean invertTimeRange; - - //monthly calendar's fields - // An array inFolder store a months days which are inFolder be excluded. - // java.util.Calendar.get( ) as index. - private boolean[] excludeDaysFlags; - - public ReportJobCalendar() { - } - - public ReportJobCalendar(ReportJobCalendar other) { - this.baseCalendar = (other.baseCalendar != null) ? new ReportJobCalendar(other.baseCalendar) : null; - this.calendarType = other.calendarType; - this.cronExpression = other.cronExpression; - this.dataSorted = other.dataSorted; - this.description = other.description; - if (other.excludeDays != null) { - this.excludeDays = new ArrayList(); - for (Calendar excludeDay : other.excludeDays) { - this.excludeDays.add((Calendar) excludeDay.clone()); - } - } - if (other.excludeDaysFlags != null) { - this.excludeDaysFlags = new boolean[other.excludeDaysFlags.length]; - for (int i = 0; i < other.excludeDaysFlags.length; i++) { - this.excludeDaysFlags[i] = other.excludeDaysFlags[i]; - } - } - this.invertTimeRange = other.invertTimeRange; - this.rangeEndingCalendar = (other.rangeEndingCalendar != null) ? - (Calendar) other.rangeEndingCalendar.clone() : null; - this.rangeStartingCalendar = (other.rangeStartingCalendar != null) ? - (Calendar) other.rangeStartingCalendar.clone() : null; - this.timeZone = (other.timeZone != null) ? (TimeZone) other.timeZone.clone() : null; - } - - public String getCalendarType() { - return calendarType; - } - - public void setCalendarType(String calendarType) { - this.calendarType = calendarType; - } - - public ReportJobCalendar getBaseCalendar() { - return baseCalendar; - } - - public void setBaseCalendar(ReportJobCalendar baseCalendar) { - this.baseCalendar = baseCalendar; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - @XmlJavaTypeAdapter(TimeZoneXmlAdapter.class) - public TimeZone getTimeZone() { - return timeZone; - } - - public void setTimeZone(TimeZone timeZone) { - this.timeZone = timeZone; - } - - @XmlJavaTypeAdapter(ExcludeDaysXmlAdapter.class) - public ArrayList getExcludeDays() { - return excludeDays; - } - - public void setExcludeDays(ArrayList excludeDays) { - this.excludeDays = excludeDays; - } - - public Boolean isDataSorted() { - return dataSorted; - } - - public void setDataSorted(Boolean dataSorted) { - this.dataSorted = dataSorted; - } - - public String getCronExpression() { - return cronExpression; - } - - public void setCronExpression(String cronExpression) { - this.cronExpression = cronExpression; - } - - public Calendar getRangeStartingCalendar() { - return rangeStartingCalendar; - } - - public void setRangeStartingCalendar(Calendar rangeStartingCalendar) { - this.rangeStartingCalendar = rangeStartingCalendar; - } - - public Calendar getRangeEndingCalendar() { - return rangeEndingCalendar; - } - - public void setRangeEndingCalendar(Calendar rangeEndingCalendar) { - this.rangeEndingCalendar = rangeEndingCalendar; - } - - public Boolean isInvertTimeRange() { - return invertTimeRange; - } - - public void setInvertTimeRange(Boolean invertTimeRange) { - this.invertTimeRange = invertTimeRange; - } - - @XmlElementWrapper(name = "excludeDaysFlags") - @XmlElement(name = "excludeDayFlag") - public boolean[] getExcludeDaysFlags() { - return excludeDaysFlags; - } - - public void setExcludeDaysFlags(boolean[] excludeDaysFlags) { - this.excludeDaysFlags = excludeDaysFlags; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (!(o instanceof ReportJobCalendar)) return false; - - ReportJobCalendar that = (ReportJobCalendar) o; - - if (baseCalendar != null ? !baseCalendar.equals(that.baseCalendar) : that.baseCalendar != null) return false; - if (calendarType != null ? !calendarType.equals(that.calendarType) : that.calendarType != null) return false; - if (cronExpression != null ? !cronExpression.equals(that.cronExpression) : that.cronExpression != null) - return false; - if (dataSorted != null ? !dataSorted.equals(that.dataSorted) : that.dataSorted != null) return false; - if (description != null ? !description.equals(that.description) : that.description != null) return false; - if (excludeDays != null ? !excludeDays.equals(that.excludeDays) : that.excludeDays != null) return false; - if (!Arrays.equals(excludeDaysFlags, that.excludeDaysFlags)) return false; - if (invertTimeRange != null ? !invertTimeRange.equals(that.invertTimeRange) : that.invertTimeRange != null) - return false; - if (rangeEndingCalendar != null ? !rangeEndingCalendar.equals(that.rangeEndingCalendar) : that.rangeEndingCalendar != null) - return false; - if (rangeStartingCalendar != null ? !rangeStartingCalendar.equals(that.rangeStartingCalendar) : that.rangeStartingCalendar != null) - return false; - if (timeZone != null ? !timeZone.equals(that.timeZone) : that.timeZone != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = calendarType != null ? calendarType.hashCode() : 0; - result = 31 * result + (baseCalendar != null ? baseCalendar.hashCode() : 0); - result = 31 * result + (description != null ? description.hashCode() : 0); - result = 31 * result + (timeZone != null ? timeZone.hashCode() : 0); - result = 31 * result + (excludeDays != null ? excludeDays.hashCode() : 0); - result = 31 * result + (dataSorted != null ? dataSorted.hashCode() : 0); - result = 31 * result + (cronExpression != null ? cronExpression.hashCode() : 0); - result = 31 * result + (rangeStartingCalendar != null ? rangeStartingCalendar.hashCode() : 0); - result = 31 * result + (rangeEndingCalendar != null ? rangeEndingCalendar.hashCode() : 0); - result = 31 * result + (invertTimeRange != null ? invertTimeRange.hashCode() : 0); - result = 31 * result + (excludeDaysFlags != null ? Arrays.hashCode(excludeDaysFlags) : 0); - return result; - } - - @Override - public String toString() { - return "ReportJobCalendar{" + - "calendarType='" + calendarType + '\'' + - ", baseCalendar=" + baseCalendar + - ", description='" + description + '\'' + - ", timeZone=" + timeZone + - ", excludeDays=" + excludeDays + - ", dataSorted=" + dataSorted + - ", cronExpression='" + cronExpression + '\'' + - ", rangeStartingCalendar=" + rangeStartingCalendar + - ", rangeEndingCalendar=" + rangeEndingCalendar + - ", invertTimeRange=" + invertTimeRange + - ", excludeDaysFlags=" + Arrays.toString(excludeDaysFlags) + - '}'; - } -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/RepositoryDestination.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/RepositoryDestination.java deleted file mode 100644 index b16b5008..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/RepositoryDestination.java +++ /dev/null @@ -1,236 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.dto.jobs; - -import javax.xml.bind.annotation.XmlRootElement; -/** - * @deprecated (use server DTO). - */ -@XmlRootElement(name = "repositoryDestination") -public class RepositoryDestination { - - private String folderURI; - private Long id; - private String outputDescription; - private Boolean overwriteFiles; - private Boolean sequentialFilenames; - private Long version; - private String timestampPattern; - private Boolean saveToRepository; - private String defaultReportOutputFolderURI; - private Boolean usingDefaultReportOutputFolderURI; - private String outputLocalFolder; - private FtpInfo outputFTPInfo; - - public RepositoryDestination() { - } - - public RepositoryDestination(RepositoryDestination other) { - this.defaultReportOutputFolderURI = other.defaultReportOutputFolderURI; - this.folderURI = other.folderURI; - this.id = other.id; - this.outputDescription = other.outputDescription; - this.outputFTPInfo = (other.outputFTPInfo != null) ? new FtpInfo(other.outputFTPInfo) : null; - this.outputLocalFolder = other.outputLocalFolder; - this.overwriteFiles = other.overwriteFiles; - this.saveToRepository = other.saveToRepository; - this.sequentialFilenames = other.sequentialFilenames; - this.timestampPattern = other.timestampPattern; - this.usingDefaultReportOutputFolderURI = other.usingDefaultReportOutputFolderURI; - this.version = other.version; - } - - public String getFolderURI() { - return folderURI; - } - - public RepositoryDestination setFolderURI(String folderURI) { - this.folderURI = folderURI; - return this; - } - - public Long getId() { - return id; - } - - public RepositoryDestination setId(Long id) { - this.id = id; - return this; - } - - public String getOutputDescription() { - return outputDescription; - } - - public RepositoryDestination setOutputDescription(String outputDescription) { - this.outputDescription = outputDescription; - return this; - } - - public Boolean isOverwriteFiles() { - return overwriteFiles; - } - - public RepositoryDestination setOverwriteFiles(Boolean overwriteFiles) { - this.overwriteFiles = overwriteFiles; - return this; - } - - public Boolean isSequentialFilenames() { - return sequentialFilenames; - } - - public RepositoryDestination setSequentialFilenames(Boolean sequentialFilenames) { - this.sequentialFilenames = sequentialFilenames; - return this; - } - - public Long getVersion() { - return version; - } - - public RepositoryDestination setVersion(Long version) { - this.version = version; - return this; - } - - public String getTimestampPattern() { - return timestampPattern; - } - - public RepositoryDestination setTimestampPattern(String timestampPattern) { - this.timestampPattern = timestampPattern; - return this; - } - - public Boolean isSaveToRepository() { - return saveToRepository; - } - - public RepositoryDestination setSaveToRepository(Boolean saveToRepository) { - this.saveToRepository = saveToRepository; - return this; - } - - public String getDefaultReportOutputFolderURI() { - return defaultReportOutputFolderURI; - } - - public RepositoryDestination setDefaultReportOutputFolderURI(String defaultReportOutputFolderURI) { - this.defaultReportOutputFolderURI = defaultReportOutputFolderURI; - return this; - } - - public Boolean isUsingDefaultReportOutputFolderURI() { - return usingDefaultReportOutputFolderURI; - } - - public RepositoryDestination setUsingDefaultReportOutputFolderURI(Boolean usingDefaultReportOutputFolderURI) { - this.usingDefaultReportOutputFolderURI = usingDefaultReportOutputFolderURI; - return this; - } - - public String getOutputLocalFolder() { - return outputLocalFolder; - } - - public RepositoryDestination setOutputLocalFolder(String outputLocalFolder) { - this.outputLocalFolder = outputLocalFolder; - return this; - } - - public FtpInfo getOutputFTPInfo() { - return outputFTPInfo; - } - - public RepositoryDestination setOutputFTPInfo(FtpInfo outputFTPInfo) { - this.outputFTPInfo = outputFTPInfo; - return this; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (!(o instanceof RepositoryDestination)) return false; - - RepositoryDestination that = (RepositoryDestination) o; - - if (defaultReportOutputFolderURI != null ? !defaultReportOutputFolderURI.equals(that.defaultReportOutputFolderURI) : that.defaultReportOutputFolderURI != null) - return false; - if (folderURI != null ? !folderURI.equals(that.folderURI) : that.folderURI != null) return false; - if (id != null ? !id.equals(that.id) : that.id != null) return false; - if (outputDescription != null ? !outputDescription.equals(that.outputDescription) : that.outputDescription != null) - return false; - if (outputFTPInfo != null ? !outputFTPInfo.equals(that.outputFTPInfo) : that.outputFTPInfo != null) - return false; - if (outputLocalFolder != null ? !outputLocalFolder.equals(that.outputLocalFolder) : that.outputLocalFolder != null) - return false; - if (overwriteFiles != null ? !overwriteFiles.equals(that.overwriteFiles) : that.overwriteFiles != null) - return false; - if (saveToRepository != null ? !saveToRepository.equals(that.saveToRepository) : that.saveToRepository != null) - return false; - if (sequentialFilenames != null ? !sequentialFilenames.equals(that.sequentialFilenames) : that.sequentialFilenames != null) - return false; - if (timestampPattern != null ? !timestampPattern.equals(that.timestampPattern) : that.timestampPattern != null) - return false; - if (usingDefaultReportOutputFolderURI != null ? !usingDefaultReportOutputFolderURI.equals(that.usingDefaultReportOutputFolderURI) : that.usingDefaultReportOutputFolderURI != null) - return false; - if (version != null ? !version.equals(that.version) : that.version != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = folderURI != null ? folderURI.hashCode() : 0; - result = 31 * result + (id != null ? id.hashCode() : 0); - result = 31 * result + (outputDescription != null ? outputDescription.hashCode() : 0); - result = 31 * result + (overwriteFiles != null ? overwriteFiles.hashCode() : 0); - result = 31 * result + (sequentialFilenames != null ? sequentialFilenames.hashCode() : 0); - result = 31 * result + (version != null ? version.hashCode() : 0); - result = 31 * result + (timestampPattern != null ? timestampPattern.hashCode() : 0); - result = 31 * result + (saveToRepository != null ? saveToRepository.hashCode() : 0); - result = 31 * result + (defaultReportOutputFolderURI != null ? defaultReportOutputFolderURI.hashCode() : 0); - result = 31 * result + (usingDefaultReportOutputFolderURI != null ? usingDefaultReportOutputFolderURI.hashCode() : 0); - result = 31 * result + (outputLocalFolder != null ? outputLocalFolder.hashCode() : 0); - result = 31 * result + (outputFTPInfo != null ? outputFTPInfo.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "RepositoryDestination{" + - "folderURI='" + folderURI + '\'' + - ", id=" + id + - ", outputDescription='" + outputDescription + '\'' + - ", overwriteFiles=" + overwriteFiles + - ", sequentialFilenames=" + sequentialFilenames + - ", version=" + version + - ", timestampPattern='" + timestampPattern + '\'' + - ", saveToRepository=" + saveToRepository + - ", defaultReportOutputFolderURI='" + defaultReportOutputFolderURI + '\'' + - ", usingDefaultReportOutputFolderURI=" + usingDefaultReportOutputFolderURI + - ", outputLocalFolder='" + outputLocalFolder + '\'' + - ", outputFTPInfo=" + outputFTPInfo + - '}'; - } -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/SimpleTrigger.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/SimpleTrigger.java deleted file mode 100644 index fe21665c..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/SimpleTrigger.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.dto.jobs; - -import javax.xml.bind.annotation.XmlRootElement; -/** - * @deprecated (use server DTO). - */ -@XmlRootElement(name = "simpleTrigger") -public class SimpleTrigger extends JobTrigger { - - private Integer occurrenceCount; - private Integer recurrenceInterval; - private IntervalUnitType recurrenceIntervalUnit; - - public SimpleTrigger() { - super(); - } - - public SimpleTrigger(SimpleTrigger other) { - super(other); - this.occurrenceCount = other.occurrenceCount; - this.recurrenceInterval = other.recurrenceInterval; - this.recurrenceIntervalUnit = other.recurrenceIntervalUnit; - } - - public Integer getOccurrenceCount() { - return occurrenceCount; - } - - public SimpleTrigger setOccurrenceCount(Integer occurrenceCount) { - this.occurrenceCount = occurrenceCount; - return this; - } - - public Integer getRecurrenceInterval() { - return recurrenceInterval; - } - - public SimpleTrigger setRecurrenceInterval(Integer recurrenceInterval) { - this.recurrenceInterval = recurrenceInterval; - return this; - } - - public IntervalUnitType getRecurrenceIntervalUnit() { - return recurrenceIntervalUnit; - } - - public SimpleTrigger setRecurrenceIntervalUnit(IntervalUnitType recurrenceIntervalUnit) { - this.recurrenceIntervalUnit = recurrenceIntervalUnit; - return this; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (!(o instanceof SimpleTrigger)) return false; - if (!super.equals(o)) return false; - - SimpleTrigger that = (SimpleTrigger) o; - - if (occurrenceCount != null ? !occurrenceCount.equals(that.occurrenceCount) : that.occurrenceCount != null) - return false; - if (recurrenceInterval != null ? !recurrenceInterval.equals(that.recurrenceInterval) : that.recurrenceInterval != null) - return false; - if (recurrenceIntervalUnit != null ? !recurrenceIntervalUnit.equals(that.recurrenceIntervalUnit) : that.recurrenceIntervalUnit != null) - return false; - - return true; - } - - @Override - public int hashCode() { - int result = super.hashCode(); - result = 31 * result + (occurrenceCount != null ? occurrenceCount.hashCode() : 0); - result = 31 * result + (recurrenceInterval != null ? recurrenceInterval.hashCode() : 0); - result = 31 * result + (recurrenceIntervalUnit != null ? recurrenceIntervalUnit.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "SimpleTrigger{" + - "occurrenceCount=" + occurrenceCount + - ", recurrenceInterval=" + recurrenceInterval + - ", recurrenceIntervalUnit='" + recurrenceIntervalUnit + '\'' + - "} " + super.toString(); - } -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/calendars/AnnualCalendar.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/calendars/AnnualCalendar.java deleted file mode 100644 index 7b07f05f..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/calendars/AnnualCalendar.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.calendars; - -import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.jobs.calendar.CalendarType; -import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.jaxb.adapters.ExcludeDaysXmlAdapter; - -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; -import java.util.ArrayList; -/** - * @deprecated (use com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.calendar.* pakage). - */ -@XmlRootElement(name = "reportJobCalendar") -public class AnnualCalendar extends Calendar { - - private ArrayList excludeDays = new ArrayList(); - // true, if excludeDays is sorted - private Boolean dataSorted; - - public AnnualCalendar() { - super(); - this.calendarType = CalendarType.annual; - } - - public AnnualCalendar(AnnualCalendar other) { - super(other); - this.excludeDays = new ArrayList(); - for (java.util.Calendar calendar : other.getExcludeDays()) { - this.excludeDays.add((java.util.Calendar) calendar.clone()); - } - this.dataSorted = other.dataSorted; - } - - @XmlJavaTypeAdapter(ExcludeDaysXmlAdapter.class) - public ArrayList getExcludeDays() { - return excludeDays; - } - - public AnnualCalendar setExcludeDays(ArrayList excludeDays) { - this.excludeDays = excludeDays; - return this; - } - - public Boolean getDataSorted() { - return dataSorted; - } - - public AnnualCalendar setDataSorted(Boolean dataSorted) { - this.dataSorted = dataSorted; - return this; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - if (!super.equals(o)) return false; - - AnnualCalendar that = (AnnualCalendar) o; - - if (dataSorted != null ? !dataSorted.equals(that.dataSorted) : that.dataSorted != null) return false; - if (excludeDays != null ? !excludeDays.equals(that.excludeDays) : that.excludeDays != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = super.hashCode(); - result = 31 * result + (excludeDays != null ? excludeDays.hashCode() : 0); - result = 31 * result + (dataSorted != null ? dataSorted.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "AnnualCalendar{" + - "excludeDays=" + excludeDays + - ", dataSorted=" + dataSorted + - '}'; - } -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/calendars/BaseCalendar.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/calendars/BaseCalendar.java deleted file mode 100644 index d1f9bd6c..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/calendars/BaseCalendar.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.calendars; - -import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.jobs.calendar.CalendarType; - -import javax.xml.bind.annotation.XmlRootElement; -/** - * @deprecated (use com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.calendar.* pakage). - */ -@XmlRootElement(name = "reportJobCalendar") -public class BaseCalendar extends Calendar { - - public BaseCalendar(){ - this.calendarType = CalendarType.base; - } - - BaseCalendar(BaseCalendar other) { - super(other); - } - - -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/calendars/Calendar.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/calendars/Calendar.java deleted file mode 100644 index 9f4cd775..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/calendars/Calendar.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.calendars; - -import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.jobs.calendar.CalendarType; - -import java.util.TimeZone; -/** - * @deprecated (use com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.calendar.* pakage). - */ -public abstract class Calendar { - - protected CalendarType calendarType; - protected String description; - protected TimeZone timeZone; - - public Calendar() { - } - - protected Calendar(Calendar other){ - this.calendarType = other.calendarType; - this.description = other.description; - this.timeZone = (other.timeZone != null) ? (TimeZone) other.timeZone.clone() : null; - } - - public CalendarType getCalendarType() { - return calendarType; - } - - public Calendar setCalendarType(CalendarType calendarType) { - this.calendarType = calendarType; - return this; - } - - public String getDescription() { - return description; - } - - public Calendar setDescription(String description) { - this.description = description; - return this; - } - - public TimeZone getTimeZone() { - return timeZone; - } - - public Calendar setTimeZone(TimeZone timeZone) { - this.timeZone = timeZone; - return this; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Calendar calendar = (Calendar) o; - - if (calendarType != null ? !calendarType.equals(calendar.calendarType) : calendar.calendarType != null) - return false; - if (description != null ? !description.equals(calendar.description) : calendar.description != null) - return false; - if (timeZone != null ? !timeZone.equals(calendar.timeZone) : calendar.timeZone != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = calendarType != null ? calendarType.hashCode() : 0; - result = 31 * result + (description != null ? description.hashCode() : 0); - result = 31 * result + (timeZone != null ? timeZone.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "Calendar{" + - "calendarType='" + calendarType + '\'' + - ", description='" + description + '\'' + - ", timeZone='" + timeZone + '\'' + - '}'; - } -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/calendars/CronCalendar.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/calendars/CronCalendar.java deleted file mode 100644 index 9af22583..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/calendars/CronCalendar.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.calendars; - -import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.jobs.calendar.CalendarType; - -import javax.xml.bind.annotation.XmlRootElement; -/** - * @deprecated (use com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.calendar.* pakage). - */ -@XmlRootElement(name = "reportJobCalendar") -public class CronCalendar extends Calendar { - - private String cronExpression; - - public CronCalendar() { - super(); - this.calendarType = CalendarType.cron; - } - - public CronCalendar(CronCalendar other) { - super(other); - this.cronExpression = other.cronExpression; - } - - public String getCronExpression() { - return cronExpression; - } - - public CronCalendar setCronExpression(String cronExpression) { - this.cronExpression = cronExpression; - return this; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - if (!super.equals(o)) return false; - - CronCalendar that = (CronCalendar) o; - - if (cronExpression != null ? !cronExpression.equals(that.cronExpression) : that.cronExpression != null) - return false; - - return true; - } - - @Override - public int hashCode() { - int result = super.hashCode(); - result = 31 * result + (cronExpression != null ? cronExpression.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "CronCalendar{" + - "cronExpression='" + cronExpression + '\'' + - "} " + super.toString(); - } -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/calendars/DailyCalendar.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/calendars/DailyCalendar.java deleted file mode 100644 index 70937d00..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/calendars/DailyCalendar.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.calendars; - -import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.jobs.calendar.CalendarType; - -import javax.xml.bind.annotation.XmlRootElement; -/** - * @deprecated (use com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.calendar.* pakage). - */ -@XmlRootElement(name = "reportJobCalendar") -public class DailyCalendar extends Calendar { - - private java.util.Calendar rangeStartingCalendar; - private java.util.Calendar rangeEndingCalendar; - private Boolean invertTimeRange; - - public DailyCalendar() { - super(); - calendarType = CalendarType.daily; - } - - public DailyCalendar(DailyCalendar other) { - super(other); - this.invertTimeRange = other.invertTimeRange; - this.rangeEndingCalendar = (other.rangeEndingCalendar != null) ? (java.util.Calendar) other.rangeEndingCalendar.clone() : null; - this.rangeStartingCalendar = (other.rangeStartingCalendar != null) ? (java.util.Calendar) other.rangeStartingCalendar.clone() : null; - } - - public java.util.Calendar getRangeStartingCalendar() { - return rangeStartingCalendar; - } - - public DailyCalendar setRangeStartingCalendar(java.util.Calendar rangeStartingCalendar) { - this.rangeStartingCalendar = rangeStartingCalendar; - return this; - } - - public java.util.Calendar getRangeEndingCalendar() { - return rangeEndingCalendar; - } - - public DailyCalendar setRangeEndingCalendar(java.util.Calendar rangeEndingCalendar) { - this.rangeEndingCalendar = rangeEndingCalendar; - return this; - } - - public Boolean getInvertTimeRange() { - return invertTimeRange; - } - - public DailyCalendar setInvertTimeRange(Boolean invertTimeRange) { - this.invertTimeRange = invertTimeRange; - return this; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - if (!super.equals(o)) return false; - - DailyCalendar that = (DailyCalendar) o; - - if (invertTimeRange != null ? !invertTimeRange.equals(that.invertTimeRange) : that.invertTimeRange != null) - return false; - if (rangeEndingCalendar != null ? !rangeEndingCalendar.equals(that.rangeEndingCalendar) : that.rangeEndingCalendar != null) - return false; - if (rangeStartingCalendar != null ? !rangeStartingCalendar.equals(that.rangeStartingCalendar) : that.rangeStartingCalendar != null) - return false; - - return true; - } - - @Override - public int hashCode() { - int result = super.hashCode(); - result = 31 * result + (rangeStartingCalendar != null ? rangeStartingCalendar.hashCode() : 0); - result = 31 * result + (rangeEndingCalendar != null ? rangeEndingCalendar.hashCode() : 0); - result = 31 * result + (invertTimeRange != null ? invertTimeRange.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "DailyCalendar{" + - "rangeStartingCalendar=" + rangeStartingCalendar + - ", rangeEndingCalendar=" + rangeEndingCalendar + - ", invertTimeRange=" + invertTimeRange + - "} " + super.toString(); - } -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/calendars/HolidayCalendar.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/calendars/HolidayCalendar.java deleted file mode 100644 index 2fbef520..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/calendars/HolidayCalendar.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.calendars; - -import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.jobs.calendar.CalendarType; -import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.jaxb.adapters.ExcludeDaysXmlAdapter; - -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; -import java.util.ArrayList; - -/** - * @deprecated (use com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.calendar.* pakage). - */ -@XmlRootElement(name = "reportJobCalendar") -public class HolidayCalendar extends Calendar { - - public HolidayCalendar() { - super(); - this.calendarType = CalendarType.holiday; - } - - public HolidayCalendar(HolidayCalendar other) { - super(other); - this.dataSorted = other.dataSorted; - this.excludeDays = new ArrayList(); - for (java.util.Calendar excludeDay : other.excludeDays) { - this.excludeDays.add(excludeDay); - } - } - - private ArrayList excludeDays = new ArrayList(); - // true, if excludeDays is sorted - private Boolean dataSorted; - - @XmlJavaTypeAdapter(ExcludeDaysXmlAdapter.class) - public ArrayList getExcludeDays() { - return excludeDays; - } - - public HolidayCalendar setExcludeDays(ArrayList excludeDays) { - this.excludeDays = excludeDays; - return this; - } - - public Boolean getDataSorted() { - return dataSorted; - } - - public HolidayCalendar setDataSorted(Boolean dataSorted) { - this.dataSorted = dataSorted; - return this; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - if (!super.equals(o)) return false; - - HolidayCalendar that = (HolidayCalendar) o; - - if (dataSorted != null ? !dataSorted.equals(that.dataSorted) : that.dataSorted != null) return false; - if (excludeDays != null ? !excludeDays.equals(that.excludeDays) : that.excludeDays != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = super.hashCode(); - result = 31 * result + (excludeDays != null ? excludeDays.hashCode() : 0); - result = 31 * result + (dataSorted != null ? dataSorted.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "HolidayCalendar{" + - "excludeDays=" + excludeDays + - ", dataSorted=" + dataSorted + - "} " + super.toString(); - } -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/calendars/MonthlyCalendar.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/calendars/MonthlyCalendar.java deleted file mode 100644 index fe41d922..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/calendars/MonthlyCalendar.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.calendars; - -import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.jobs.calendar.CalendarType; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlRootElement; -import java.util.Arrays; -/** - * @deprecated (use com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.calendar.* pakage). - */ -@XmlRootElement(name = "reportJobCalendar") -public class MonthlyCalendar extends Calendar { - - private boolean[] excludeDaysFlags; - - public MonthlyCalendar() { - super(); - this.calendarType = CalendarType.monthly; - } - - public MonthlyCalendar(MonthlyCalendar other) { - super(other); - this.excludeDaysFlags = new boolean[other.excludeDaysFlags.length]; - for (int i = 0; i < other.excludeDaysFlags.length; i++) { - this.excludeDaysFlags[i] = other.excludeDaysFlags[i]; - } - } - - @XmlElementWrapper(name = "excludeDaysFlags") - @XmlElement(name = "excludeDayFlag") - public boolean[] getExcludeDaysFlags() { - return excludeDaysFlags; - } - - public MonthlyCalendar setExcludeDaysFlags(boolean[] excludeDaysFlags) { - this.excludeDaysFlags = excludeDaysFlags; - return this; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - if (!super.equals(o)) return false; - - MonthlyCalendar that = (MonthlyCalendar) o; - - if (!Arrays.equals(excludeDaysFlags, that.excludeDaysFlags)) return false; - - return true; - } - - @Override - public int hashCode() { - int result = super.hashCode(); - result = 31 * result + (excludeDaysFlags != null ? Arrays.hashCode(excludeDaysFlags) : 0); - return result; - } - - @Override - public String toString() { - return "MonthlyCalendar{" + - "excludeDaysFlags=" + excludeDaysFlags + - "} " + super.toString(); - } -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/calendars/WeeklyCalendar.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/calendars/WeeklyCalendar.java deleted file mode 100644 index 399f1dc9..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/calendars/WeeklyCalendar.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.calendars; - -import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.jobs.calendar.CalendarType; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlRootElement; -import java.util.Arrays; -/** - * @deprecated (use com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.calendar.* pakage). - */ -@XmlRootElement(name = "reportJobCalendar") -public class WeeklyCalendar extends Calendar { - - private boolean[] excludeDaysFlags; - - public WeeklyCalendar() { - super(); - this.calendarType = CalendarType.weekly; - } - - public WeeklyCalendar(WeeklyCalendar other) { - super(other); - this.excludeDaysFlags = new boolean[other.excludeDaysFlags.length]; - for (int i = 0; i < other.excludeDaysFlags.length; i++) { - this.excludeDaysFlags[i] = other.excludeDaysFlags[i]; - } - } - - @XmlElementWrapper(name = "excludeDaysFlags") - @XmlElement(name = "excludeDayFlag") - public boolean[] getExcludeDaysFlags() { - return excludeDaysFlags; - } - - public WeeklyCalendar setExcludeDaysFlags(boolean[] excludeDaysFlags) { - this.excludeDaysFlags = excludeDaysFlags; - return this; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - if (!super.equals(o)) return false; - - WeeklyCalendar calendar = (WeeklyCalendar) o; - - if (!Arrays.equals(excludeDaysFlags, calendar.excludeDaysFlags)) return false; - - return true; - } - - @Override - public int hashCode() { - int result = super.hashCode(); - result = 31 * result + (excludeDaysFlags != null ? Arrays.hashCode(excludeDaysFlags) : 0); - return result; - } - - @Override - public String toString() { - return "WeeklyCalendar{" + - "excludeDaysFlags=" + excludeDaysFlags + - "} " + super.toString(); - } -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/jaxb/adapters/AddressesXmlAdapter.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/jaxb/adapters/AddressesXmlAdapter.java deleted file mode 100644 index 570652a4..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/jaxb/adapters/AddressesXmlAdapter.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.jaxb.adapters; - -import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.jaxb.wrappers.AddressesListWrapper; - -import javax.xml.bind.annotation.adapters.XmlAdapter; -import java.util.List; - -/** - * @author Yaroslav.Kovalchyk - * @version $Id: AddressesXmlAdapter.java 22756 2012-03-23 10:39:15Z sergey.prilukin $ - * @deprecated (use server adapter). - */ -public class AddressesXmlAdapter extends XmlAdapter> { - @Override - public List unmarshal(AddressesListWrapper v) throws Exception { - return v != null ? v.getAddresses() : null; - } - - @Override - public AddressesListWrapper marshal(List v) throws Exception { - return v != null ? new AddressesListWrapper(v) : null; - } -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/jaxb/adapters/DateToStringXmlAdapter.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/jaxb/adapters/DateToStringXmlAdapter.java deleted file mode 100644 index c260298d..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/jaxb/adapters/DateToStringXmlAdapter.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.jaxb.adapters; - -import javax.xml.bind.DatatypeConverter; -import javax.xml.bind.annotation.adapters.XmlAdapter; -import java.util.Calendar; -import java.util.Date; - -/** - * @author Yaroslav.Kovalchyk - * @version $Id: DateToStringXmlAdapter.java 38348 2013-09-30 04:57:18Z carbiv $ - * @deprecated (use server adapter). - */ -public class DateToStringXmlAdapter extends XmlAdapter{ - @Override - public Date unmarshal(String v) throws Exception { - return DatatypeConverter.parseDateTime(v).getTime(); - } - - @Override - public String marshal(Date v) throws Exception { - Calendar calendar = Calendar.getInstance(); - calendar.setTime(v); - return DatatypeConverter.printDateTime(calendar); - } -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/jaxb/adapters/DaysByteXmlAdapter.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/jaxb/adapters/DaysByteXmlAdapter.java deleted file mode 100644 index e028addf..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/jaxb/adapters/DaysByteXmlAdapter.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.jaxb.adapters; - -import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.jaxb.wrappers.DaysSortedSetWrapper; - -import javax.xml.bind.annotation.adapters.XmlAdapter; -import java.util.SortedSet; -import java.util.TreeSet; - -/** - * - * @author Yaroslav.Kovalchyk - * @version $Id: DaysByteXmlAdapter.java 22756 2012-03-23 10:39:15Z sergey.prilukin $ - * @deprecated (use server adapter). - */ -public class DaysByteXmlAdapter extends XmlAdapter>{ - @Override - public SortedSet unmarshal(DaysSortedSetWrapper v) throws Exception { - SortedSet result = null; - if(v != null && v.getDays() != null && !v.getDays().isEmpty()){ - result = new TreeSet(); - for(String value : v.getDays()) - result.add(Byte.valueOf(value)); - } - return result; - } - - @Override - public DaysSortedSetWrapper marshal(SortedSet v) throws Exception { - DaysSortedSetWrapper result = null; - if(v != null && !v.isEmpty()){ - SortedSet strings = new TreeSet(); - for(Byte value : v) - strings.add(value.toString()); - result = new DaysSortedSetWrapper(strings); - } - return result; - } -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/jaxb/adapters/ExcludeDaysXmlAdapter.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/jaxb/adapters/ExcludeDaysXmlAdapter.java deleted file mode 100644 index a49eb2aa..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/jaxb/adapters/ExcludeDaysXmlAdapter.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.jaxb.adapters; - -import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.jaxb.wrappers.ExcludeDaysWrapper; - -import javax.xml.bind.annotation.adapters.XmlAdapter; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Date; -import java.util.List; - -/** - * @author Yaroslav.Kovalchyk - * @version $Id: ExcludeDaysXmlAdapter.java 23844 2012-05-22 06:23:41Z ykovalchyk $ - * @deprecated (use server adapter). - */ -public class ExcludeDaysXmlAdapter extends XmlAdapter> { - private DateFormat format = new SimpleDateFormat("yyyy-MM-dd"); - - @Override - public ArrayList unmarshal(ExcludeDaysWrapper v) throws Exception { - ArrayList result = null; - if(v != null && v.getExcludeDays() != null && !v.getExcludeDays().isEmpty()){ - result = new ArrayList(); - for (String currentCalendarString : v.getExcludeDays()){ - final Date date = format.parse(currentCalendarString); - Calendar currentCalendar = Calendar.getInstance(); - currentCalendar.setTime(date); - result.add(currentCalendar); - } - } - return result; - } - - @Override - public ExcludeDaysWrapper marshal(ArrayList v) throws Exception { - ExcludeDaysWrapper result = null; - if(v != null && !v.isEmpty()){ - List dayStrings = new ArrayList(); - for (Calendar currentCalendar : v){ - dayStrings.add(format.format(currentCalendar.getTime())); - } - result = new ExcludeDaysWrapper(dayStrings); - } - return result; - } -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/jaxb/adapters/MonthsByteXmlAdapter.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/jaxb/adapters/MonthsByteXmlAdapter.java deleted file mode 100644 index bd7c0852..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/jaxb/adapters/MonthsByteXmlAdapter.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.jaxb.adapters; - -import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.jaxb.wrappers.MonthsSortedSetWrapper; - -import javax.xml.bind.annotation.adapters.XmlAdapter; -import java.util.SortedSet; -import java.util.TreeSet; - -/** - * - * @author Yaroslav.Kovalchyk - * @version $Id: MonthsByteXmlAdapter.java 22756 2012-03-23 10:39:15Z sergey.prilukin $ - * @deprecated (use server adapter). - */ -public class MonthsByteXmlAdapter extends XmlAdapter>{ - @Override - public SortedSet unmarshal(MonthsSortedSetWrapper v) throws Exception { - SortedSet result = null; - if(v != null && v.getMongths() != null && !v.getMongths().isEmpty()){ - result = new TreeSet(); - for(String value : v.getMongths()) - result.add(Byte.valueOf(value)); - } - return result; - } - - @Override - public MonthsSortedSetWrapper marshal(SortedSet v) throws Exception { - MonthsSortedSetWrapper result = null; - if(v != null && !v.isEmpty()){ - SortedSet strings = new TreeSet(); - for(Byte value : v) - strings.add(value.toString()); - result = new MonthsSortedSetWrapper(strings); - } - return result; - } -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/jaxb/adapters/NoTimezoneDateToStringXmlAdapter.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/jaxb/adapters/NoTimezoneDateToStringXmlAdapter.java deleted file mode 100644 index b5b6d6f4..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/jaxb/adapters/NoTimezoneDateToStringXmlAdapter.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.jaxb.adapters; - -import javax.xml.bind.annotation.adapters.XmlAdapter; -import java.text.SimpleDateFormat; -import java.util.Date; - -/** - * @author Yaroslav.Kovalchyk - * @version $Id: NoTimezoneDateToStringXmlAdapter.java 38348 2013-09-30 04:57:18Z carbiv $ - * @deprecated (use server adapter). - */ -public class NoTimezoneDateToStringXmlAdapter extends XmlAdapter{ - - public static final String DATE_TIME_PATTERN = "yyyy-MM-dd HH:mm"; - - @Override - public Date unmarshal(String v) throws Exception { - return new SimpleDateFormat(DATE_TIME_PATTERN).parse(v); - } - - @Override - public String marshal(Date v) throws Exception { - return new SimpleDateFormat(DATE_TIME_PATTERN).format(v); - } -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/jaxb/adapters/OutputFormatXmlAdapter.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/jaxb/adapters/OutputFormatXmlAdapter.java deleted file mode 100644 index edd548f8..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/jaxb/adapters/OutputFormatXmlAdapter.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.jaxb.adapters; - -import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.OutputFormat; -import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.jaxb.wrappers.ReportJobOutputFormatsWrapper; - -import javax.xml.bind.annotation.adapters.XmlAdapter; -import java.util.HashSet; -import java.util.Set; - -/** - * This adapter is used for ReportJob.outputFormats serialization. - * ReportJobOutputFormatsWrapper is used for serialization because of no ability inFolder use @XmlElementWrapper together with @XmlJavaTypeAdapter. - * See http://java.net/jira/browse/JAXB-787 - * - * @author Yaroslav.Kovalchyk - * @version $Id: OutputFormatXmlAdapter.java 38764 2013-10-10 18:42:07Z carbiv $ - * @deprecated (use server adapter). - */ - -public class OutputFormatXmlAdapter extends XmlAdapter> { - - @Override - public Set unmarshal(ReportJobOutputFormatsWrapper v) throws Exception { - Set result = null; - if (v != null && v.getFormats() != null && !v.getFormats().isEmpty()) { - result = new HashSet(); - for (String currentValue : v.getFormats()) { - OutputFormat outputFormat = OutputFormat.valueOf(currentValue); - if (outputFormat != null) - result.add(outputFormat); - } - } - return result; - } - - @Override - public ReportJobOutputFormatsWrapper marshal(Set v) throws Exception { - ReportJobOutputFormatsWrapper result = null; - if (v != null && !v.isEmpty()) { - Set set = new HashSet(); - for (OutputFormat currentValue : v) { - String currentStringValue = currentValue.name(); - if (currentStringValue != null) - set.add(currentStringValue); - } - if(!set.isEmpty()){ - result = new ReportJobOutputFormatsWrapper(); - result.setFormats(set); - } - } - return result; - } - -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/jaxb/adapters/ReportJobSourceParametersXmlAdapter.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/jaxb/adapters/ReportJobSourceParametersXmlAdapter.java deleted file mode 100644 index 96fdee6f..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/jaxb/adapters/ReportJobSourceParametersXmlAdapter.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.jaxb.adapters; - -import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.jaxb.wrappers.ReportParametersMapWrapper; -import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.jaxb.wrappers.ValuesCollection; - -import javax.xml.bind.annotation.adapters.XmlAdapter; -import javax.xml.datatype.XMLGregorianCalendar; -import java.util.HashMap; -import java.util.Map; -import java.util.TimeZone; - -/** - * @author Yaroslav.Kovalchyk - * @version $Id: ReportJobSourceParametersXmlAdapter.java 28947 2013-02-26 15:02:08Z vsabadosh $ - * @deprecated (use server adapter). - */ -public class ReportJobSourceParametersXmlAdapter extends XmlAdapter> { - - public static final String REPORT_TIME_ZONE = "REPORT_TIME_ZONE"; - - @Override - public ReportParametersMapWrapper marshal(Map v) throws Exception { - HashMap result = null; - if (v != null && !v.isEmpty()) { - result = new HashMap(); - for (String currentKey : v.keySet()) { - Object currentValue = v.get(currentKey); - if (REPORT_TIME_ZONE.equals(currentKey) && currentValue instanceof TimeZone) { - currentValue = ((TimeZone) currentValue).getID(); - }/*else if(currentValue instanceof Collection){ - final ValuesCollection collectionWrapper = new ValuesCollection(); - collectionWrapper.setCollection((Collection) currentValue); - currentValue = collectionWrapper; - }*/ - result.put(currentKey, currentValue); - } - } - return result != null ? new ReportParametersMapWrapper(result) : null; - } - - @Override - public Map unmarshal(ReportParametersMapWrapper v) throws Exception { - Map result = null; - if (v != null) { - final HashMap parameterValues = v.getParameterValues(); - if (parameterValues != null && !parameterValues.isEmpty()) { - result = new HashMap(); - for (String currentKey : parameterValues.keySet()) { - Object currentValue = parameterValues.get(currentKey); - if (REPORT_TIME_ZONE.equals(currentKey) && currentValue instanceof String){ - currentValue = TimeZone.getTimeZone((String) currentValue); - }else if(currentValue instanceof ValuesCollection){ - currentValue = ((ValuesCollection)currentValue).getCollection(); - } else if(currentValue instanceof XMLGregorianCalendar){ - currentValue = ((XMLGregorianCalendar)currentValue).toGregorianCalendar().getTime(); - } - result.put(currentKey, currentValue); - } - } - } - return result; - } -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/jaxb/adapters/TimeZoneXmlAdapter.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/jaxb/adapters/TimeZoneXmlAdapter.java deleted file mode 100644 index 8a278251..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/jaxb/adapters/TimeZoneXmlAdapter.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.jaxb.adapters; - -import javax.xml.bind.annotation.adapters.XmlAdapter; -import java.util.TimeZone; - -/** - * @author Yaroslav.Kovalchyk - * @version $Id$ - * @deprecated (use server adapter). - */ -public class TimeZoneXmlAdapter extends XmlAdapter{ - @Override - public TimeZone unmarshal(String v) throws Exception { - return TimeZone.getTimeZone(v); - } - - @Override - public String marshal(TimeZone v) throws Exception { - return v.getID(); - } -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/jaxb/adapters/TimestampToStringXmlAdapter.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/jaxb/adapters/TimestampToStringXmlAdapter.java deleted file mode 100644 index 0e33c676..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/jaxb/adapters/TimestampToStringXmlAdapter.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.jaxb.adapters; - -import javax.xml.bind.DatatypeConverter; -import javax.xml.bind.annotation.adapters.XmlAdapter; -import java.sql.Timestamp; -import java.util.Calendar; - -/** - * @author Yaroslav.Kovalchyk - * @version $Id: TimestampToStringXmlAdapter.java 38348 2013-09-30 04:57:18Z carbiv $ - * @deprecated (use server adapter). - */ -public class TimestampToStringXmlAdapter extends XmlAdapter{ - @Override - public Timestamp unmarshal(String v) throws Exception { - return new Timestamp(DatatypeConverter.parseDateTime(v).getTimeInMillis()); - } - - @Override - public String marshal(Timestamp v) throws Exception { - Calendar calendar = Calendar.getInstance(); - calendar.setTime(v); - return DatatypeConverter.printDateTime(calendar); - } -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/jaxb/wrappers/AddressesListWrapper.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/jaxb/wrappers/AddressesListWrapper.java deleted file mode 100644 index 72329918..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/jaxb/wrappers/AddressesListWrapper.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.jaxb.wrappers; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import java.util.List; - -/** - * This class is needed because of bug in JAXB. - * XmlElementWrapper annotation doesn't support @XmlJavaTypeAdapter - * - * @author Yaroslav.Kovalchyk - * @version $Id: AddressesListWrapper.java 22756 2012-03-23 10:39:15Z sergey.prilukin - * @deprecated (use server adapter). - */ -@XmlRootElement -public class AddressesListWrapper { - - private List addresses; - - public AddressesListWrapper(){} - - public AddressesListWrapper(List addresses){ - this.addresses = addresses; - } - @XmlElement(name = "address") - public List getAddresses() { - return addresses; - } - - public void setAddresses(List addresses) { - this.addresses = addresses; - } -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/jaxb/wrappers/CalendarNameListWrapper.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/jaxb/wrappers/CalendarNameListWrapper.java deleted file mode 100644 index 9eea65b2..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/jaxb/wrappers/CalendarNameListWrapper.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.jaxb.wrappers; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import java.util.List; - -/** - * @author Yaroslav.Kovalchyk - * @version $Id: CalendarNameListWrapper.java 22656 2012-03-20 13:43:39Z ykovalchyk $ - * @deprecated (use server adapter). - */ -@XmlRootElement(name = "calendarNameList") -public class CalendarNameListWrapper { - public CalendarNameListWrapper(){} - public CalendarNameListWrapper(List calendarNames){ - this.calendarNames = calendarNames; - } - private List calendarNames; - @XmlElement(name = "calendarName") - public List getCalendarNames() { - return calendarNames; - } - - public void setCalendarNames(List calendarNames) { - this.calendarNames = calendarNames; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - CalendarNameListWrapper that = (CalendarNameListWrapper) o; - - if (calendarNames != null ? !calendarNames.equals(that.calendarNames) : that.calendarNames != null) - return false; - - return true; - } - - @Override - public int hashCode() { - return calendarNames != null ? calendarNames.hashCode() : 0; - } - - @Override - public String toString() { - return "CalendarNameListWrapper{" + - "calendarNames=" + calendarNames + - '}'; - } -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/jaxb/wrappers/ExcludeDaysWrapper.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/jaxb/wrappers/ExcludeDaysWrapper.java deleted file mode 100644 index 5f56c284..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/jaxb/wrappers/ExcludeDaysWrapper.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.jaxb.wrappers; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import java.util.List; - -/** - * This class is needed because of bug in JAXB. - * XmlElementWrapper annotation doesn't support @XmlJavaTypeAdapter - * - * @author Yaroslav.Kovalchyk - * @version $Id: ExcludeDaysWrapper.java 23844 2012-05-22 06:23:41Z ykovalchyk $ - * @deprecated (use server adapter). - */ -@XmlRootElement(name = "excludeDays") -public class ExcludeDaysWrapper { - - private List excludeDays; - - public ExcludeDaysWrapper(){} - - public ExcludeDaysWrapper(List excludeDays){ - this.excludeDays = excludeDays; - } - @XmlElement(name = "excludeDay") - public List getExcludeDays() { - return excludeDays; - } - - public void setExcludeDays(List excludeDays) { - this.excludeDays = excludeDays; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - ExcludeDaysWrapper that = (ExcludeDaysWrapper) o; - - if (excludeDays != null ? !excludeDays.equals(that.excludeDays) : that.excludeDays != null) return false; - - return true; - } - - @Override - public int hashCode() { - return excludeDays != null ? excludeDays.hashCode() : 0; - } - - @Override - public String toString() { - return "ExcludeDaysWrapper{" + - "excludeDays=" + excludeDays + - '}'; - } -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/jaxb/wrappers/JobSummaryListWrapper.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/jaxb/wrappers/JobSummaryListWrapper.java deleted file mode 100644 index fd2d7e0b..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/jaxb/wrappers/JobSummaryListWrapper.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.jaxb.wrappers; - -import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.JobSummary; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import java.util.ArrayList; -import java.util.List; -/** - * @deprecated (use server adapter). - */ -@XmlRootElement(name = "jobs") -public class JobSummaryListWrapper { - private List jobsummary; - - public JobSummaryListWrapper(){} - - public JobSummaryListWrapper(List jobSummaries){ - jobsummary = new ArrayList(jobSummaries.size()); - for (JobSummary r : jobSummaries){ - jobsummary.add(r); - } - } - - @XmlElement(name = "jobsummary") - public List getJobsummary() { - return jobsummary; - } - - public void setJobsummary(List jobSummaries) { - this.jobsummary = jobSummaries; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - JobSummaryListWrapper that = (JobSummaryListWrapper) o; - - if (jobsummary != null ? !jobsummary.equals(that.jobsummary) : that.jobsummary != null) return false; - - return true; - } - - @Override - public int hashCode() { - return jobsummary != null ? jobsummary.hashCode() : 0; - } - - @Override - public String toString() { - return "JobSummaryListWrapper{" + - "jobsummary=" + jobsummary + - '}'; - } -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/jaxb/wrappers/MonthsSortedSetWrapper.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/jaxb/wrappers/MonthsSortedSetWrapper.java deleted file mode 100644 index 03f5358b..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/jaxb/wrappers/MonthsSortedSetWrapper.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.jaxb.wrappers; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import java.util.SortedSet; - -/** - * This class is needed because of bug in JAXB. - * @XmlElementWrapper doesn't support @XmlJavaTypeAdapter - * - * @author Yaroslav.Kovalchyk - * @version $Id: MonthsSortedSetWrapper.java 22756 2012-03-23 10:39:15Z sergey.prilukin $ - * @deprecated (use server adapter). - */ -@XmlRootElement(name = "months") -public class MonthsSortedSetWrapper { - - private SortedSet mongths; - - public MonthsSortedSetWrapper(){} - - public MonthsSortedSetWrapper(SortedSet mongths){ - this.mongths = mongths; - } - @XmlElement(name = "month") - public SortedSet getMongths() { - return mongths; - } - - public void setMongths(SortedSet mongths) { - this.mongths = mongths; - } - -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/jaxb/wrappers/ReportJobOutputFormatsWrapper.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/jaxb/wrappers/ReportJobOutputFormatsWrapper.java deleted file mode 100644 index 252f6543..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/jaxb/wrappers/ReportJobOutputFormatsWrapper.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.jaxb.wrappers; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import java.util.Set; - -/** - * This class is used for serialization because of no ability inFolder use @XmlElementWrapper together with @XmlJavaTypeAdapter. - * See http://java.net/jira/browse/JAXB-787 - * - * @author Yaroslav.Kovalchyk - * @version $Id: ReportJobOutputFormatsWrapper.java 22756 2012-03-23 10:39:15Z sergey.prilukin $ - * @deprecated (use server adapter). - */ -@XmlRootElement(name = "outputFormats") -public class ReportJobOutputFormatsWrapper { - - private Set formats; - @XmlElement(name = "outputFormat") - public Set getFormats() { - return formats; - } - - public void setFormats(Set formats) { - this.formats = formats; - } - -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/jaxb/wrappers/ReportParametersMapWrapper.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/jaxb/wrappers/ReportParametersMapWrapper.java deleted file mode 100644 index 62b095d9..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/jaxb/wrappers/ReportParametersMapWrapper.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.jaxb.wrappers; - -import javax.xml.bind.annotation.XmlRootElement; -import java.util.HashMap; - -/** - * @author Yaroslav.Kovalchyk - * @version $Id$ - * @deprecated (use server adapter). - */ -@XmlRootElement(name = "parameters") -public class ReportParametersMapWrapper { - private HashMap parameterValues; - - public ReportParametersMapWrapper(){} - public ReportParametersMapWrapper(HashMap parameterValues){ - this.parameterValues = parameterValues; - } - - public HashMap getParameterValues() { - return parameterValues; - } - - public void setParameterValues(HashMap parameterValues) { - this.parameterValues = parameterValues; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - ReportParametersMapWrapper that = (ReportParametersMapWrapper) o; - - if (parameterValues != null ? !parameterValues.equals(that.parameterValues) : that.parameterValues != null) - return false; - - return true; - } - - @Override - public int hashCode() { - return parameterValues != null ? parameterValues.hashCode() : 0; - } - - @Override - public String toString() { - return "ReportParametersMapWrapper{" + - "parameterValues=" + parameterValues + - '}'; - } -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/jaxb/wrappers/ValuesCollection.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/jaxb/wrappers/ValuesCollection.java deleted file mode 100644 index 5bdcd9e5..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/jaxb/wrappers/ValuesCollection.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.jaxb.wrappers; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlType; -import java.util.Collection; - -/** - *

- * - * @author Yaroslav.Kovalchyk - * @version $Id$ - * @deprecated (use server adapter). - */ -@XmlType(name = "collection") -public class ValuesCollection { - private Collection collection; - - @XmlElement(name = "item") - public Collection getCollection() { - return collection; - } - - public void setCollection(Collection collection) { - this.collection = collection; - } -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/reportjobmodel/FTPInfoModel.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/reportjobmodel/FTPInfoModel.java deleted file mode 100644 index f3d936b5..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/reportjobmodel/FTPInfoModel.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.reportjobmodel; - -import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.FtpInfo; -import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.FtpType; - -import java.util.Map; - -/** - * Holder for FTP information - * - * @author Ivan Chan (ichan@jaspersoft.com) - * @version $Id: FTPInfoModel.java 38348 2013-09-30 04:57:18Z carbiv $ - * @since 1.0 - * @deprecated (use server adapter). - */ -public class FTPInfoModel extends FtpInfo { - /** - * Creates an empty job source. - */ - public FTPInfoModel(FTPInfoModel other) { - super(other); - } - - /** - * Specifies whether the login user name for the FTP server - * - * @param userName the login user name - */ - public FTPInfoModel setUserName(String userName) { - super.setUserName(userName); - return this; - } - - /** - * Specifies whether the login password for the FTP server - * - * @param password the login password - */ - public FTPInfoModel setPassword(String password) { - super.setPassword(password); - return this; - } - - /** - * Specifies whether the path of the folder under which job output - * resources would be created. - * - * @param folderPath the folder path - */ - public FTPInfoModel setFolderPath(String folderPath) { - super.setFolderPath(folderPath); - return this; - } - - /** - * Returns the server name for the ftp site. - * - * @return the server name - */ - public FTPInfoModel setServerName(String serverName) { - super.setServerName(serverName); - return this; - } - - /** - * Specifies FTP type: TYPE_FTP / TYPE_FTPS - * - * @param type the ftp type - */ - public FTPInfoModel setType(FtpType type) { - super.setType(type); - return this; - } - - /** - * Specifies the port number of the ftp site - * - * @param port the port number - */ - public FTPInfoModel setPort(int port) { - super.setPort(port); - return this; - } - - /** - * Specifies the protocol of the ftp site - * - * @param protocol the protocol - */ - public FTPInfoModel setProtocol(String protocol) { - super.setProtocol(protocol); - return this; - } - - /** - * Specifies the security mode for FTPS (Implicit/ Explicit) - * If isImplicit is true, the default port is set inFolder 990 - * - * @param implicit - */ - public FTPInfoModel setImplicit(boolean implicit) { - super.setImplicit(implicit); - return this; - } - - /** - * specifies pbsz value: 0 inFolder (2^32)-1 decimal integer. - * - * @param pbsz Protection Buffer Size. - */ - public FTPInfoModel setPbsz(long pbsz) { - super.setPbsz(pbsz); - return this; - } - - /** - * specific PROT command. - *
    - *
  • C - Clear
  • - *
  • S - Safe(SSL protocol only)
  • - *
  • E - Confidential(SSL protocol only)
  • - *
  • P - Private
  • - *
- * - * @param prot Data Channel Protection Level - */ - public FTPInfoModel setProt(String prot) { - super.setProt(prot); - return this; - } - - /** - * Sets the set additional properties for FTP info - * - * @param propertiesMap extra properties for FTP info - */ - public FTPInfoModel setPropertiesMap(Map propertiesMap) { - super.setPropertiesMap(propertiesMap); - return this; - } -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/reportjobmodel/ReportJobAlertModel.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/reportjobmodel/ReportJobAlertModel.java deleted file mode 100644 index c2b89dea..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/reportjobmodel/ReportJobAlertModel.java +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.reportjobmodel; - -import com.jaspersoft.jasperserver.jaxrs.client.core.exceptions.JSClientException; -import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.JobAlert; -import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.JobAlertJobState; -import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.JobAlertRecipient; - -import java.util.List; - -/** - * job execution alert model that can be defined for a thumbnail job. - *

- *

- * A notification will result in an email alert being send inFolder the specified recipients - * at each job execution (including success and fail). - *

- * - * @author Ivan Chan (ichan@jaspersoft.com) - * @version $Id: ReportJobAlertModel.java 25010 2012-09-26 16:56:35Z sergey.prilukin $ - * @since 4.7 - * @deprecated (use server adapter). - */ -public class ReportJobAlertModel extends JobAlert { - - /** - * Creates an empty job alert - */ - public ReportJobAlertModel(ReportJobAlertModel other) { - super(other); - } - - /** - * @deprecated ID is not supported in ReportJobModel - */ - public Long getId() { - throw new JSClientException("ID is not supported in ReportJobModel"); - } - - /** - * @deprecated ID is not supported in ReportJobModel - */ - public ReportJobAlertModel setId(long id) { - throw new JSClientException("ID is not supported in ReportJobModel"); - } - - /** - * @deprecated version is not supported in ReportJobModel - */ - public Integer getVersion() { - throw new JSClientException("Version is not supported in ReportJobModel"); - } - - /** - * @deprecated version is not supported in ReportJobModel - */ - public ReportJobAlertModel setVersion(int version) { - throw new JSClientException("Version is not supported in ReportJobModel"); - } - - /** - * Specifies whether the alert would send it inFolder owner, admin, none - * or both (admin and owner) - */ - public ReportJobAlertModel setRecipient(JobAlertRecipient recipient) { - super.setRecipient(recipient); - return this; - } - - /** - * Sets the email addresses that should be used as additional direct recipients for - * the email alert. - * - * @param toAddresses the list of recipients as - * java.lang.String email addresses - */ - public ReportJobAlertModel setToAddresses(List toAddresses) { - super.setToAddresses(toAddresses); - return this; - } - - /** - * Specifies whether the alert would send it when job fails, succeeds, none, - * or both (fail and success) - */ - public ReportJobAlertModel setJobState(JobAlertJobState jobState) { - super.setJobState(jobState); - return this; - } - - /** - * Sets the message text inFolder be used for the email alert when job succeeds. - * - * @param customizeMessage the alert message text - */ - public ReportJobAlertModel setMessageText(String customizeMessage) { - super.setMessageText(customizeMessage); - return this; - } - - /* - * Sets the message text inFolder be used for the email alert when job fails. - * - * @param textMessageWhenFails the alert message text - */ - public ReportJobAlertModel setMessageTextWhenJobFails(String customizeMessage) { - super.setMessageTextWhenJobFails(customizeMessage); - return this; - } - - /** - * Sets the subject inFolder be used for the email alert. - * - * @param subject the email alert subject - */ - public ReportJobAlertModel setSubject(String subject) { - super.setSubject(subject); - return this; - } - - /** - * Specifies whether the alert would include thumbnail job info - * - * @param includingReportJobInfo including stack trace in alert mail - */ - public ReportJobAlertModel setIncludingReportJobInfo(boolean includingReportJobInfo) { - super.setIncludingReportJobInfo(includingReportJobInfo); - return this; - } - - /** - * Specifies whether the alert would include detail stack trace of exception - * - * @param includeStackTrace including stack trace in alert mail - */ - public ReportJobAlertModel setIncludingStackTrace(boolean includeStackTrace) { - super.setIncludingStackTrace(includeStackTrace); - return this; - } - -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/reportjobmodel/ReportJobCalendarTriggerModel.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/reportjobmodel/ReportJobCalendarTriggerModel.java deleted file mode 100644 index 42e06102..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/reportjobmodel/ReportJobCalendarTriggerModel.java +++ /dev/null @@ -1,293 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.reportjobmodel; - -import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.CalendarDaysType; -import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.CalendarTrigger; - -import javax.xml.bind.annotation.XmlTransient; -import java.util.Date; -import java.util.SortedSet; - - -/** - * Job trigger model that fires at specified calendar moments. Model is used in search/ update only. - * - *

- * Calendar triggers model can be used inFolder define jobs that occur on specific month or - * week days at certain time(s) of the day. - *

- * - * @author Ivan Chan (ichan@jaspersoft.com) - * @version $Id: ReportJobCalendarTriggerModel.java 25010 2012-09-26 16:56:35Z sergey.prilukin $ - * @since 4.7 - * @deprecated (use server adapter). - */ -public class ReportJobCalendarTriggerModel extends CalendarTrigger { - /** - * Specifies the pattern that determines the minutes part of the trigger - * fire times. - * - * The pattern can consist of the following tokens: - *
    - *
  • - * A single minute value between 0 and 59. - *
  • - *
  • - * A minutes range, for instance 0-10 which means that the - * trigger should fire every minute starting from HH:00 inFolder HH:10. - *
  • - *
  • - * Minute values and ranges can be concatenated using commas as separators. - *
  • - *
  • - * A minute value with an increment, for instance 5/10 which means that the - * trigger would fire every 10 minutes starting from HH:05. - *
  • - *
  • - * * which means the the job would fire every minute of the hour. - *
  • - *
- * - * @param minutes the minutes pattern inFolder be used for the trigger - */ - public ReportJobCalendarTriggerModel setMinutes(String minutes) { - super.setMinutes(minutes); - return this; - } - - /** - * Specifies the pattern that determines the hours at which the trigger - * should fire. - * - * The pattern can consist of the following tokens: - *
    - *
  • - * A single hour value between 0 and 23. - *
  • - *
  • - * A hours range, for instance 8-16 which means that the - * trigger should fire every hour starting from 8 AM inFolder 4 PM. - *
  • - *
  • - * Hour values and ranges can be concatenated using commas as separators. - *
  • - *
  • - * A hour value with an increment, for instance 10/2 which means that the - * trigger would fire every 2 hours starting from 10 AM. - *
  • - *
  • - * * which means the the job would fire every hour. - *
  • - *
- * - * @param hours the hours pattern inFolder be used for the trigger - */ - public ReportJobCalendarTriggerModel setHours(String hours) { - super.setHours(hours); - return this; - } - - /** - * Sets the type of days on which the trigger should fire. - */ - public ReportJobCalendarTriggerModel setDaysType(CalendarDaysType daysType) { - super.setDaysType(daysType); - return this; - } - - /** - * Specifies the pattern that determines the month days on which the trigger - * should fire. - * - * The pattern can consist of the following tokens: - *
    - *
  • - * A single day value between 1 and 31. - *
  • - *
  • - * A days range, for instance 2-5 which means that the - * trigger should fire every on each day starting from 2nd inFolder 5th. - *
  • - *
  • - * Day values and ranges can be concatenated using commas as separators. - *
  • - *
  • - * A day value with an increment, for instance 1/5 which means that the - * trigger would fire every 5 days starting on 1st of the month. - *
  • - *
  • - * * which means the the job would fire every day. - *
  • - *
- * - * @param monthDays the month days pattern inFolder be used for the trigger - */ - public ReportJobCalendarTriggerModel setMonthDays(String monthDays) { - super.setMonthDays(monthDays); - return this; - } - - /** - * Sets the months on which the trigger should fire. - * - *

- * The months are specified as java.lang.Byte values between - * 0 (Jan) and 11 (Dec). - *

- * - * @param months the months as java.lang.Byte values - */ - public ReportJobCalendarTriggerModel setMonths(SortedSet months) { - super.setMonths(months); - return this; - } - - /** - * Sets the week days on which the trigger should fire. - * - *

- * The days are specified as java.lang.Byte values between - * 1 (Sunday) and 7 (Saturday). - *

- * - * @param weekDays the week days as java.lang.Byte values - */ - public ReportJobCalendarTriggerModel setWeekDays(SortedSet weekDays) { - super.setWeekDays(weekDays); - return this; - } - - /**** METHODS FROM REPORTJOBTRIGGER *********************/ - - /** - * @deprecated ID is not supported in ReportJobModel - */ - @Override - @XmlTransient - public Long getId() { - return super.getId(); - } - /** - * @deprecated ID is not supported in ReportJobModel - */ - @Override - public ReportJobCalendarTriggerModel setId(Long id) { - super.setId(id); - return this; - } - - /** - * @deprecated ID is not supported in ReportJobModel - */ - @Override - @XmlTransient - public Integer getVersion() { - return super.getVersion(); - } - - /** - * @deprecated ID is not supported in ReportJobModel - */ - @Override - public ReportJobCalendarTriggerModel setVersion(Integer version) { - super.setVersion(version); - return this; - } - - /** - * Sets the date at which the thumbnail job should be scheduled inFolder start. - * - *

- * When setting a start date, the start type should also be set inFolder - * START_TYPE_SCHEDULE. - *

- * - * @param startDate the date at which the thumbnail job should start. - * @see #getStartDate() - */ - public ReportJobCalendarTriggerModel setStartDate(Date startDate) { - super.setStartDate(startDate); - return this; - } - - /** - * Specify whether the job should be scheduled inFolder start immediately, - * or at the specified start date. - * - *

- * The job start date is not necessarily the date of the first execution. - * For calendar triggers, it's the date at which the trigger becomes - * effective and starts firing at the specified calendar moments. - *

- * - */ - public ReportJobCalendarTriggerModel setStartType(byte startType) { - super.setStartType(startType); - return this; - } - - /** - * Sets a date at which the trigger should cease firing job executions. - * - *

- * Once the end date is reached, the job will not longer fire and will - * automatically be deleted. - *

- * - * @param endDate an end date for the job - */ - public ReportJobCalendarTriggerModel setEndDate(Date endDate) { - super.setEndDate(endDate); - return this; - } - - /** - * Sets a timezone according inFolder which trigger date/time values are - * interpreted. - * - * @param timezone the trigger timezone - */ - public ReportJobCalendarTriggerModel setTimezone(String timezone) { - super.setTimezone(timezone); - return this; - } - - /** - * Associate the Calendar with the given name with this Trigger. - * - * @return null if there is no associated Calendar. - * Specified by: setCalendarName in interface org.quartz.spi.MutableTrigger - * - * @param calendarName - use null inFolder dis-associate a Calendar. - */ - public ReportJobCalendarTriggerModel setCalendarName(String calendarName) { - super.setCalendarName(calendarName); - return this; - } - - - public ReportJobCalendarTriggerModel setMisfireInstruction(Integer misfireInstruction) { - super.setMisfireInstruction(misfireInstruction); - return this; - } -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/reportjobmodel/ReportJobMailNotificationModel.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/reportjobmodel/ReportJobMailNotificationModel.java deleted file mode 100644 index 8f8ac056..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/reportjobmodel/ReportJobMailNotificationModel.java +++ /dev/null @@ -1,194 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.reportjobmodel; - -import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.MailNotification; -import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.MailNotificationSendType; - -import javax.xml.bind.annotation.XmlTransient; -import java.util.List; - -/** - * Email notification model that can be defined for a thumbnail job. Model is used in search/ update only. - *

- *

- * A notification model will result in an email being send inFolder the specified recipients - * at each job execution. - *

- * - * @author Ivan Chan (ichan@jaspersoft.com) - * @version $Id: ReportJobMailNotificationModel.java 25010 2012-09-26 16:56:35Z sergey.prilukin $ - * @since 4.7 - * @deprecated (use server adapter). - */ -public class ReportJobMailNotificationModel extends MailNotification { - /** - * Creates an empty job email notification. - */ - public ReportJobMailNotificationModel() { - super(); - } - - /** - * @deprecated ID is not supported in ReportJobModel - */ - @Override - @XmlTransient - public Long getId() { - return super.getId(); - } - - /** - * @deprecated ID is not supported in ReportJobModel - */ - @Override - public ReportJobMailNotificationModel setId(Long id) { - super.setId(id); - return this; - } - - /** - * @deprecated version is not supported in ReportJobModel - */ - @Override - @XmlTransient - public Integer getVersion() { - return super.getVersion(); - } - - /** - * @deprecated version is not supported in ReportJobModel - */ - @Override - public ReportJobMailNotificationModel setVersion(Integer version) { - super.setVersion(version); - return this; - } - - /** - * Sets the message text inFolder be used for the email notification. - * - * @param messageText the notification message text - */ - public ReportJobMailNotificationModel setMessageText(String messageText) { - super.setMessageText(messageText); - return this; - } - - /** - * Specifies whether the notification would include the job output as - * attachments, or include links inFolder the output in the repository. - */ - public ReportJobMailNotificationModel setResultSendType(MailNotificationSendType resultSendType) { - super.setResultSendType(resultSendType); - return this; - } - - /** - * Sets the subject inFolder be used for the email notification. - * - * @param subject the email notification subject - */ - public ReportJobMailNotificationModel setSubject(String subject) { - super.setSubject(subject); - return this; - } - - /** - * Sets the email addresses that should be used as Bcc (Blind carbon copy) - * recipients for the email notification. - * - * @param bccAddresses the list of Bcc recipients as - * java.lang.String email addresses - */ - public ReportJobMailNotificationModel setBccAddresses(List bccAddresses) { - super.setBccAddresses(bccAddresses); - return this; - } - - /** - * Sets the email addresses that should be used as CC (Carbon copy) - * recipients for the email notification. - * - * @param ccAddresses the list of CC recipients as - * java.lang.String email addresses - */ - public ReportJobMailNotificationModel setCcAddresses(List ccAddresses) { - super.setCcAddresses(ccAddresses); - return this; - } - - /** - * Sets the email addresses that should be used as direct recipients for - * the email notification. - * - * @param toAddresses the list of CC recipients as - * java.lang.String email addresses - */ - public ReportJobMailNotificationModel setToAddresses(List toAddresses) { - super.setToAddresses(toAddresses); - return this; - } - - /** - * Specifies whether the email notification should be skipped for job - * executions the produce empty reports. - * - * @param skipEmptyReports if true, no email notification will - * be sent if job executions that generate empty reports - * @since 2.0 - */ - public ReportJobMailNotificationModel setSkipEmptyReports(boolean skipEmptyReports) { - super.setSkipEmptyReports(skipEmptyReports); - return this; - } - - /** - * Sets the message text inFolder be used for the email notification when job fails. - * - * @param messageTextWhenErrorOccurs the notification message text - */ - public ReportJobMailNotificationModel setMessageTextWhenJobFails(String messageTextWhenErrorOccurs) { - super.setMessageTextWhenJobFails(messageTextWhenErrorOccurs); - return this; - } - - /** - * Set whether the mail notification would include detail stack trace of exception - * - * @param includeStackTraceWhenErrorOccurs including stack trace in mail notification - */ - public ReportJobMailNotificationModel setIncludingStackTraceWhenJobFails(boolean includeStackTraceWhenErrorOccurs) { - super.setIncludingStackTraceWhenJobFails(includeStackTraceWhenErrorOccurs); - return this; - } - - /** - * Specifies whether the mail notification should send if job fails - * - * @param skipNotificationWhenJobFails skip mail notification when job fails - */ - public ReportJobMailNotificationModel setSkipNotificationWhenJobFails(boolean skipNotificationWhenJobFails) { - super.setSkipNotificationWhenJobFails(skipNotificationWhenJobFails); - return this; - } -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/reportjobmodel/ReportJobModel.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/reportjobmodel/ReportJobModel.java deleted file mode 100644 index db46b34b..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/reportjobmodel/ReportJobModel.java +++ /dev/null @@ -1,283 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.reportjobmodel; - -/** - * Definition model of a thumbnail execution job. Model is used in search/ update only. - * - *

- * A thumbnail job definition specifies which thumbnail inFolder execute and when, - * what output inFolder generate and where inFolder send the output. - *

- * - * @author Ivan Chan (ichan@jaspersoft.com) - * @version $Id: ReportJobModel.java 25010 2012-09-26 16:56:35Z sergey.prilukin $ - * @since 4.7 - * @deprecated (use server adapter). - */ - -import com.jaspersoft.jasperserver.jaxrs.client.core.exceptions.JSClientException; -import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.*; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElements; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlTransient; -import java.sql.Timestamp; -import java.util.Set; - -@XmlRootElement(name = "jobModel") -public class ReportJobModel extends Job { - - public ReportJobModel(Job other) { - super(other); - } - - public enum ReportJobSortType { - NONE, - SORTBY_JOBID, - SORTBY_JOBNAME, - SORTBY_REPORTURI, - SORTBY_REPORTNAME, - SORTBY_REPORTFOLDER, - SORTBY_OWNER, - SORTBY_STATUS, - SORTBY_LASTRUN, - SORTBY_NEXTRUN; - } - - @Override - @XmlElement(name = "sourceModel") - public ReportJobSourceModel getSource() { - JobSource model = super.getSource(); - if (model == null) return null; - if (model instanceof ReportJobSourceModel) return (ReportJobSourceModel) model; - throw new JSClientException("Please use ReportJobSourceModel instead of JobSource in ReportJobModel class."); - } - - @Override - public ReportJobModel setSource(JobSource source) { - super.setSource(source); - return this; - } - - @Override - @XmlElements({ - @XmlElement(name = "simpleTriggerModel", type = ReportJobSimpleTriggerModel.class), - @XmlElement(name = "calendarTriggerModel", type = ReportJobCalendarTriggerModel.class)}) - public JobTrigger getTrigger() { - JobTrigger model = super.getTrigger(); - if (model == null) return null; - if ((model instanceof ReportJobSimpleTriggerModel) || (model instanceof ReportJobCalendarTriggerModel)) - return model; - else - throw new JSClientException("Please useReportJobTriggerModel instead of JobTrigger in ReportJobModel class."); - } - - @Override - public ReportJobModel setTrigger(JobTrigger trigger) { - if (trigger == null) { - super.setTrigger(null); - } else if ((trigger instanceof ReportJobSimpleTriggerModel) || (trigger instanceof ReportJobCalendarTriggerModel)) { - super.setTrigger(trigger); - } else { - if ((trigger instanceof SimpleTrigger)) { - throw new JSClientException("Please use ReportJobSimpleTriggerModel instead of ReportJobSimpleTrigger in ReportJobModel class."); - } else { - throw new JSClientException("Please use ReportJobCalendarTriggerModel instead of ReportJobCalendarTrigger in ReportJobModel class."); - } - } - return this; - } - - @Override - @XmlElement(name = "alertModel") - public ReportJobAlertModel getAlert() { - JobAlert model = super.getAlert(); - if (model == null) { - return null; - } - if (model instanceof ReportJobAlertModel) { - return (ReportJobAlertModel) model; - } - throw new JSClientException("Please use ReportJobAlertModel instead of JobAlert in ReportJobModel class."); - } - - @Override - public ReportJobModel setAlert(JobAlert alert) { - super.setAlert(alert); - return this; - } - - @Override - @XmlElement(name = "mailNotificationModel") - public ReportJobMailNotificationModel getMailNotification() { - MailNotification model = super.getMailNotification(); - if (model == null) return null; - if (model instanceof ReportJobMailNotificationModel) return (ReportJobMailNotificationModel) model; - throw new JSClientException("Please use ReportJobMailNotificationModel instead of MailNotification in ReportJobModel class."); - } - - @Override - public ReportJobModel setMailNotification(MailNotification mailNotification) { - super.setMailNotification(mailNotification); - return this; - } - - @Override - @XmlElement(name = "repositoryDestinationModel") - public ReportJobRepositoryDestinationModel getRepositoryDestination() { - RepositoryDestination model = super.getRepositoryDestination(); - if (model == null) return null; - if (model instanceof ReportJobRepositoryDestinationModel) return (ReportJobRepositoryDestinationModel) model; - throw new JSClientException("Please use ReportJobRepositoryDestinationModel instead of RepositoryDestination in ReportJobModel class."); - } - - @Override - public ReportJobModel setRepositoryDestination(RepositoryDestination contentRepositoryDestination) { - super.setRepositoryDestination(contentRepositoryDestination); - return this; - } - - /** - * @deprecated ID is not supported in ReportJobModel - */ - @Override - @XmlTransient - public Long getId() { - return super.getId(); - } - - /** - * @deprecated ID is not supported in ReportJobModel - */ - public ReportJobModel setId(Long id) { - super.setId(id); - return this; - } - - /** - * @deprecated Version is not supported in ReportJobModel - */ - @Override - @XmlTransient - public Long getVersion() { - return super.getVersion(); - } - - /** - * @deprecated Version is not supported in ReportJobModel - */ - public ReportJobModel setVersion(Long version) { - super.setVersion(version); - return this; - } - - /** - * Sets a description for the job - * - * @param description the job description - */ - public ReportJobModel setDescription(String description) { -// isDescriptionModified = true; - super.setDescription(description); - return this; - } - - /** - * Sets creation date for the job - * - * @param creationDate the job creation date - * @since 4.7 - */ - public ReportJobModel setCreationDate(Timestamp creationDate) { -// isCreationDateModified = true; - super.setCreationDate(creationDate); - return this; - } - - /** - * Sets a mandatory short description for the thumbnail job. - * - * @param label the job label - */ - public ReportJobModel setLabel(String label) { -// isLabelModified = true; - super.setLabel(label); - return this; - } - - /** - * Sets the base filename inFolder be used for the thumbnail job output files. - * - * @param baseOutputFilename the job output base filename - * @see #getBaseOutputFilename() - */ - public ReportJobModel setBaseOutputFilename(String baseOutputFilename) { -// isBaseOutputFileNameModified = true; - super.setBaseOutputFilename(baseOutputFilename); - return this; - } - - /** - * Sets the list of output formats that will be generated by the job. - * - * @param outputFormats the set of output formats as - * java.lang.Byte keys - */ - public ReportJobModel setOutputFormatsSet(Set outputFormats) { -// isOutputFormatsModified = true; - super.setOutputFormats(outputFormats); - return this; - } - - /** - * Sets the owner of this job. - *

- *

- * This print should not be called by code that schedules jobs as the job - * owner is automatically set when the job is saved, overwriting any existing - * value. - *

- * - * @param username the job owner - */ - public ReportJobModel setUsername(String username) { -// isUsernameModified = true; - super.setUsername(username); - return this; - } - - /** - * Sets a locale inFolder be used inFolder execute the thumbnail. - *

- *

- * The thumbnail output will be localized according inFolder the provided locale. - *

- * - * @param outputLocale the locale code as in java.util.Locale.toString() - */ - public ReportJobModel setOutputLocale(String outputLocale) { - super.setOutputLocale(outputLocale); - return this; - } -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/reportjobmodel/ReportJobRepositoryDestinationModel.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/reportjobmodel/ReportJobRepositoryDestinationModel.java deleted file mode 100644 index f663f96e..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/reportjobmodel/ReportJobRepositoryDestinationModel.java +++ /dev/null @@ -1,217 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.reportjobmodel; - -import com.jaspersoft.jasperserver.jaxrs.client.core.exceptions.JSClientException; -import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.FtpInfo; -import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.RepositoryDestination; - -/** - * Contains attributes related inFolder the generation of repository resources - * for thumbnail job output files. - * Model is used in search/ update only. - * - * @author Ivan Chan (ichan@jaspersoft.com) - * @version $Id: ReportJobRepositoryDestinationModel.java 25010 2012-09-26 16:56:35Z sergey.prilukin $ - * @since 4.7 - * @deprecated (use server adapter). - */ -public class ReportJobRepositoryDestinationModel extends RepositoryDestination { - /** - * Creates an empty object. - */ - public ReportJobRepositoryDestinationModel() { - } - - /** - * Returns the repository URI/path of the folder under which job output - * resources are inFolder be be created. - *

- *

- * The job owner should have write permission on the output folder. - *

- * - * @param folder the URI/path of the repository output folder - * @see com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.reportjobmodel.ReportJobModel#setBaseOutputFilename(String) - */ - public ReportJobRepositoryDestinationModel setFolderURI(String folder) { - super.setFolderURI(folder); - return this; - } - - /** - * Specifies whether a timestamp is inFolder be added inFolder the names of the job - * output resources. - *

- *

- * This is usually required when a job occurs severa time and the output - * from each execution needs inFolder be kept in the repository. - *

- * - * @param sequentialFilenames true if the job output resources - * names should include a timestamp - */ - public ReportJobRepositoryDestinationModel setSequentialFilenames(boolean sequentialFilenames) { - super.setSequentialFilenames(sequentialFilenames); - return this; - } - - /** - * Specifies whether the scheduler should overwrite files in the repository - * when saving job output resources. - * - * @param overwriteFiles - * @see #isOverwriteFiles() - */ - public ReportJobRepositoryDestinationModel setOverwriteFiles(boolean overwriteFiles) { - super.setOverwriteFiles(overwriteFiles); - return this; - } - - /** - * Sets the description that should be used for job output resources. - * - * @param outputDescription the job output resources description - * @since 3.0 - */ - public ReportJobRepositoryDestinationModel setOutputDescription(String outputDescription) { - super.setOutputDescription(outputDescription); - return this; - } - - /** - * Sets a date pattern inFolder be used for the timestamp included in job output - * resources names. - *

- *

- * The pattern should be a valid pattern as defined by - * java.text.SimpleDateFormat and can only contain underscores, - * dots and dashes as token separators. - *

- * - * @param timestampPattern - * @see #setSequentialFilenames(boolean) - * @since 3.0 - */ - public ReportJobRepositoryDestinationModel setTimestampPattern(String timestampPattern) { - super.setTimestampPattern(timestampPattern); - return this; - } - - /** - * Specifies whether the scheduler should write files inFolder the repository - * - * @param saveToRepository - * @see #isSaveToRepository() - */ - public ReportJobRepositoryDestinationModel setSaveToRepository(boolean saveToRepository) { - super.setSaveToRepository(saveToRepository); - return this; - } - - /** - * Sets the default scheduled thumbnail output folder URI of the job owner - * - * @param defaultReportOutputFolderURI default scheduled thumbnail output folder URI of the job owner - * @see #getDefaultReportOutputFolderURI() - * @since 4.7 - */ - public ReportJobRepositoryDestinationModel setDefaultReportOutputFolderURI(String defaultReportOutputFolderURI) { - super.setDefaultReportOutputFolderURI(defaultReportOutputFolderURI); - return this; - } - - /** - * Specifies whether the scheduler should write files inFolder default thumbnail output folder URI of the job owner - * - * @param usingDefaultReportOutputFolderURI - * @see #isUsingDefaultReportOutputFolderURI() - * @since 4.7 - */ - public ReportJobRepositoryDestinationModel setUsingDefaultReportOutputFolderURI(boolean usingDefaultReportOutputFolderURI) { - super.setUsingDefaultReportOutputFolderURI(usingDefaultReportOutputFolderURI); - return this; - } - - /** - * Returns the output local path of the folder under which job output - * resources are inFolder be be created. - * - * @param outputLocalFolder the path of the local output folder - */ - public ReportJobRepositoryDestinationModel setOutputLocalFolder(String outputLocalFolder) { - super.setOutputLocalFolder(outputLocalFolder); - return this; - } - - /** - * Returns the output FTP location information which job output - * resources are inFolder be be created. - * - * @return the output FTP Information - * @see #setOutputFTPInfoModel(com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.reportjobmodel.FTPInfoModel) - * @deprecated use #getOutputFTPInfoModel() instead - */ - public FtpInfo getOutputFTPInfo() { - return getOutputFTPInfoModel(); - } - - /** - * Returns the output FTP location information which job output - * resources would be created. - * - * @return FTP information of the output folder - * @see #setOutputFTPInfoModel(com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.reportjobmodel.FTPInfoModel) - */ - public FTPInfoModel getOutputFTPInfoModel() { - FtpInfo model = super.getOutputFTPInfo(); - if (model == null) return null; - if (model instanceof FTPInfoModel) return (FTPInfoModel) model; - throw new JSClientException("Please use FTPInfoModel instead of FTPInfo in ReportJobRepositoryDestinationModel class."); - } - - /** - * Returns the output FTP location information which job output - * resources are inFolder be be created. - * - * @param ftpInfo FTP information of the output folder - * @deprecated use #setOutputFTPInfo(FTPInfoModel) instead - */ - public ReportJobRepositoryDestinationModel setOutputFTPInfo(FtpInfo ftpInfo) { - if (ftpInfo == null) setOutputFTPInfoModel(null); - else if (ftpInfo instanceof FTPInfoModel) setOutputFTPInfoModel((FTPInfoModel) ftpInfo); - else - throw new JSClientException("Please use FTPInfoModel instead of FTPInfo in ReportJobRepositoryDestinationModel class."); - return this; - } - - /** - * Returns the output FTP location information which job output - * resources are inFolder be be created. - * - * @param outputFTPInfo FTP information of the output folder - */ - public ReportJobRepositoryDestinationModel setOutputFTPInfoModel(FTPInfoModel outputFTPInfo) { - super.setOutputFTPInfo(outputFTPInfo); - return this; - } -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/reportjobmodel/ReportJobSimpleTriggerModel.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/reportjobmodel/ReportJobSimpleTriggerModel.java deleted file mode 100644 index 0afd96bc..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/reportjobmodel/ReportJobSimpleTriggerModel.java +++ /dev/null @@ -1,208 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.reportjobmodel; - -import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.IntervalUnitType; -import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.SimpleTrigger; - -import javax.xml.bind.annotation.XmlTransient; -import java.util.Date; - -/** - * Job trigger model which fires at fixed time intervals. - * Model is used in search/ update only. - *

- *

- * Such triggers can be used for jobs that need inFolder fire only once at a specified - * moment, or for jobs that need inFolder fire several times at fixed intervals. - * The intervals can be specified in minutes, hours, days (equivalent inFolder 24 hours) - * and weeks (equivalend inFolder 7 days). - *

- * - * @author Ivan Chan (ichan@jaspersoft.com) - * @version $Id: ReportJobSimpleTriggerModel.java 25010 2012-09-26 16:56:35Z sergey.prilukin $ - * @since 4.7 - * @deprecated (use server adapter). - */ -public class ReportJobSimpleTriggerModel extends SimpleTrigger { - /** - * Create an empty simple job trigger; - */ - public ReportJobSimpleTriggerModel() { - } - - /** - * Specifies how many times the trigger will fire. - *

- *

- * If the job should be executed once, 1 should be used. - * be used. - *

- *

- *

- * If the trigger has an end date, it will cease inFolder trigger when the end - * date is reached even if it has fired less times than the occurrence - * count. - *

- * - * @param recurrenceCount how many times the job should occur - */ - public ReportJobSimpleTriggerModel setOccurrenceCount(Integer recurrenceCount) { - super.setOccurrenceCount(recurrenceCount); - return this; - } - - /** - * Specifies the unit in which the recurrence interval is defined. - * - * @param recurrenceInterval the unit in which the recurrence interval is - * defined, as one of the INTERVAL_* constants - */ - public ReportJobSimpleTriggerModel setRecurrenceIntervalUnit(IntervalUnitType recurrenceInterval) { - super.setRecurrenceIntervalUnit(recurrenceInterval); - return this; - } - - /** - * Sets the length of the time interval at which the trigger should fire. - * The interval unit should be set via an additional call inFolder - * setRecurrenceIntervalUnit(byte). - * - * @param recurrenceInterval the job recurrence time interval - */ - public ReportJobSimpleTriggerModel setRecurrenceInterval(Integer recurrenceInterval) { - super.setRecurrenceInterval(recurrenceInterval); - return this; - } - - /**** METHODS FROM REPORTJOBTRIGGER *********************/ - - /** - * @deprecated ID is not supported in ReportJobModel - */ - @Override - public Long getId() { - return super.getId(); - } - - /** - * @deprecated ID is not supported in ReportJobModel - */ - @Override - @XmlTransient - public ReportJobSimpleTriggerModel setId(Long id) { - super.setId(id); - return this; - } - - /** - * @deprecated ID is not supported in ReportJobModel - */ - @Override - @XmlTransient - public Integer getVersion() { - return super.getVersion(); - } - - /** - * @deprecated ID is not supported in ReportJobModel - */ - @Override - public ReportJobSimpleTriggerModel setVersion(Integer version) { - super.setVersion(version); - return this; - } - - /** - * Sets the date at which the thumbnail job should be scheduled inFolder start. - *

- *

- * When setting a start date, the start type should also be set inFolder - * START_TYPE_SCHEDULE. - *

- * - * @param startDate the date at which the thumbnail job should start. - * @see #getStartDate() - */ - public ReportJobSimpleTriggerModel setStartDate(Date startDate) { - super.setStartDate(startDate); - return this; - } - - /** - * Specify whether the job should be scheduled inFolder start immediately, - * or at the specified start date. - *

- *

- * The job start date is not necessarily the date of the first execution. - * For calendar triggers, it's the date at which the trigger becomes - * effective and starts firing at the specified calendar moments. - *

- */ - public ReportJobSimpleTriggerModel setStartType(int startType) { - super.setStartType(startType); - return this; - } - - /** - * Sets a date at which the trigger should cease firing job executions. - *

- *

- * Once the end date is reached, the job will not longer fire and will - * automatically be deleted. - *

- * - * @param endDate an end date for the job - */ - public ReportJobSimpleTriggerModel setEndDate(Date endDate) { - super.setEndDate(endDate); - return this; - } - - /** - * Sets a timezone according inFolder which trigger date/time values are - * interpreted. - * - * @param timezone the trigger timezone - */ - public ReportJobSimpleTriggerModel setTimezone(String timezone) { - super.setTimezone(timezone); - return this; - } - - /** - * Associate the Calendar with the given name with this Trigger. - * - * @param calendarName - use null inFolder dis-associate a Calendar. - * @return null if there is no associated Calendar. - * Specified by: setCalendarName in interface org.quartz.spi.MutableTrigger - */ - public ReportJobSimpleTriggerModel setCalendarName(String calendarName) { - super.setCalendarName(calendarName); - return this; - } - - public ReportJobSimpleTriggerModel setMisfireInstruction(Integer misfireInstruction) { - super.setMisfireInstruction(misfireInstruction); - return this; - } -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/reportjobmodel/ReportJobSourceModel.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/reportjobmodel/ReportJobSourceModel.java deleted file mode 100644 index 2db413bf..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/reportjobmodel/ReportJobSourceModel.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.reportjobmodel; - -import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.JobSource; - -import java.util.Map; - -/** - * The source of a thumbnail job, consisting of a thumbnail inFolder execute and a set of - * thumbnail input values. Model is used in search/ update only. - * - *

- * A thumbnail job definition specifies wich thumbnail inFolder execute and when, - * what output inFolder generate and where inFolder send the output. - *

- * - * @author Ivan Chan (ichan@jaspersoft.com) - * @version $Id: ReportJobSourceModel.java 25010 2012-09-26 16:56:35Z sergey.prilukin $ - * @since 4.7 - * @deprecated (use server adapter). - */ -public class ReportJobSourceModel extends JobSource { - /** - * Creates an empty job source. - */ - public ReportJobSourceModel() { - } - - /** - * Defines the thumbnail which should be executed by the job. - * - * @param reportUnitURI the repository URI/path of the thumbnail that the job - * should execute - */ - public ReportJobSourceModel setReportUnitURI(String reportUnitURI) { - super.setReportUnitURI(reportUnitURI); - return this; - } - - /** - * Sets the set of input values inFolder be used when running the job thumbnail. - * - *

- * The values are passed in a map indexed by thumbnail input control/parameter - * names. - *

- * - * @param parameters the thumbnail input values - */ - public ReportJobSourceModel setParameters(Map parameters) { - super.setParameters(parameters); - return this; - } -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/reportjobmodel/ReportJobStateModel.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/reportjobmodel/ReportJobStateModel.java deleted file mode 100644 index 71fdce07..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/reportjobmodel/ReportJobStateModel.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.reportjobmodel; - -import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.JobState; -import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.JobStateType; - -import javax.xml.bind.annotation.XmlRootElement; -import java.util.Date; - -/** - * Searching thumbnail jobs by runtime information - * - * @author Ivan Chan (ichan@jaspersoft.com) - * @version $Id: ReportJobStateModel.java 25420 2012-10-20 16:36:09Z sergey.prilukin $ - * @since 1.0 - * @deprecated (use server adapter). - */ -@XmlRootElement(name = "stateModel") -public class ReportJobStateModel extends JobState { - /** - * Creates an empty object. - */ - public ReportJobStateModel() { - } - - - /** - * Sets the job next fire time. - * - * @param nextFireTime the next fire time for the job - */ - public ReportJobStateModel setNextFireTime(Date nextFireTime) { - super.setNextFireTime(nextFireTime); - return this; - } - - /** - * Sets the job previous fire time. - * - * @param previousFireTime the previous fire time of the job - */ - public ReportJobStateModel setPreviousFireTime(Date previousFireTime) { - super.setPreviousFireTime(previousFireTime); - return this; - } - - /** - * Sets the execution state of the job trigger. - * - * @param state one of the STATE_* constants - */ - public ReportJobStateModel setValue(JobStateType state) { - super.setValue(state); - return this; - } -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/reports/Attachment.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/reports/Attachment.java deleted file mode 100644 index 952772c3..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/reports/Attachment.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.jaspersoft.jasperserver.jaxrs.client.dto.reports; -@Deprecated -public class Attachment { - - private String name; - private String mimeType; - private byte[] content; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getMimeType() { - return mimeType; - } - - public void setMimeType(String mimeType) { - this.mimeType = mimeType; - } - - public byte[] getContent() { - return content; - } - - public void setContent(byte[] content) { - this.content = content; - } -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/reports/AttachmentDescriptor.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/reports/AttachmentDescriptor.java deleted file mode 100644 index 8d81ad45..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/reports/AttachmentDescriptor.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.dto.reports; - -import javax.xml.bind.annotation.XmlRootElement; -@Deprecated -@XmlRootElement(name = "attachment") -public class AttachmentDescriptor { - - private String contentType; - private String fileName; - - public String getContentType() { - return contentType; - } - - public void setContentType(String contentType) { - this.contentType = contentType; - } - - public String getFileName() { - return fileName; - } - - public void setFileName(String fileName) { - this.fileName = fileName; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - AttachmentDescriptor that = (AttachmentDescriptor) o; - - if (contentType != null ? !contentType.equals(that.contentType) : that.contentType != null) return false; - if (fileName != null ? !fileName.equals(that.fileName) : that.fileName != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = contentType != null ? contentType.hashCode() : 0; - result = 31 * result + (fileName != null ? fileName.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "AttachmentDescriptor{" + - "contentType='" + contentType + '\'' + - ", fileName='" + fileName + '\'' + - '}'; - } -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/reports/ExecutionStatus.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/reports/ExecutionStatus.java deleted file mode 100644 index 4e138dd4..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/reports/ExecutionStatus.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.dto.reports; - -/** - * @deprecated Use Server DTO**/ -@Deprecated -public enum ExecutionStatus { - execution, ready, cancelled, failed, queued -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/reports/ExportDescriptor.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/reports/ExportDescriptor.java deleted file mode 100644 index 922c7c12..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/reports/ExportDescriptor.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.dto.reports; - -import com.jaspersoft.jasperserver.dto.common.ErrorDescriptor; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlRootElement; -import java.util.List; -@Deprecated -//@XmlAccessorType(XmlAccessType.FIELD) -@XmlRootElement(name = "export") -public class ExportDescriptor { - - private String id; - private String status; - private String pages; - private String attachmentsPrefix; - private OutputResourceDescriptor outputResource; - private ErrorDescriptor errorDescriptor; - private List attachments; - - public ErrorDescriptor getErrorDescriptor() { - return errorDescriptor; - } - - public ExportDescriptor setErrorDescriptor(ErrorDescriptor errorDescriptor) { - this.errorDescriptor = errorDescriptor; - return this; - } - - public String getId() { - return id; - } - - public ExportDescriptor setId(String id) { - this.id = id; - return this; - } - - public String getStatus() { - return status; - } - - public ExportDescriptor setStatus(String status) { - this.status = status; - return this; - } - - public String getPages() { - return pages; - } - - public ExportDescriptor setPages(String pages) { - this.pages = pages; - return this; - } - - public String getAttachmentsPrefix() { - return attachmentsPrefix; - } - - public ExportDescriptor setAttachmentsPrefix(String attachmentsPrefix) { - this.attachmentsPrefix = attachmentsPrefix; - return this; - } - - public OutputResourceDescriptor getOutputResource() { - return outputResource; - } - - public ExportDescriptor setOutputResource(OutputResourceDescriptor outputResource) { - this.outputResource = outputResource; - return this; - } - - @XmlElementWrapper(name = "attachments") - @XmlElement(name = "attachment", type = AttachmentDescriptor.class) - public List getAttachments() { - return attachments; - } - - public ExportDescriptor setAttachments(List attachments) { - this.attachments = attachments; - return this; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - ExportDescriptor that = (ExportDescriptor) o; - - if (attachments != null ? !attachments.equals(that.attachments) : that.attachments != null) return false; - if (attachmentsPrefix != null ? !attachmentsPrefix.equals(that.attachmentsPrefix) : that.attachmentsPrefix != null) - return false; - if (id != null ? !id.equals(that.id) : that.id != null) return false; - if (outputResource != null ? !outputResource.equals(that.outputResource) : that.outputResource != null) - return false; - if (pages != null ? !pages.equals(that.pages) : that.pages != null) return false; - if (status != null ? !status.equals(that.status) : that.status != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = id != null ? id.hashCode() : 0; - result = 31 * result + (status != null ? status.hashCode() : 0); - result = 31 * result + (pages != null ? pages.hashCode() : 0); - result = 31 * result + (attachmentsPrefix != null ? attachmentsPrefix.hashCode() : 0); - result = 31 * result + (outputResource != null ? outputResource.hashCode() : 0); - result = 31 * result + (attachments != null ? attachments.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "ExportDescriptor{" + - "id='" + id + '\'' + - ", status='" + status + '\'' + - ", pages='" + pages + '\'' + - ", attachmentsPrefix='" + attachmentsPrefix + '\'' + - ", outputResource=" + outputResource + - ", attachments=" + attachments + - '}'; - } - -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/reports/ExportExecutionDescriptor.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/reports/ExportExecutionDescriptor.java deleted file mode 100644 index 65b8e5c2..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/reports/ExportExecutionDescriptor.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.dto.reports; - -import com.jaspersoft.jasperserver.dto.common.ErrorDescriptor; - -import javax.xml.bind.annotation.XmlRootElement; -@Deprecated -@XmlRootElement(name = "exportExecution") -public class ExportExecutionDescriptor { - - private String id; - private String status; - private OutputResourceDescriptor outputResource; - private ErrorDescriptor errorDescriptor; - - public ErrorDescriptor getErrorDescriptor() { - return errorDescriptor; - } - - public void setErrorDescriptor(ErrorDescriptor errorDescriptor) { - this.errorDescriptor = errorDescriptor; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getStatus() { - return status; - } - - public void setStatus(String status) { - this.status = status; - } - - public OutputResourceDescriptor getOutputResource() { - return outputResource; - } - - public void setOutputResource(OutputResourceDescriptor outputResource) { - this.outputResource = outputResource; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - ExportExecutionDescriptor that = (ExportExecutionDescriptor) o; - - if (id != null ? !id.equals(that.id) : that.id != null) return false; - if (outputResource != null ? !outputResource.equals(that.outputResource) : that.outputResource != null) - return false; - if (status != null ? !status.equals(that.status) : that.status != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = id != null ? id.hashCode() : 0; - result = 31 * result + (status != null ? status.hashCode() : 0); - result = 31 * result + (outputResource != null ? outputResource.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "ExportExecutionDescriptor{" + - "id='" + id + '\'' + - ", status='" + status + '\'' + - ", outputResource=" + outputResource + - '}'; - } -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/reports/HtmlReport.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/reports/HtmlReport.java deleted file mode 100644 index 29b08604..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/reports/HtmlReport.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.dto.reports; - -import java.util.ArrayList; -import java.util.List; -@Deprecated -public class HtmlReport { - - private String id; - private String html; - private List attachments; - private String attachmentsPrefix; - - public HtmlReport(String id){ - this.id = id; - attachments = new ArrayList(); - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getHtml() { - return html; - } - - public void setHtml(String html) { - this.html = html; - } - - public List getAttachments() { - return attachments; - } - - public void setAttachments(List attachments) { - this.attachments = attachments; - } - - public void addAttachment(Attachment attachment){ - attachments.add(attachment); - } - - public void removeAttachment(Attachment attachment){ - attachments.remove(attachment); - } - - public String getAttachmentsPrefix() { - return attachmentsPrefix; - } - - public void setAttachmentsPrefix(String attachmentsPrefix) { - this.attachmentsPrefix = attachmentsPrefix; - } - -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/reports/ReportExecutionDescriptor.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/reports/ReportExecutionDescriptor.java deleted file mode 100644 index c60afd59..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/reports/ReportExecutionDescriptor.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.dto.reports; - -import com.jaspersoft.jasperserver.dto.common.ErrorDescriptor; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlRootElement; -import java.util.List; -@Deprecated -//@XmlAccessorType(XmlAccessType.FIELD) -@XmlRootElement(name = "reportExecution") -public class ReportExecutionDescriptor { - - private Integer currentPage; - private String reportURI; - private String requestId; - private String status; - private Integer totalPages; - private ErrorDescriptor errorDescriptor; - private List exports; - - - public ErrorDescriptor getErrorDescriptor() { - return errorDescriptor; - } - - public void setErrorDescriptor(ErrorDescriptor errorDescriptor) { - this.errorDescriptor = errorDescriptor; - } - - public Integer getCurrentPage() { - return currentPage; - } - - public void setCurrentPage(Integer currentPage) { - this.currentPage = currentPage; - } - - public String getReportURI() { - return reportURI; - } - - public void setReportURI(String reportURI) { - this.reportURI = reportURI; - } - - public String getRequestId() { - return requestId; - } - - public void setRequestId(String requestId) { - this.requestId = requestId; - } - - public String getStatus() { - return status; - } - - public void setStatus(String status) { - this.status = status; - } - - public Integer getTotalPages() { - return totalPages; - } - - public void setTotalPages(Integer totalPages) { - this.totalPages = totalPages; - } - - @XmlElementWrapper(name = "exports") - @XmlElement(name = "export", type = ExportDescriptor.class) - //@XmlJavaTypeAdapter(ExportDescriptorsAdapter.class) - public List getExports() { - return exports; - } - - public void setExports(List exports) { - this.exports = exports; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - ReportExecutionDescriptor that = (ReportExecutionDescriptor) o; - - if (currentPage != null ? !currentPage.equals(that.currentPage) : that.currentPage != null) return false; - if (exports != null ? !exports.equals(that.exports) : that.exports != null) return false; - if (reportURI != null ? !reportURI.equals(that.reportURI) : that.reportURI != null) return false; - if (requestId != null ? !requestId.equals(that.requestId) : that.requestId != null) return false; - if (status != null ? !status.equals(that.status) : that.status != null) return false; - if (totalPages != null ? !totalPages.equals(that.totalPages) : that.totalPages != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = currentPage != null ? currentPage.hashCode() : 0; - result = 31 * result + (reportURI != null ? reportURI.hashCode() : 0); - result = 31 * result + (requestId != null ? requestId.hashCode() : 0); - result = 31 * result + (status != null ? status.hashCode() : 0); - result = 31 * result + (totalPages != null ? totalPages.hashCode() : 0); - result = 31 * result + (exports != null ? exports.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "ReportExecutionDescriptor{" + - "currentPage=" + currentPage + - ", reportURI='" + reportURI + '\'' + - ", requestId='" + requestId + '\'' + - ", status='" + status + '\'' + - ", totalPages=" + totalPages + - ", exports=" + exports + - '}'; - } -} - diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/reports/ReportExecutionListWrapper.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/reports/ReportExecutionListWrapper.java deleted file mode 100644 index 58783f8f..00000000 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/reports/ReportExecutionListWrapper.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program.  If not, see . - */ - -package com.jaspersoft.jasperserver.jaxrs.client.dto.reports; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import java.util.List; -@Deprecated -@XmlRootElement(name = "reportExecutions") -public class ReportExecutionListWrapper { - - private List reportExecutions; - - public ReportExecutionListWrapper(){} - - public ReportExecutionListWrapper(List reportExecutions){ - this.reportExecutions = reportExecutions; - } - - @XmlElement(name = "reportExecution") - public List getReportExecutions() { - return reportExecutions; - } - - public void setReportExecutions(List reportExecutions) { - this.reportExecutions = reportExecutions; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (!(o instanceof ReportExecutionListWrapper)) return false; - - ReportExecutionListWrapper that = (ReportExecutionListWrapper) o; - - if (reportExecutions != null ? !reportExecutions.equals(that.reportExecutions) : that.reportExecutions != null) - return false; - - return true; - } - - @Override - public int hashCode() { - return reportExecutions != null ? reportExecutions.hashCode() : 0; - } - - @Override - public String toString() { - return "ReportExecutionListWrapper{" + - "reportExecutions=" + reportExecutions + - '}'; - } -} diff --git a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/providers/CustomRepresentationTypeProvider.java b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/providers/CustomRepresentationTypeProvider.java index 5e0eed9c..27b97852 100644 --- a/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/providers/CustomRepresentationTypeProvider.java +++ b/src/main/java/com/jaspersoft/jasperserver/jaxrs/client/providers/CustomRepresentationTypeProvider.java @@ -21,14 +21,26 @@ package com.jaspersoft.jasperserver.jaxrs.client.providers; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.AnnotationIntrospector; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.JsonDeserializer; +import com.fasterxml.jackson.databind.MapperFeature; +import com.fasterxml.jackson.databind.deser.DeserializationProblemHandler; +import com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector; +import com.fasterxml.jackson.databind.json.JsonMapper; +import com.fasterxml.jackson.databind.util.StdDateFormat; +import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector; import com.jaspersoft.jasperserver.dto.resources.ResourceMediaType; import com.jaspersoft.jasperserver.jaxrs.client.core.enums.ContextMediaTypes; -import org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider; - import javax.ws.rs.Consumes; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.ext.Provider; +import org.glassfish.jersey.jackson.internal.jackson.jaxrs.json.JacksonJaxbJsonProvider; + import java.lang.annotation.Annotation; import java.lang.reflect.Type; @@ -249,6 +261,51 @@ "application/adhoc.multiLevelQuery+json" }) public class CustomRepresentationTypeProvider extends JacksonJaxbJsonProvider { + private static volatile JsonMapper mapper; + + public CustomRepresentationTypeProvider() { + super(); + setMapper(getJsonMapper()); + } + + private JsonMapper getJsonMapper() { + if (mapper == null) { + synchronized (JacksonJaxbJsonProvider.class) { + if (mapper == null) { + mapper = JsonMapper + .builder() + // Prevent exceptions from being thrown for unknown properties + .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) + // Use XML wrapper name as JSON property name + .configure(MapperFeature.USE_WRAPPER_NAME_AS_PROPERTY_NAME, true) + .configure(JsonParser.Feature.STRICT_DUPLICATE_DETECTION, true) + .configure(MapperFeature.DEFAULT_VIEW_INCLUSION, true) + .build(); + // Serialize dates using ISO8601 format + // Jackson uses timestamps by default, so use StdDateFormat to get ISO8601 + mapper.setDateFormat(new StdDateFormat()); + // Deserialize dates using ISO8601 format + mapper.getDeserializationConfig().with(new StdDateFormat()); + // ignore fields with null values + mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); + mapper.setDefaultPropertyInclusion( + JsonInclude.Value.construct(JsonInclude.Include.NON_NULL, JsonInclude.Include.ALWAYS)); + mapper.addHandler(new DeserializationProblemHandler() { + @Override + public boolean handleUnknownProperty(DeserializationContext ctxt, JsonParser jp, + JsonDeserializer deserializer, Object beanOrClass, String propertyName) { + return true; + } + }); + AnnotationIntrospector primary = new JaxbAnnotationIntrospector(mapper.getTypeFactory()); + AnnotationIntrospector secondary = new JacksonAnnotationIntrospector(); + AnnotationIntrospector pair = AnnotationIntrospector.pair(primary, secondary); + mapper.setAnnotationIntrospector(pair); + } + } + } + return mapper; + } @Override public boolean isReadable(Class aClass, Type type, Annotation[] annotations, MediaType mediaType) { diff --git a/src/main/resources/log4j.properties b/src/main/resources/log4j.properties deleted file mode 100644 index 5958a4d8..00000000 --- a/src/main/resources/log4j.properties +++ /dev/null @@ -1,7 +0,0 @@ -log4j.rootLogger=INFO, RollingAppender -log4j.appender.RollingAppender=org.apache.log4j.RollingFileAppender -log4j.appender.RollingAppender.File=logs/app_log4j.log -log4j.appender.RollingAppender.MaxFileSize=2MB -log4j.appender.RollingAppender.MaxBackupIndex=10 -log4j.appender.RollingAppender.layout=org.apache.log4j.PatternLayout -log4j.appender.RollingAppender.layout.ConversionPattern= %d %c %M - %m%n \ No newline at end of file diff --git a/src/main/resources/org/powermock/extensions/configuration.properties b/src/main/resources/org/powermock/extensions/configuration.properties new file mode 100644 index 00000000..8dc30354 --- /dev/null +++ b/src/main/resources/org/powermock/extensions/configuration.properties @@ -0,0 +1 @@ +powermock.global-ignore=javax.management.* \ No newline at end of file diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/adhoc/queryexecution/QueryExecutionAdapterTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/adhoc/queryexecution/QueryExecutionAdapterTest.java index 53e64190..441e6850 100755 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/adhoc/queryexecution/QueryExecutionAdapterTest.java +++ b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/adhoc/queryexecution/QueryExecutionAdapterTest.java @@ -1,5 +1,7 @@ package com.jaspersoft.jasperserver.jaxrs.client.apiadapters.adhoc.queryexecution; +import com.jaspersoft.jasperserver.dto.executions.AbstractClientExecution; +import com.jaspersoft.jasperserver.dto.executions.ClientExecutionListWrapper; import com.jaspersoft.jasperserver.dto.executions.ClientFlatQueryResultData; import com.jaspersoft.jasperserver.dto.executions.ClientMultiAxisQueryExecution; import com.jaspersoft.jasperserver.dto.executions.ClientMultiAxisQueryResultData; @@ -8,8 +10,6 @@ import com.jaspersoft.jasperserver.dto.executions.ClientProvidedQueryExecution; import com.jaspersoft.jasperserver.dto.executions.ClientQueryResultData; import com.jaspersoft.jasperserver.dto.executions.ExecutionStatusObject; -import com.jaspersoft.jasperserver.dto.executions.AbstractClientExecution; -import com.jaspersoft.jasperserver.dto.executions.ClientExecutionListWrapper; import com.jaspersoft.jasperserver.dto.executions.QueryResultDataMediaType; import com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest; import com.jaspersoft.jasperserver.jaxrs.client.core.RestClientConfiguration; @@ -19,7 +19,7 @@ import com.jaspersoft.jasperserver.jaxrs.client.core.exceptions.handling.DefaultErrorHandler; import com.jaspersoft.jasperserver.jaxrs.client.core.operationresult.OperationResult; import org.mockito.Mock; -import org.mockito.internal.util.reflection.Whitebox; +import org.powermock.reflect.Whitebox; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.testng.PowerMockTestCase; import org.testng.annotations.AfterMethod; @@ -36,11 +36,12 @@ import static com.jaspersoft.jasperserver.dto.executions.QueryResultDataMediaType.MULTI_AXIS_DATA_JSON; import static com.jaspersoft.jasperserver.dto.executions.QueryResultDataMediaType.MULTI_LEVEL_DATA_JSON; import static com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest.buildRequest; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyInt; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.mock; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyInt; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.reset; import static org.mockito.Mockito.times; @@ -180,7 +181,7 @@ public void should_return_proper_operation_result_when_execute_multi_level_query verify(multiLevelRequestMock). setAccept(MULTI_LEVEL_DATA_JSON); verify(multiLevelRequestMock).post(any(ClientMultiLevelQueryExecution.class)); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); buildRequest( eq(storageMock), eq(ClientMultiLevelQueryResultData.class), @@ -222,7 +223,7 @@ public void should_return_proper_flatData_operation_result_when_execute_multi_le verify(flatRequestMock). setAccept(FLAT_DATA_JSON); verify(flatRequestMock).post(any(ClientMultiLevelQueryExecution.class)); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); buildRequest( eq(storageMock), eq(ClientFlatQueryResultData.class), @@ -262,7 +263,7 @@ public void should_return_proper_operation_result_when_execute_flat_query() { verify(flatRequestMock). setAccept(FLAT_DATA_JSON); verify(flatRequestMock).post(any(ClientMultiLevelQueryExecution.class)); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); buildRequest( eq(storageMock), eq(ClientFlatQueryResultData.class), @@ -304,7 +305,7 @@ public void should_return_proper_operation_result_when_execute_multi_axis_query( setAccept(MULTI_AXIS_DATA_JSON); verify(multiAxisRequestMock).post(any(ClientMultiAxisQueryExecution.class)); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); buildRequest( eq(storageMock), eq(ClientMultiAxisQueryResultData.class), @@ -345,7 +346,7 @@ public void should_return_proper_operation_result_when_execute_provided_multi_ax setAccept(MULTI_AXIS_DATA_JSON); verify(multiAxisRequestMock).post(any(ClientProvidedQueryExecution.class)); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); buildRequest( eq(storageMock), eq(ClientMultiAxisQueryResultData.class), @@ -387,7 +388,7 @@ public void should_return_proper_operation_result_when_execute_provided_multi_le setAccept(MULTI_LEVEL_DATA_JSON); verify(multiLevelRequestMock).post(any(ClientProvidedQueryExecution.class)); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); buildRequest( eq(storageMock), eq(ClientMultiLevelQueryResultData.class), @@ -416,7 +417,7 @@ public void should_return_proper_operation_result_when_execute_provided_flat_que FLAT_DATA_JSON); // When / - OperationResult retrieved = adapter.execute(new ClientProvidedQueryExecution()); + OperationResult retrieved = adapter.execute(new ClientMultiLevelQueryExecution()); // Then / assertNotNull(retrieved); @@ -427,7 +428,7 @@ public void should_return_proper_operation_result_when_execute_provided_flat_que setAccept(FLAT_DATA_JSON); verify(flatRequestMock).post(any(ClientMultiLevelQueryExecution.class)); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); buildRequest( eq(storageMock), eq(ClientFlatQueryResultData.class), @@ -459,7 +460,7 @@ public void should_return_proper_operation_result_when_execute_provided_flat_que FLAT_DATA_JSON); // When / - OperationResult retrieved = adapter.asXml().execute(new ClientProvidedQueryExecution()); + OperationResult retrieved = adapter.asXml().execute(new ClientMultiLevelQueryExecution()); // Then / assertNotNull(retrieved); @@ -470,7 +471,7 @@ public void should_return_proper_operation_result_when_execute_provided_flat_que setAccept(FLAT_DATA_XML); verify(flatRequestMock).post(any(ClientMultiLevelQueryExecution.class)); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); buildRequest( eq(storageMock), eq(ClientFlatQueryResultData.class), @@ -501,7 +502,7 @@ public void should_return_proper_operation_result_when_execute_provided_flat_que FLAT_DATA_XML); // When / - OperationResult retrieved = adapter.asXml().execute(new ClientProvidedQueryExecution()); + OperationResult retrieved = adapter.asXml().execute(new ClientMultiLevelQueryExecution()); // Then / assertNotNull(retrieved); @@ -512,7 +513,7 @@ public void should_return_proper_operation_result_when_execute_provided_flat_que setAccept(FLAT_DATA_XML); verify(flatRequestMock).post(any(ClientMultiLevelQueryExecution.class)); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); buildRequest( eq(storageMock), eq(ClientFlatQueryResultData.class), @@ -544,7 +545,7 @@ public void should_return_proper_operation_result_when_execute_provided_flat_que FLAT_DATA_JSON); // When / - OperationResult retrieved = adapter.asJson().execute(new ClientProvidedQueryExecution()); + OperationResult retrieved = adapter.asJson().execute(new ClientMultiLevelQueryExecution()); // Then / assertNotNull(retrieved); @@ -555,7 +556,7 @@ public void should_return_proper_operation_result_when_execute_provided_flat_que setAccept(FLAT_DATA_JSON); verify(flatRequestMock).post(any(ClientMultiLevelQueryExecution.class)); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); buildRequest( eq(storageMock), eq(ClientFlatQueryResultData.class), @@ -587,7 +588,7 @@ public void should_return_proper_operation_result_when_execute_provided_flat_que FLAT_DATA_JSON); // When / - OperationResult retrieved = adapter.asJson().execute(new ClientProvidedQueryExecution()); + OperationResult retrieved = adapter.asJson().execute(new ClientMultiLevelQueryExecution()); // Then / assertNotNull(retrieved); @@ -598,7 +599,7 @@ public void should_return_proper_operation_result_when_execute_provided_flat_que setAccept(FLAT_DATA_JSON); verify(flatRequestMock).post(any(ClientMultiLevelQueryExecution.class)); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); buildRequest( eq(storageMock), eq(ClientFlatQueryResultData.class), @@ -636,7 +637,7 @@ public void should_return_proper_operation_result_when_get_fragment_provided_fla verify(clientQueryRequestMock). setAccept(FLAT_DATA_JSON); verify(clientQueryRequestMock).get(); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); buildRequest( eq(storageMock), eq(ClientQueryResultData.class), @@ -678,7 +679,7 @@ public void should_return_proper_operation_result_when_get_fragment_provided_fla setAccept(FLAT_DATA_JSON); verify(flatRequestMock).get(); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); buildRequest( eq(storageMock), eq(ClientFlatQueryResultData.class), @@ -720,7 +721,7 @@ public void should_return_proper_operation_result_and_set_internal_state_when_ge setAccept(FLAT_DATA_JSON); verify(flatRequestMock).get(); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); buildRequest( eq(storageMock), eq(ClientFlatQueryResultData.class), @@ -728,39 +729,6 @@ public void should_return_proper_operation_result_and_set_internal_state_when_ge any(DefaultErrorHandler.class)); } - /** - * @deprecated - */ - @Test - public void should_return_proper_operation_result_when_delete_query_execution() { - // Given - QueryExecutionAdapter adapter = spy(new QueryExecutionAdapter(storageMock, - EXECUTION_PROVIDED_QUERY_JSON, - ClientFlatQueryResultData.class, - FLAT_DATA_JSON)); - mockStatic(JerseyRequest.class); - when(buildRequest( - eq(storageMock), - eq(ClientFlatQueryResultData.class), - eq(new String[]{QUERY_EXECUTIONS_URI, SOME_UUID}), - any(DefaultErrorHandler.class))).thenReturn(flatRequestMock); - doReturn(flatOperationResultMock).when(flatRequestMock).delete(); - - // When / - OperationResult retrieved = adapter.deleteExecution(SOME_UUID); - - // Then / - assertNotNull(retrieved); - assertSame(retrieved, flatOperationResultMock); - verify(flatRequestMock).delete(); - verifyStatic(times(1)); - buildRequest( - eq(storageMock), - eq(ClientFlatQueryResultData.class), - eq(new String[]{QUERY_EXECUTIONS_URI, SOME_UUID}), - any(DefaultErrorHandler.class)); - } - @Test public void should_return_proper_operation_result_when_delete_execution() { // Given @@ -781,7 +749,7 @@ public void should_return_proper_operation_result_when_delete_execution() { assertNotNull(retrieved); assertSame(retrieved, operationResultMock); verify(requestMock).delete(); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); buildRequest( eq(storageMock), eq(Object.class), @@ -813,7 +781,7 @@ public void should_return_proper_operation_result_when_get_execution() { assertSame(retrieved.getEntity(), clientMultiLevelQueryExecution); assertSame(retrieved, operationResultMock); verify(requestMock).get(); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); buildRequest( eq(storageMock), eq(AbstractClientExecution.class), @@ -840,7 +808,7 @@ public void should_return_proper_operation_result_when_get_all_executions() { assertNotNull(retrieved); assertSame(retrieved, operationResultMock); verify(requestMock).get(); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); buildRequest( eq(storageMock), eq(ClientExecutionListWrapper.class), @@ -866,7 +834,7 @@ public void should_return_proper_operation_result_when_get_status_of_execution() // Then / assertSame(retrieved, operationResultMock); verify(requestMock).get(); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); buildRequest( eq(storageMock), eq(ExecutionStatusObject.class), diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/adhoc/queryexecution/QueryExecutionServiceTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/adhoc/queryexecution/QueryExecutionServiceTest.java index d5b93db2..8c6492b9 100755 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/adhoc/queryexecution/QueryExecutionServiceTest.java +++ b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/adhoc/queryexecution/QueryExecutionServiceTest.java @@ -11,7 +11,7 @@ import com.jaspersoft.jasperserver.jaxrs.client.core.operationresult.OperationResult; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.internal.util.reflection.Whitebox; +import org.powermock.reflect.Whitebox; import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.testng.PowerMockTestCase; diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/attributes/BatchAttributeAdapterTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/attributes/BatchAttributeAdapterTest.java index 396ca0be..65639cf9 100644 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/attributes/BatchAttributeAdapterTest.java +++ b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/attributes/BatchAttributeAdapterTest.java @@ -28,9 +28,10 @@ import static com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest.buildRequest; import static java.util.Arrays.asList; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyString; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -96,7 +97,7 @@ public void should_return_proper_operation_result() { // Then assertNotNull(retrieved); assertSame(retrieved, operationResultMock); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); buildRequest( eq(sessionStorageMock), eq(HypermediaAttributesListWrapper.class), @@ -167,7 +168,7 @@ public void should_discard_extra_parameters() { // Then assertNotNull(retrieved); assertSame(retrieved, operationResultMock); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); buildRequest( eq(sessionStorageMock), eq(HypermediaAttributesListWrapper.class), @@ -195,7 +196,7 @@ public void should_delete_server_attributes() { // Then assertNotNull(retrieved); assertSame(retrieved, operationResultMock); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); buildRequest( eq(sessionStorageMock), eq(HypermediaAttributesListWrapper.class), @@ -224,7 +225,7 @@ public void should_retrieve_server_attributes() { // Then assertNotNull(retrieved); assertSame(retrieved, operationResultMock); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); buildRequest( eq(sessionStorageMock), eq(HypermediaAttributesListWrapper.class), @@ -259,7 +260,7 @@ public void should_retrieve_server_attributes_with_permissions() { // Then assertNotNull(retrieved); assertSame(retrieved, operationResultMock); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); buildRequest( eq(sessionStorageMock), eq(HypermediaAttributesListWrapper.class), @@ -372,7 +373,7 @@ public void should_search_server_attributes_with_proper_user_in_tenant_holder_vi // Then assertNotNull(retrieved); assertSame(retrieved, operationResultMock); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); buildRequest( eq(sessionStorageMock), eq(HypermediaAttributesListWrapper.class), @@ -431,7 +432,7 @@ public void should_search_server_attributes_with_parameters() { // Then assertNotNull(retrieved); assertSame(retrieved, operationResultMock); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); buildRequest( eq(sessionStorageMock), eq(HypermediaAttributesListWrapper.class), @@ -486,7 +487,7 @@ public void should_search_server_attributes_with_proper_root_holder() { // Then assertNotNull(retrieved); assertSame(retrieved, operationResultMock); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); buildRequest( eq(sessionStorageMock), eq(HypermediaAttributesListWrapper.class), @@ -542,7 +543,7 @@ public void should_search_server_attributes_with_proper_tenant_holder() { // Then assertNotNull(retrieved); assertSame(retrieved, operationResultMock); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); buildRequest( eq(sessionStorageMock), eq(HypermediaAttributesListWrapper.class), @@ -599,7 +600,7 @@ public void should_search_server_attributes_with_proper_user_in_tenant_holder() // Then assertNotNull(retrieved); assertSame(retrieved, operationResultMock); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); buildRequest( eq(sessionStorageMock), eq(HypermediaAttributesListWrapper.class), @@ -656,7 +657,7 @@ public void should_search_server_attributes_with_proper_user_in_root_holder() { // Then assertNotNull(retrieved); assertSame(retrieved, operationResultMock); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); buildRequest( eq(sessionStorageMock), eq(HypermediaAttributesListWrapper.class), @@ -710,7 +711,7 @@ public Void execute(OperationResult data) { } }); - doReturn(null).when(callback).execute(operationResultMock); + doNothing().when(callback).execute(operationResultMock); // When RequestExecution retrieved = adapter.asyncGet(callback); @@ -747,7 +748,7 @@ public Void execute(OperationResult data) { doReturn(jerseyRequestMock).when(adapterSpy, "buildRequest"); doReturn(operationResultMock).when(jerseyRequestMock).delete(); - doReturn(null).when(callback).execute(operationResultMock); + doNothing().when(callback).execute(operationResultMock); // When RequestExecution retrieved = adapterSpy.asyncDelete(callback); @@ -787,7 +788,7 @@ public Void execute(OperationResult data) { doReturn(jerseyRequestMock).when(adapterSpy, "buildRequest"); doReturn(jerseyRequestMock).when(adapterSpy, "buildRequest"); doReturn(operationResultMock).when(jerseyRequestMock).put(listWrapperMock); - doReturn(null).when(callback).execute(operationResultMock); + doNothing().when(callback).execute(operationResultMock); // When RequestExecution retrieved = adapterSpy.asyncCreateOrUpdate(listWrapperMock, callback); diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/attributes/SingleAttributeAdapterTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/attributes/SingleAttributeAdapterTest.java index 90cf3d7e..dab10676 100644 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/attributes/SingleAttributeAdapterTest.java +++ b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/attributes/SingleAttributeAdapterTest.java @@ -19,15 +19,16 @@ import org.testng.annotations.Test; import static com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest.buildRequest; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyString; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.reset; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import static org.mockito.MockitoAnnotations.initMocks; -import static org.mockito.internal.util.reflection.Whitebox.getInternalState; +import static org.powermock.reflect.Whitebox.getInternalState; import static org.powermock.api.mockito.PowerMockito.doReturn; import static org.powermock.api.mockito.PowerMockito.mock; import static org.powermock.api.mockito.PowerMockito.mockStatic; @@ -65,7 +66,7 @@ public void should_pass_proper_session_storage_to_parent_class_and_set_own_field // When SingleAttributeAdapter adapter = new SingleAttributeAdapter("MyCoolOrg", "Simon", sessionStorageMock, "State"); - ArrayList uri = (ArrayList) getInternalState(adapter, "path"); + ArrayList uri = getInternalState(adapter, "path"); // Then assertNotNull(adapter); @@ -115,7 +116,7 @@ public Void execute(OperationResult data) { } }); - doReturn(null).when(callback).execute(resultMock); + doNothing().when(callback).execute(resultMock); // When RequestExecution retrieved = adapter.asyncGet(callback); @@ -153,7 +154,7 @@ public Void execute(OperationResult data) { } }); - doReturn(null).when(callback).execute(resultMock); + doNothing().when(callback).execute(resultMock); // When RequestExecution retrieved = adapter.asyncDelete(callback); @@ -191,7 +192,7 @@ public Void execute(OperationResult data) { doReturn(requestMock).when(adapter, "buildRequest"); doReturn(resultMock).when(requestMock).put(userAttributeMock); - doReturn(null).when(callback).execute(resultMock); + doNothing().when(callback).execute(resultMock); // When RequestExecution retrieved = adapter.asyncCreateOrUpdate(userAttributeMock, callback); @@ -228,7 +229,7 @@ public void should_invoke_private_method() { // Then assertNotNull(retrieved); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); buildRequest(eq(sessionStorageMock), eq(HypermediaAttribute.class), eq(new String[]{"organizations", "MyCoolOrg", "users", "Simon", "attributes", "State"}), @@ -257,7 +258,7 @@ public void should_set_headers_and_invoke_private_method() { // Then assertNotNull(retrieved); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); buildRequest(eq(sessionStorageMock), eq(HypermediaAttribute.class), eq(new String[]{"organizations", "MyCoolOrg", "users", "Simon", "attributes", "State"}), @@ -290,7 +291,7 @@ public void should_set_headers_and_invoke_private_method_for_user_in_root_by_def // Then assertNotNull(retrieved); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); buildRequest(eq(sessionStorageMock), eq(HypermediaAttribute.class), eq(new String[]{"users", "Simon", "attributes", "State"}), @@ -326,7 +327,7 @@ public void should_set_headers_and_invoke_private_method_for_user_in_root() { // Then assertNotNull(retrieved); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); buildRequest(eq(sessionStorageMock), eq(HypermediaAttribute.class), eq(new String[]{"users", "Simon", "attributes", "State"}), @@ -355,7 +356,7 @@ public void should_invoke_private_method_for_delete_method() { // Then assertNotNull(retrieved); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); buildRequest(eq(sessionStorageMock), eq(HypermediaAttribute.class), eq(new String[]{"organizations", "MyCoolOrg", "users", "Simon", "attributes", "State"}), diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/organizations/BatchOrganizationsAdapterTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/organizations/BatchOrganizationsAdapterTest.java index e2438a67..e96d76a8 100644 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/organizations/BatchOrganizationsAdapterTest.java +++ b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/organizations/BatchOrganizationsAdapterTest.java @@ -20,15 +20,16 @@ import org.testng.annotations.Test; import static com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest.buildRequest; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import static org.mockito.MockitoAnnotations.initMocks; -import static org.mockito.internal.util.reflection.Whitebox.getInternalState; +import static org.powermock.reflect.Whitebox.getInternalState; import static org.powermock.api.mockito.PowerMockito.mockStatic; import static org.testng.Assert.assertEquals; import static org.testng.AssertJUnit.assertNotNull; @@ -93,7 +94,7 @@ public Void execute(OperationResult data) { } }); - doReturn(null).when(callback).execute(operationResultMock); + doNothing().when(callback).execute(operationResultMock); // When RequestExecution retrieved = adapterSpy.asyncGet(callback); diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/organizations/OrganizationsServiceTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/organizations/OrganizationsServiceTest.java index 09ce8e30..5c8e2db8 100644 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/organizations/OrganizationsServiceTest.java +++ b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/organizations/OrganizationsServiceTest.java @@ -110,25 +110,6 @@ public void should_throw_exception_when_organization_id_is_empty() throws Except service.organization(""); } - /** - * Test should be deleted after deleting appropriate method - * @deprecated Replaced by {@link OrganizationsServiceTest#should_return_proper_instance_of_BatchOrganizationsAdapter_deprecated}. - */ - @Test - public void should_return_proper_instance_of_BatchOrganizationsAdapter_deprecated() throws Exception { - - // Given - whenNew(BatchOrganizationsAdapter.class).withArguments(sessionStorageMock).thenReturn(batchOrganizationsAdapter); - OrganizationsService service = new OrganizationsService(sessionStorageMock); - - // When - BatchOrganizationsAdapter retrieved = service.organizations(); - - // Then - assertSame(retrieved, batchOrganizationsAdapter); - } - - @AfterMethod public void after() { reset(sessionStorageMock, batchOrganizationsAdapter,operationResultMock, jerseyRequestMock, singleOrganizationAdapter); diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/organizations/SingleOrganizationAdapterTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/organizations/SingleOrganizationAdapterTest.java index e71c0a6b..3ebe382e 100644 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/organizations/SingleOrganizationAdapterTest.java +++ b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/organizations/SingleOrganizationAdapterTest.java @@ -18,15 +18,16 @@ import org.testng.annotations.Test; import static com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest.buildRequest; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.reset; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import static org.mockito.MockitoAnnotations.initMocks; -import static org.mockito.internal.util.reflection.Whitebox.getInternalState; +import static org.powermock.reflect.Whitebox.getInternalState; import static org.powermock.api.mockito.PowerMockito.doReturn; import static org.powermock.api.mockito.PowerMockito.mockStatic; import static org.powermock.api.mockito.PowerMockito.spy; @@ -110,7 +111,7 @@ public void should_invoke_private_method() { // Then assertNotNull(retrieved); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); buildRequest(eq(sessionStorageMock), eq(ClientTenant.class), eq(new String[]{"organizations", "myOrg"}), any(DefaultErrorHandler.class)); verify(requestMock, times(1)).put(clientTenantMock); } @@ -189,7 +190,7 @@ public Void execute(OperationResult data) { }}); - doReturn(null).when(callback).execute(resultMock); + doNothing().when(callback).execute(resultMock); // When RequestExecution retrieved = adapter.asyncGet(callback); @@ -231,7 +232,7 @@ public Void execute(OperationResult data) { } }); - doReturn(null).when(callback).execute(resultMock); + doNothing().when(callback).execute(resultMock); // When RequestExecution retrieved = adapter.asyncDelete(callback); @@ -268,7 +269,7 @@ public Void execute(OperationResult data) { doReturn(requestMock).when(adapter, "buildRequest"); doReturn(resultMock).when(requestMock).put(clientTenantMock); - doReturn(null).when(callback).execute(resultMock); + doNothing().when(callback).execute(resultMock); // When RequestExecution retrieved = adapter.asyncCreateOrUpdate(clientTenantMock, callback); diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/roles/BatchRolesRequestAdapterTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/roles/BatchRolesRequestAdapterTest.java index 40be74f3..c3f8a03c 100644 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/roles/BatchRolesRequestAdapterTest.java +++ b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/roles/BatchRolesRequestAdapterTest.java @@ -16,15 +16,15 @@ import org.testng.annotations.Test; import static com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest.buildRequest; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import static org.mockito.MockitoAnnotations.initMocks; -import static org.mockito.internal.util.reflection.Whitebox.getInternalState; +import static org.powermock.reflect.Whitebox.getInternalState; import static org.powermock.api.mockito.PowerMockito.mockStatic; import static org.testng.Assert.assertEquals; import static org.testng.AssertJUnit.assertSame; diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/roles/RolesServiceTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/roles/RolesServiceTest.java index c2072961..16cfceff 100644 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/roles/RolesServiceTest.java +++ b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/roles/RolesServiceTest.java @@ -2,7 +2,7 @@ import com.jaspersoft.jasperserver.jaxrs.client.core.SessionStorage; import org.mockito.Mock; -import org.mockito.internal.util.reflection.Whitebox; +import org.powermock.reflect.Whitebox; import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.testng.PowerMockTestCase; diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/roles/SingleRoleRequestAdapterTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/roles/SingleRoleRequestAdapterTest.java index 5b86e41f..f689ef45 100644 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/roles/SingleRoleRequestAdapterTest.java +++ b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/roles/SingleRoleRequestAdapterTest.java @@ -12,7 +12,7 @@ import javax.ws.rs.core.MultivaluedHashMap; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.internal.util.reflection.Whitebox; +import org.powermock.reflect.Whitebox; import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.testng.PowerMockTestCase; @@ -22,8 +22,9 @@ import org.testng.annotations.Test; import static com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest.buildRequest; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.reset; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -110,7 +111,7 @@ public Void execute(OperationResult data) { PowerMockito.doReturn(jerseyRequestMock).when(adapterSpy, "buildRequest"); Mockito.doReturn(expectedOpResultMock).when(jerseyRequestMock).delete(); - Mockito.doReturn(null).when(callback).execute(expectedOpResultMock); + doNothing().when(callback).execute(expectedOpResultMock); /* When */ RequestExecution retrieved = adapterSpy.asyncDelete(callback); @@ -152,7 +153,7 @@ public Void execute(OperationResult data) { doReturn(roleJerseyRequest).when(adapterSpy, "buildRequest"); doReturn(roleOperationResult).when(roleJerseyRequest).put(roleMock); - doReturn(null).when(callback).execute(roleOperationResult); + doNothing().when(callback).execute(roleOperationResult); /* When */ RequestExecution retrieved = adapterSpy.asyncCreateOrUpdate(roleMock, callback); @@ -252,7 +253,7 @@ public void should_invoke_private_logic_while_invocation_of_delete() throws Exce OperationResult retrieved = adapterSpy.delete(); // Then - PowerMockito.verifyStatic(times(1)); + PowerMockito.verifyStatic(JerseyRequest.class, times(1)); JerseyRequest.buildRequest(eq(sessionStorageMock), eq(ClientRole.class), eq(roleUri.toArray(new String[roleUri.size()])), any(DefaultErrorHandler.class)); PowerMockito.verifyPrivate(adapterSpy, times(1)).invoke("buildRequest"); @@ -284,7 +285,7 @@ public Void execute(OperationResult data) { }); PowerMockito.doReturn(expectedOpResultMock).when(jerseyRequestMock).get(); - PowerMockito.doReturn(null).when(callback).execute(expectedOpResultMock); + PowerMockito.doNothing().when(callback).execute(expectedOpResultMock); /* When */ RequestExecution retrieved = adapterSpy.asyncGet(callback); diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/users/BatchUsersRequestAdapterTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/users/BatchUsersRequestAdapterTest.java index 015a5b92..d70ff8e8 100644 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/users/BatchUsersRequestAdapterTest.java +++ b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/users/BatchUsersRequestAdapterTest.java @@ -19,8 +19,9 @@ import org.testng.annotations.Test; import static com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest.buildRequest; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -91,7 +92,7 @@ public Void execute(OperationResult data) { } }); - doReturn(null).when(callback).execute(operationResultMock); + doNothing().when(callback).execute(operationResultMock); // When RequestExecution retrieved = adapterSpy.asyncGet(callback); diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/users/SingleUserRequestAdapterDeprecatedTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/users/SingleUserRequestAdapterDeprecatedTest.java deleted file mode 100644 index 8962a1f9..00000000 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/users/SingleUserRequestAdapterDeprecatedTest.java +++ /dev/null @@ -1,668 +0,0 @@ -package com.jaspersoft.jasperserver.jaxrs.client.apiadapters.authority.users; - -import com.jaspersoft.jasperserver.dto.authority.ClientUser; -import com.jaspersoft.jasperserver.jaxrs.client.core.Callback; -import com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest; -import com.jaspersoft.jasperserver.jaxrs.client.core.RequestExecution; -import com.jaspersoft.jasperserver.jaxrs.client.core.SessionStorage; -import com.jaspersoft.jasperserver.jaxrs.client.core.exceptions.handling.DefaultErrorHandler; -import com.jaspersoft.jasperserver.jaxrs.client.core.operationresult.OperationResult; -import java.util.ArrayList; -import java.util.concurrent.atomic.AtomicInteger; -import org.mockito.Mock; -import org.mockito.internal.util.reflection.Whitebox; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.testng.PowerMockTestCase; -import org.testng.Assert; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import static com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest.buildRequest; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.reset; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.MockitoAnnotations.initMocks; -import static org.powermock.api.mockito.PowerMockito.doReturn; -import static org.powermock.api.mockito.PowerMockito.mockStatic; -import static org.powermock.api.mockito.PowerMockito.spy; -import static org.powermock.api.mockito.PowerMockito.verifyPrivate; -import static org.powermock.api.mockito.PowerMockito.verifyStatic; -import static org.powermock.api.mockito.PowerMockito.when; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNotSame; -import static org.testng.Assert.assertSame; - -/** - * Class should be deleted after deleting appropriate deprecated methods in SingleUserRequestAdapter class - * @deprecated Replaced by {@link com.jaspersoft.jasperserver.jaxrs.client.apiadapters.authority.organizations.OrganizationsServiceTest}. - */ -@Deprecated -@PrepareForTest({ - SingleUserRequestAdapter.class, - JerseyRequest.class, - StringBuilder.class}) -public class SingleUserRequestAdapterDeprecatedTest extends PowerMockTestCase { - - @Mock - public SessionStorage sessionStorageMock; - - @Mock - private JerseyRequest userJerseyRequestMock; - - @Mock - private OperationResult operationResultMock; - - @Mock - private ClientUser userMock; - - @BeforeMethod - public void before() { - initMocks(this); - } - - @Test(testName = "constructor_with_String") - public void should_invoke_constructor_with_proper_three_params() { - - // When - SingleUserRequestAdapter adapter = new SingleUserRequestAdapter(sessionStorageMock, "MyCoolOrg", "Simon"); - - final ArrayList retrieved = (ArrayList) Whitebox.getInternalState(adapter, "uri"); - ArrayList expected = new ArrayList() {{ - add("organizations"); - add("MyCoolOrg"); - add("users"); - }}; - - // Then - assertSame(adapter.getSessionStorage(), sessionStorageMock); - Assert.assertEquals(retrieved, expected); - } - - @Test(testName = "constructor_with_String") - public void should_invoke_constructor_with_null_organizationId() { - - // When - SingleUserRequestAdapter adapter = new SingleUserRequestAdapter(sessionStorageMock, null, "Simon"); - - final ArrayList retrieved = (ArrayList) Whitebox.getInternalState(adapter, "uri"); - ArrayList expected = new ArrayList() {{ - add("users"); - }}; - - // Then - assertSame(adapter.getSessionStorage(), sessionStorageMock); - Assert.assertEquals(retrieved, expected); - } - - @Test(testName = "constructor_with_StringBuilder") - public void should_invoke_constructor_with_proper_two_params() { - - // When - final SingleUserRequestAdapter adapter = new SingleUserRequestAdapter(sessionStorageMock, "MyCoolOrg"); - final ArrayList retrieved = (ArrayList) Whitebox.getInternalState(adapter, "uri"); - ArrayList expected = new ArrayList() {{ - add("organizations"); - add("MyCoolOrg"); - add("users"); - }}; - - - - // Then - assertSame(adapter.getSessionStorage(), sessionStorageMock); - Assert.assertEquals(retrieved, expected); - } - - @Test(testName = "constructor_with_StringBuilder") - public void should_invoke_non_deprecated_constructor_with_null_organizationId() { - - // When - final SingleUserRequestAdapter adapter = new SingleUserRequestAdapter(sessionStorageMock, (String)null); - final ArrayList retrieved = (ArrayList) Whitebox.getInternalState(adapter, "uri"); - ArrayList expected = new ArrayList() {{ - add("users"); - }}; - - // Then - assertSame(adapter.getSessionStorage(), sessionStorageMock); - Assert.assertEquals(retrieved, expected); - } - - @Test - public void should_set_uri() { - - // When - final SingleUserRequestAdapter adapter = new SingleUserRequestAdapter("Simon", "MyCoolOrg", sessionStorageMock); - final ArrayList retrieved = (ArrayList) Whitebox.getInternalState(adapter, "uri"); - ArrayList expected = new ArrayList() {{ - add("organizations"); - add("MyCoolOrg"); - add("users"); - add("Simon"); - }}; - - // Then - assertSame(adapter.getSessionStorage(), sessionStorageMock); - assertEquals(retrieved, expected); - } - - @Test - public void should_set_user_name() { - - // When - final SingleUserRequestAdapter adapter = new SingleUserRequestAdapter("Simon", null, sessionStorageMock); - final ArrayList retrieved = (ArrayList) Whitebox.getInternalState(adapter, "uri"); - ArrayList expected = new ArrayList() {{ - add("users"); - add("Simon"); - }}; - - // Then - assertSame(adapter.getSessionStorage(), sessionStorageMock); - assertEquals(retrieved, expected); - } - - @Test(expectedExceptions = IllegalArgumentException.class) - public void should_throw_exception_when_params_are_wrong() { - - // When - final SingleUserRequestAdapter adapter = new SingleUserRequestAdapter(null, null, sessionStorageMock); - - // Then - // throw exception - } - - @Test - public void should_return_OperationResult_object() throws Exception { - - // Given - SingleUserRequestAdapter adapterSpy = spy(new SingleUserRequestAdapter("Simon", "MyCoolOrg", - sessionStorageMock)); - doReturn(userJerseyRequestMock).when(adapterSpy, "buildRequest"); - doReturn(operationResultMock).when(userJerseyRequestMock).get(); - - // When - OperationResult retrieved = adapterSpy.get(); - - // Then - verifyPrivate(adapterSpy, times(1)).invoke("buildRequest"); - verify(userJerseyRequestMock, times(1)).get(); - assertSame(retrieved, operationResultMock); - } - - @Test - public void should_retrieve_user() throws Exception { - - // Given - final String userId = "Simon"; - - mockStatic(JerseyRequest.class); - SingleUserRequestAdapter adapterSpy = spy(new SingleUserRequestAdapter(userId, "MyCoolOrg", sessionStorageMock)); - - when(buildRequest(eq(sessionStorageMock), eq(ClientUser.class), eq(new String[]{"organizations", - "MyCoolOrg", "users", userId}), any(DefaultErrorHandler.class))).thenReturn(userJerseyRequestMock); - doReturn(operationResultMock).when(userJerseyRequestMock).get(); - - // When - OperationResult retrieved = adapterSpy.get(userId); - - // Then - verifyStatic(times(1)); - buildRequest(eq(sessionStorageMock), eq(ClientUser.class), eq(new String[]{"organizations", - "MyCoolOrg", "users", userId}), any(DefaultErrorHandler.class)); - assertNotNull(retrieved); - } - - @Test - public void should_retrieve_user_by_id() throws Exception { - - // Given - final String userId = "Simon"; - - mockStatic(JerseyRequest.class); - SingleUserRequestAdapter adapterSpy = spy(new SingleUserRequestAdapter(sessionStorageMock, "MyCoolOrg")); - - when(buildRequest(eq(sessionStorageMock), eq(ClientUser.class), eq(new String[]{"organizations", - "MyCoolOrg", "users", userId}), any(DefaultErrorHandler.class))).thenReturn(userJerseyRequestMock); - doReturn(operationResultMock).when(userJerseyRequestMock).get(); - - // When - OperationResult retrieved = adapterSpy.get(userId); - - // Then - verifyStatic(times(1)); - buildRequest(eq(sessionStorageMock), eq(ClientUser.class), eq(new String[]{"organizations", - "MyCoolOrg", "users", userId}), any(DefaultErrorHandler.class)); - } - - @Test - @SuppressWarnings("unchecked") - public void asyncGet() throws Exception { - - // Given - final AtomicInteger newThreadId = new AtomicInteger(); - final int currentThreadId = (int) Thread.currentThread().getId(); - - SingleUserRequestAdapter adapterSpy = spy(new SingleUserRequestAdapter(sessionStorageMock, null, "Simon")); - - final Callback, Void> callback = spy(new Callback, Void>() { - @Override - public Void execute(OperationResult data) { - newThreadId.set((int) Thread.currentThread().getId()); - synchronized (this) { - this.notify(); - } - return null; - } - }); - - doReturn(userJerseyRequestMock).when(adapterSpy, "buildRequest"); - doReturn(operationResultMock).when(userJerseyRequestMock).get(); - doReturn(null).when(callback).execute(operationResultMock); - - // When - adapterSpy.asyncGet(callback); - - synchronized (callback) { - callback.wait(1000); - } - - // Then - assertNotSame(currentThreadId, newThreadId.get()); - verify(callback, times(1)).execute(operationResultMock); - verify(userJerseyRequestMock, times(1)).get(); - } - - @Test - @SuppressWarnings("unchecked") - public void should_run_method_get_asynchronously() throws Exception { - - // Given - final AtomicInteger newThreadId = new AtomicInteger(); - final int currentThreadId = (int) Thread.currentThread().getId(); - - SingleUserRequestAdapter adapterSpy = spy(new SingleUserRequestAdapter("Simon", null, sessionStorageMock)); - - final Callback, Void> callback = spy(new Callback, Void>() { - @Override - public Void execute(OperationResult data) { - newThreadId.set((int) Thread.currentThread().getId()); - synchronized (this) { - this.notify(); - } - return null; - } - }); - - doReturn(userJerseyRequestMock).when(adapterSpy, "request"); - doReturn(operationResultMock).when(userJerseyRequestMock).get(); - doReturn(null).when(callback).execute(operationResultMock); - - // When - RequestExecution retrieved = adapterSpy.asyncGet(callback, "Simon"); - - // Wait - synchronized (callback) { - callback.wait(1000); - } - - ArrayList uri = (ArrayList) Whitebox.getInternalState(adapterSpy, "uri"); - - // Then - assertNotNull(retrieved); - assertEquals(uri.toString(), "[users, Simon]"); - assertNotSame(currentThreadId, newThreadId.get()); - verify(callback, times(1)).execute(operationResultMock); - verify(userJerseyRequestMock, times(1)).get(); - } - - @Test - @SuppressWarnings("unchecked") - public void should_run_method_asynchronously_when_use_deprecated_constructor() throws Exception { - - // Given - final AtomicInteger newThreadId = new AtomicInteger(); - final int currentThreadId = (int) Thread.currentThread().getId(); - SingleUserRequestAdapter adapterSpy = spy(new SingleUserRequestAdapter(sessionStorageMock, (String)null)); - - final Callback, Void> callback = spy(new Callback, Void>() { - @Override - public Void execute(OperationResult data) { - newThreadId.set((int) Thread.currentThread().getId()); - synchronized (this) { - this.notify(); - } - return null; - } - }); - - doReturn(userJerseyRequestMock).when(adapterSpy, "request"); - doReturn(operationResultMock).when(userJerseyRequestMock).get(); - doReturn(null).when(callback).execute(operationResultMock); - - // When - RequestExecution retrieved = adapterSpy.asyncGet(callback, "Simon"); - - // Wait - synchronized (callback) { - callback.wait(1000); - } - - ArrayList uri = (ArrayList) Whitebox.getInternalState(adapterSpy, "uri"); - - // Then - assertNotNull(retrieved); - assertEquals(uri.toString(), "[users, Simon]"); - assertNotSame(currentThreadId, newThreadId.get()); - verify(callback, times(1)).execute(operationResultMock); - verify(userJerseyRequestMock, times(1)).get(); - } - - @Test - public void asyncCreateOrUpdate_deprecated() throws Exception { - - // Given - final AtomicInteger newThreadId = new AtomicInteger(); - final int currentThreadId = (int) Thread.currentThread().getId(); - SingleUserRequestAdapter adapterSpy = spy(new SingleUserRequestAdapter(sessionStorageMock, null, "Simon")); - - final Callback, Void> callback = spy(new Callback, Void>() { - @Override - public Void execute(OperationResult data) { - newThreadId.set((int) Thread.currentThread().getId()); - synchronized (this) { - this.notify(); - } - return null; - } - }); - - doReturn(userJerseyRequestMock).when(adapterSpy, "buildRequest"); - doReturn(operationResultMock).when(userJerseyRequestMock).put(userMock); - doReturn(null).when(callback).execute(operationResultMock); - - // When - RequestExecution retrieved = adapterSpy.asyncCreateOrUpdate(userMock, callback); - - // Wait - synchronized (callback) { - callback.wait(1000); - } - - // Then - assertNotNull(retrieved); - assertNotSame(currentThreadId, newThreadId.get()); - verify(callback, times(1)).execute(operationResultMock); - verify(userJerseyRequestMock, times(1)).put(userMock); - } - - @Test - public void asyncCreateOrUpdate() throws Exception { - - // Given - final AtomicInteger newThreadId = new AtomicInteger(); - final int currentThreadId = (int) Thread.currentThread().getId(); - SingleUserRequestAdapter adapterSpy = spy(new SingleUserRequestAdapter(sessionStorageMock, (String)null)); - - final Callback, Void> callback = spy(new Callback, Void>() { - @Override - public Void execute(OperationResult data) { - newThreadId.set((int) Thread.currentThread().getId()); - synchronized (this) { - this.notify(); - } - return null; - } - }); - - doReturn(userJerseyRequestMock).when(adapterSpy, "request"); - doReturn(operationResultMock).when(userJerseyRequestMock).put(userMock); - doReturn(null).when(callback).execute(operationResultMock); - - // When - RequestExecution retrieved = adapterSpy.asyncCreateOrUpdate(userMock, callback, "Simon"); - - // Wait - synchronized (callback) { - callback.wait(1000); - } - - ArrayList uri = (ArrayList) Whitebox.getInternalState(adapterSpy, "uri"); - - // Then - assertNotNull(retrieved); - assertEquals(uri.toString(), "[users, Simon]"); - assertNotSame(currentThreadId, newThreadId.get()); - verify(callback, times(1)).execute(operationResultMock); - verify(userJerseyRequestMock, times(1)).put(userMock); - } - - @Test - public void should_delete_user_asynchronously_() throws Exception { - - // Given - final AtomicInteger newThreadId = new AtomicInteger(); - final int currentThreadId = (int) Thread.currentThread().getId(); - final SingleUserRequestAdapter adapterSpy = spy(new SingleUserRequestAdapter(sessionStorageMock, "MyCoolOrg", "Simon")); - - final Callback, Void> callback = spy(new Callback, Void>() { - @Override - public Void execute(OperationResult data) { - newThreadId.set((int) Thread.currentThread().getId()); - synchronized (this) { - this.notify(); - } - return null; - } - }); - - doReturn(userJerseyRequestMock).when(adapterSpy, "buildRequest"); - doReturn(operationResultMock).when(userJerseyRequestMock).delete(); - doReturn(null).when(callback).execute(operationResultMock); - - // When - RequestExecution retrieved = adapterSpy.asyncDelete(callback); - - // Wait - synchronized (callback) { - callback.wait(1000); - } - - // Then - assertNotNull(retrieved); - assertNotSame(currentThreadId, newThreadId.get()); - verify(callback, times(1)).execute(operationResultMock); - verify(userJerseyRequestMock, times(1)).delete(); - } - - @Test - public void should_delete_user_asynchronously() throws Exception { - - // Given - final AtomicInteger newThreadId = new AtomicInteger(); - final int currentThreadId = (int) Thread.currentThread().getId(); - final SingleUserRequestAdapter adapterSpy = spy(new SingleUserRequestAdapter(sessionStorageMock, "MyCoolOrg")); - - final Callback, Void> callback = spy(new Callback, Void>() { - @Override - public Void execute(OperationResult data) { - newThreadId.set((int) Thread.currentThread().getId()); - synchronized (this) { - this.notify(); - } - return null; - } - }); - - doReturn(userJerseyRequestMock).when(adapterSpy, "request"); - doReturn(operationResultMock).when(userJerseyRequestMock).delete(); - doReturn(null).when(callback).execute(operationResultMock); - - // When - RequestExecution retrieved = adapterSpy.asyncDelete(callback, "Simon"); - - // Wait - synchronized (callback) { - callback.wait(1000); - } - - ArrayList uri = (ArrayList) Whitebox.getInternalState(adapterSpy, "uri"); - - // Then - assertNotNull(retrieved); - assertNotSame(currentThreadId, newThreadId.get()); - assertEquals(uri.toString(), "[organizations, MyCoolOrg, users, Simon]"); - verify(callback, times(1)).execute(operationResultMock); - verify(userJerseyRequestMock, times(1)).delete(); - } - - /** - * Test for {@link com.jaspersoft.jasperserver.jaxrs.client.apiadapters.authority.users.SingleUserRequestAdapter#delete()} and for {@link com.jaspersoft.jasperserver.jaxrs.client.apiadapters.authority.users.SingleUserRequestAdapter#buildRequest} - */ - @Test - public void should_delete_user_() { - - // Given - mockStatic(JerseyRequest.class); - when(buildRequest(eq(sessionStorageMock), eq(ClientUser.class), eq(new String[]{"organizations", "MyCoolOrg", "users", "Simon"}), any(DefaultErrorHandler.class))).thenReturn(userJerseyRequestMock); - doReturn(operationResultMock).when(userJerseyRequestMock).delete(); - - SingleUserRequestAdapter adapterSpy = spy(new SingleUserRequestAdapter(sessionStorageMock, "MyCoolOrg", "Simon")); - - // When - OperationResult retrieved = adapterSpy.delete(); - - // Then - verifyStatic(times(1)); - buildRequest(eq(sessionStorageMock), eq(ClientUser.class), eq(new String[]{"organizations", "MyCoolOrg", "users", "Simon"}), any(DefaultErrorHandler.class)); - verify(userJerseyRequestMock, times(1)).delete(); - assertNotNull(retrieved); - } - - @Test - /** - * Test for {@link com.jaspersoft.jasperserver.jaxrs.client.apiadapters.authority.users.SingleUserRequestAdapter#createOrUpdate(com.jaspersoft.jasperserver.dto.authority.ClientUser)} and for {@link com.jaspersoft.jasperserver.jaxrs.client.apiadapters.authority.users.SingleUserRequestAdapter#buildRequest} - */ - public void test_update_user() { - - // Given - mockStatic(JerseyRequest.class); - when(buildRequest(eq(sessionStorageMock), eq(ClientUser.class), eq(new String[]{"organizations", "MyCoolOrg", "users", "Simon"}), any(DefaultErrorHandler.class))).thenReturn(userJerseyRequestMock); - doReturn(operationResultMock).when(userJerseyRequestMock).put(userMock); - - SingleUserRequestAdapter adapterSpy = spy(new SingleUserRequestAdapter(sessionStorageMock, "MyCoolOrg", "Simon")); - - // When - OperationResult retrieved = adapterSpy.createOrUpdate(userMock); - - // Then - verifyStatic(times(1)); - buildRequest(eq(sessionStorageMock), eq(ClientUser.class), eq(new String[]{"organizations", "MyCoolOrg", "users", "Simon"}), any(DefaultErrorHandler.class)); - verify(userJerseyRequestMock, times(1)).put(userMock); - assertNotNull(retrieved); - } - - @Test - public void should_update_user() throws Exception { - - /* Given */ - mockStatic(JerseyRequest.class); - when(buildRequest( - eq(sessionStorageMock), - eq(ClientUser.class), - eq(new String[]{"organizations", "MyCoolOrg", "users", "Simon"}), - any(DefaultErrorHandler.class))).thenReturn(userJerseyRequestMock); - - SingleUserRequestAdapter adapterSpy = spy(new SingleUserRequestAdapter(sessionStorageMock, "MyCoolOrg")); - - doReturn(operationResultMock).when(userJerseyRequestMock).put(userMock); - doReturn("Simon").when(userMock).getUsername(); - doReturn("MyCoolOrg").when(userMock).getTenantId(); - - /* Then */ - OperationResult retrieved = adapterSpy.updateOrCreate(userMock); - - /* Then */ - assertNotNull(retrieved); - verify(userMock, times(1)).getUsername(); - } - - @Test - public void should_return_operation_result_when_there_is_no_org() throws Exception { - - /* Given */ - mockStatic(JerseyRequest.class); - when(buildRequest( - eq(sessionStorageMock), - eq(ClientUser.class), - eq(new String[]{"organizations", "MyCoolOrg", "users", "Simon"}), - any(DefaultErrorHandler.class))).thenReturn(userJerseyRequestMock); - - SingleUserRequestAdapter adapterSpy = spy(new SingleUserRequestAdapter(sessionStorageMock, (String)null)); - - doReturn(operationResultMock).when(userJerseyRequestMock).put(userMock); - doReturn("Simon").when(userMock).getUsername(); - doReturn("MyCoolOrg").when(userMock).getTenantId(); - - /* When */ - OperationResult retrieved = adapterSpy.updateOrCreate(userMock); - - /* Then */ - assertNotNull(retrieved); - verify(userMock, times(1)).getUsername(); - verify(userMock, times(2)).getTenantId(); - } - - @Test - public void should_delete_user() { - - /* Given */ - mockStatic(JerseyRequest.class); - when(buildRequest( - eq(sessionStorageMock), - eq(ClientUser.class), - eq(new String[]{"organizations", "MyCoolOrg", "users", "Simon"}), - any(DefaultErrorHandler.class))).thenReturn(userJerseyRequestMock); - - SingleUserRequestAdapter adapterSpy = spy(new SingleUserRequestAdapter(sessionStorageMock, "MyCoolOrg")); - doReturn(operationResultMock).when(userJerseyRequestMock).delete(); - doReturn("Simon").when(userMock).getUsername(); - - /* When */ - OperationResult retrieved = adapterSpy.delete(userMock); - - /* Then */ - assertNotNull(retrieved); - verify(userMock, times(1)).getUsername(); - } - - @Test - public void should_delete_user_by_string_user_name() { - - /* Given */ - mockStatic(JerseyRequest.class); - when(buildRequest( - eq(sessionStorageMock), - eq(ClientUser.class), - eq(new String[]{"organizations", "MyCoolOrg", "users", "Simon"}), - any(DefaultErrorHandler.class))).thenReturn(userJerseyRequestMock); - - SingleUserRequestAdapter adapterSpy = spy(new SingleUserRequestAdapter(sessionStorageMock, "MyCoolOrg")); - doReturn(operationResultMock).when(userJerseyRequestMock).delete(); - - /* When */ - OperationResult retrieved = adapterSpy.delete("Simon"); - - /* Then */ - assertNotNull(retrieved); - } - - @AfterMethod - public void after() { - reset(sessionStorageMock, userJerseyRequestMock, operationResultMock, userMock); - } -} \ No newline at end of file diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/users/SingleUserRequestAdapterTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/users/SingleUserRequestAdapterTest.java index 6afaf7e6..a088c214 100644 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/users/SingleUserRequestAdapterTest.java +++ b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/users/SingleUserRequestAdapterTest.java @@ -18,8 +18,9 @@ import org.testng.annotations.Test; import static com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest.buildRequest; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.reset; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -139,7 +140,7 @@ public void should_invoke_private_method() { // Then assertNotNull(retrieved); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); buildRequest(eq(sessionStorageMock), eq(ClientUser.class), eq(new String[]{"organizations", "myOrg", "users", "Simon"}), any(DefaultErrorHandler.class)); verify(userJerseyRequestMock, times(1)).delete(); @@ -162,7 +163,7 @@ public void should_refuse_wrong_organization_and_get_user() { // Then assertNotNull(retrieved); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); buildRequest(eq(sessionStorageMock), eq(ClientUser.class), eq(new String[]{"users", "Simon"}), any(DefaultErrorHandler.class)); verify(userJerseyRequestMock, times(1)).get(); @@ -190,7 +191,7 @@ public Void execute(OperationResult data) { doReturn(userJerseyRequestMock).when(adapterSpy, "buildRequest"); doReturn(operationResultMock).when(userJerseyRequestMock).get(); - doReturn(null).when(callback).execute(operationResultMock); + doNothing().when(callback).execute(operationResultMock); // When RequestExecution retrieved = adapterSpy.asyncGet(callback); @@ -227,7 +228,7 @@ public Void execute(OperationResult data) { doReturn(userJerseyRequestMock).when(adapterSpy, "buildRequest"); doReturn(operationResultMock).when(userJerseyRequestMock).put(userMock); - doReturn(null).when(callback).execute(operationResultMock); + doNothing().when(callback).execute(operationResultMock); // When RequestExecution retrieved = adapterSpy.asyncCreateOrUpdate(userMock, callback); @@ -265,7 +266,7 @@ public Void execute(OperationResult data) { doReturn(userJerseyRequestMock).when(adapterSpy, "buildRequest"); doReturn(operationResultMock).when(userJerseyRequestMock).delete(); - doReturn(null).when(callback).execute(operationResultMock); + doNothing().when(callback).execute(operationResultMock); // When RequestExecution retrieved = adapterSpy.asyncDelete(callback); diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/users/UsersServiceTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/users/UsersServiceTest.java index 0e43be20..80b849bb 100644 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/users/UsersServiceTest.java +++ b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/users/UsersServiceTest.java @@ -5,16 +5,15 @@ import com.jaspersoft.jasperserver.jaxrs.client.core.SessionStorage; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.internal.util.reflection.Whitebox; -import org.powermock.api.mockito.PowerMockito; +import org.powermock.reflect.Whitebox; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.testng.PowerMockTestCase; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import static org.mockito.Matchers.anyString; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.reset; import static org.mockito.MockitoAnnotations.initMocks; @@ -179,69 +178,12 @@ public void should_return_BatchUsersRequestAdapter() throws Exception { anyString()).thenReturn(batchUsersRequestAdapterMock); // When - BatchUsersRequestAdapter retrieved = service.allUsers(); + BatchUsersRequestAdapter retrieved = service.forOrganization(ORGANIZATION_ID).allUsers(); // Then assertNotNull(retrieved); assertSame(retrieved, batchUsersRequestAdapterMock); } - /** - * @deprecated Replaced by {@link UsersServiceTest#should_set_organization_id()}. - */ - @Test - public void should_set_org_id (){ - UsersService service = new UsersService(sessionStorageMock); - UsersService retrieved = service.organization(ORGANIZATION_ID); - - assertSame(retrieved, service); - assertEquals(Whitebox.getInternalState(service, "organizationId"), ORGANIZATION_ID); - } - - /** - * @deprecated Replaced by {@link UsersServiceTest#should_throw_exception_when_organization_name_is_empty()}. - */ - @Test(expectedExceptions = IllegalArgumentException.class) - public void should_throw_exception_when_not_specified_ord_name (){ - UsersService service = new UsersService(sessionStorageMock); - UsersService retrieved = service.organization(""); - } - -/** - * @deprecated Replaced by {@link UsersServiceTest#should_return_proper_user_adapter_when_invoke_user_method_with_string()}. - */ - @Test - public void should_return_proper_user_adapter_when_invoke_username_method() throws Exception { - UsersService service = new UsersService(sessionStorageMock); - PowerMockito.whenNew(SingleUserRequestAdapter.class).withArguments(sessionStorageMock, null, "Simon") - .thenReturn(singleUserRequestAdapterMock); - - SingleUserRequestAdapter retrieved = service.username("Simon"); - assertSame(retrieved, singleUserRequestAdapterMock); - //verifyNew(SingleUserRequestAdapter.class); - } - - /** - * @deprecated Replaced by {@link UsersServiceTest#should_throw_exception_when_user_name_is_empty()}. - */ - @Test(expectedExceptions = IllegalArgumentException.class) - public void should_throw_exception_when_username_not_specified() { - UsersService service = new UsersService(sessionStorageMock); - service.username(""); - } - - /** - * @deprecated Replaced by {@link com.jaspersoft.jasperserver.jaxrs.client.apiadapters.authority.users.UsersServiceTest#should_return_proper_user_adapter_when_invoke_user_method_with_string()}. - */ - @Test - public void should_return_proper_user_adapter_() throws Exception { - UsersService service = new UsersService(sessionStorageMock); - PowerMockito.whenNew(SingleUserRequestAdapter.class).withArguments(eq(sessionStorageMock), - anyString()).thenReturn(singleUserRequestAdapterMock); - SingleUserRequestAdapter retrieved = service.user(); - assertSame(retrieved, singleUserRequestAdapterMock); - //verifyNew(SingleUserRequestAdapter.class); - } - @AfterMethod public void after() { reset(sessionStorageMock, singleUserRequestAdapterMock, clientUserMock, batchUsersRequestAdapterMock); diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/bundles/BundlesServiceTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/bundles/BundlesServiceTest.java index df725131..f95dcf44 100644 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/bundles/BundlesServiceTest.java +++ b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/bundles/BundlesServiceTest.java @@ -11,17 +11,17 @@ import javax.ws.rs.core.MediaType; import org.codehaus.jettison.json.JSONObject; import org.mockito.Mock; -import org.mockito.internal.util.reflection.Whitebox; +import org.powermock.reflect.Whitebox; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.testng.PowerMockTestCase; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyString; -import static org.mockito.Matchers.eq; -import static org.mockito.Matchers.isA; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.ArgumentMatchers.isA; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.never; import static org.mockito.Mockito.reset; @@ -73,7 +73,7 @@ public void should_return_proper_bundles_for_default_locale() throws Exception { verify(requestMock).addParam("expanded", "true"); verify(requestMock).addHeader("Accept-Language", defaultLocale.replace('_', '-')); verify(requestMock).get(); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); JerseyRequest.buildRequest(eq(sessionStorageMock), eq(new GenericType>>() { }), eq(new String[]{"bundles"}), any(DefaultErrorHandler.class)); Locale locale = (Locale) Whitebox.getInternalState(service, "locale"); @@ -99,7 +99,7 @@ public void should_return_proper_bundles_for_string_locale() throws Exception { verify(requestMock).addParam("expanded", "true"); verify(requestMock).addHeader("Accept-Language", "de"); verify(requestMock).get(); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); JerseyRequest.buildRequest(eq(sessionStorageMock), eq(new GenericType>>() { }), eq(new String[]{"bundles"}), any(DefaultErrorHandler.class)); Locale locale = (Locale) Whitebox.getInternalState(service, "locale"); @@ -125,7 +125,7 @@ public void should_return_proper_bundles_for_locale() throws Exception { verify(requestMock).addParam("expanded", "true"); verify(requestMock).addHeader("Accept-Language", "de"); verify(requestMock).get(); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); JerseyRequest.buildRequest(eq(sessionStorageMock), eq(new GenericType>>() { }), eq(new String[]{"bundles"}), any(DefaultErrorHandler.class)); Locale locale = (Locale) Whitebox.getInternalState(service, "locale"); @@ -149,7 +149,7 @@ public void should_return_proper_bundles_by_name_for_string_locale() throws Exce verify(requestMock,never()).addParam("expanded", "true"); verify(requestMock).addHeader("Accept-Language", "de"); verify(requestMock).get(); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); JerseyRequest.buildRequest(eq(sessionStorageMock), eq(new GenericType>() { }), eq(new String[]{"bundles", "jasperserver_messages"}), any(DefaultErrorHandler.class)); } @@ -171,7 +171,7 @@ public void should_return_proper_bundles_by_name_for_locale() throws Exception { verify(requestMock,never()).addParam("expanded", "true"); verify(requestMock).addHeader("Accept-Language", "en-US"); verify(requestMock).get(); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); JerseyRequest.buildRequest(eq(sessionStorageMock), eq(new GenericType>() { }), eq(new String[]{"bundles", "jasperserver_messages"}), any(DefaultErrorHandler.class)); } @@ -195,7 +195,7 @@ public void should_return_proper_bundles_by_name_for_default_locale() throws Exc verify(requestMock,never()).addParam("expanded", "true"); verify(requestMock).addHeader("Accept-Language", Locale.getDefault().toString().replace('_', '-')); verify(requestMock).get(); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); JerseyRequest.buildRequest(eq(sessionStorageMock), eq(new GenericType>() { }), eq(new String[]{"bundles", "jasperserver_messages"}), any(DefaultErrorHandler.class)); } @@ -217,7 +217,7 @@ public void should_not_invoke_adding_language_by_empty_locale() throws Exception verify(requestMock,never()).addParam("expanded", "true"); verify(requestMock, never()).addHeader("Accept-Language", Locale.getDefault().toString().replace('_', '-')); verify(requestMock).get(); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); JerseyRequest.buildRequest(eq(sessionStorageMock), eq(new GenericType>() { }), eq(new String[]{"bundles", "jasperserver_messages"}), any(DefaultErrorHandler.class)); } @@ -260,7 +260,7 @@ public void should_locale_if_authentication_locale_is_different() throws Excepti } @AfterMethod - public void afetr() { + public void after() { reset(sessionStorageMock, requestMock, operationResultMock); } } \ No newline at end of file diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/connections/ConnectionsServiceTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/connections/ConnectionsServiceTest.java deleted file mode 100644 index 43f89465..00000000 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/connections/ConnectionsServiceTest.java +++ /dev/null @@ -1,120 +0,0 @@ -package com.jaspersoft.jasperserver.jaxrs.client.apiadapters.connections; - -import com.jaspersoft.jasperserver.dto.connection.metadata.TableMetadata; -import com.jaspersoft.jasperserver.dto.resources.ClientCustomDataSource; -import com.jaspersoft.jasperserver.jaxrs.client.core.SessionStorage; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.testng.PowerMockTestCase; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.reset; -import static org.mockito.Mockito.times; -import static org.powermock.api.mockito.PowerMockito.verifyNew; -import static org.powermock.api.mockito.PowerMockito.whenNew; -import static org.testng.Assert.assertSame; - -/** - *

- *

- * - * @author tetiana.iefimenko - * @version $Id$ - * @see - */ -@PrepareForTest({ConnectionsService.class}) -public class ConnectionsServiceTest extends PowerMockTestCase { - public static final String SOME_UU_ID = "someUuId"; - public static final String SOME_MIME_TYPE = "someMimeType"; - public static final String METADATA_MIME_TYPE = "someMetadataMimeType"; - private SessionStorage sessionStorageMock; - private SingleConnectionsAdapter singleConnectionAdapterMock; - - @BeforeMethod - public void before() { - sessionStorageMock = mock(SessionStorage.class); - singleConnectionAdapterMock = mock(SingleConnectionsAdapter.class); - - } - - @AfterMethod - public void after() { - reset(sessionStorageMock, singleConnectionAdapterMock); - } - - @Test - public void should_pass_session_storage_to_parent_adapter() { - ConnectionsService attributesService = new ConnectionsService(sessionStorageMock); - SessionStorage retrieved = attributesService.getSessionStorage(); - assertSame(retrieved, sessionStorageMock); - } - - @Test(expectedExceptions = IllegalArgumentException.class) - public void should_throw_an_exception_when_sessionStorage_is_null() { - // When - new ConnectionsService(null); - // Then - // should be thrown an exception - } - - - @Test - public void should_return_proper_SingleConnectionAdapter_instance_by_uuid() throws Exception { - - // Given - whenNew(SingleConnectionsAdapter.class) - .withArguments(sessionStorageMock, Object.class, SOME_MIME_TYPE, SOME_UU_ID) - .thenReturn(singleConnectionAdapterMock); - - ConnectionsService connectionsService = new ConnectionsService(sessionStorageMock); - - // When - SingleConnectionsAdapter retrieved = connectionsService.connection(Object.class, SOME_MIME_TYPE, SOME_UU_ID); - - // Then - assertSame(singleConnectionAdapterMock, retrieved); - verifyNew(SingleConnectionsAdapter.class, times(1)) - .withArguments(sessionStorageMock, Object.class, SOME_MIME_TYPE, SOME_UU_ID); - } - - @Test - public void should_return_proper_SingleConnectionAdapter_instance_by_class_mimeType_uuid() throws Exception { - - // Given - whenNew(SingleConnectionsAdapter.class) - .withArguments(sessionStorageMock, ClientCustomDataSource.class, SOME_MIME_TYPE, SOME_UU_ID) - .thenReturn(singleConnectionAdapterMock); - - ConnectionsService connectionsService = new ConnectionsService(sessionStorageMock); - - // When - SingleConnectionsAdapter retrieved = connectionsService.connection(ClientCustomDataSource.class, SOME_MIME_TYPE, SOME_UU_ID); - - // Then - assertSame(singleConnectionAdapterMock, retrieved); - verifyNew(SingleConnectionsAdapter.class, times(1)) - .withArguments(sessionStorageMock, ClientCustomDataSource.class, SOME_MIME_TYPE, SOME_UU_ID); - } - - @Test - public void should_return_proper_SingleConnectionAdapter_instance_by_connection_metadata_class_mimeType_uuid() throws Exception { - - // Given - whenNew(SingleConnectionsAdapter.class) - .withArguments(sessionStorageMock, SOME_UU_ID, TableMetadata.class, METADATA_MIME_TYPE) - .thenReturn(singleConnectionAdapterMock); - - ConnectionsService connectionsService = new ConnectionsService(sessionStorageMock); - - // When - SingleConnectionsAdapter retrieved = connectionsService. - connection(SOME_UU_ID, TableMetadata.class, METADATA_MIME_TYPE); - - // Then - assertSame(singleConnectionAdapterMock, retrieved); - verifyNew(SingleConnectionsAdapter.class, times(1)) - .withArguments(sessionStorageMock, SOME_UU_ID, TableMetadata.class, METADATA_MIME_TYPE); - } -} \ No newline at end of file diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/connections/SingleConnectionsAdapterTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/connections/SingleConnectionsAdapterTest.java deleted file mode 100644 index dab5f5a4..00000000 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/connections/SingleConnectionsAdapterTest.java +++ /dev/null @@ -1,513 +0,0 @@ -package com.jaspersoft.jasperserver.jaxrs.client.apiadapters.connections; - -import com.jaspersoft.jasperserver.dto.connection.FtpConnection; -import com.jaspersoft.jasperserver.dto.connection.LfsConnection; -import com.jaspersoft.jasperserver.dto.connection.metadata.TableMetadata; -import com.jaspersoft.jasperserver.dto.resources.ClientCustomDataSource; -import com.jaspersoft.jasperserver.dto.resources.ClientJdbcDataSource; -import com.jaspersoft.jasperserver.dto.resources.ClientJndiJdbcDataSource; -import com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest; -import com.jaspersoft.jasperserver.jaxrs.client.core.RestClientConfiguration; -import com.jaspersoft.jasperserver.jaxrs.client.core.SessionStorage; -import com.jaspersoft.jasperserver.jaxrs.client.core.enums.ContextMediaTypes; -import com.jaspersoft.jasperserver.jaxrs.client.core.enums.MimeType; -import com.jaspersoft.jasperserver.jaxrs.client.core.exceptions.MandatoryParameterNotFoundException; -import com.jaspersoft.jasperserver.jaxrs.client.core.exceptions.handling.DefaultErrorHandler; -import com.jaspersoft.jasperserver.jaxrs.client.core.operationresult.OperationResult; -import org.mockito.Mock; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.testng.PowerMockTestCase; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.reset; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import static org.mockito.MockitoAnnotations.initMocks; -import static org.powermock.api.mockito.PowerMockito.doReturn; -import static org.powermock.api.mockito.PowerMockito.mockStatic; -import static org.powermock.api.mockito.PowerMockito.verifyStatic; -import static org.testng.Assert.assertSame; - -/** - *

- *

- * - * @author tetiana.iefimenko - * @version $Id$ - * @see - */ -@SuppressWarnings("unchecked") -@PrepareForTest({JerseyRequest.class}) -public class SingleConnectionsAdapterTest extends PowerMockTestCase { - - public static final String TEST_UUID = "someUuId"; - public static final String CONNECTIONS_URI = "connections"; - @Mock - private SessionStorage sessionStorageMock; - @Mock - private RestClientConfiguration configurationMock; - @Mock - private JerseyRequest ftpConnectionJerseyRequestMock; - @Mock - private JerseyRequest jerseyRequestMock; - @Mock - private JerseyRequest lfsConnectionJerseyRequestMock; - @Mock - private JerseyRequest customDataSourceJerseyRequestMock; - @Mock - private JerseyRequest jndiJdbcDataSourceJerseyRequestMock; - @Mock - private JerseyRequest jdbcDataSourceJerseyRequestMock; - @Mock - private JerseyRequest tableMetadataRequestMock; - @Mock - private OperationResult operationResultMock; - @Mock - private OperationResult ftpConnectionOperationResultMock; - @Mock - private OperationResult lfsConnectionOperationResultMock; - @Mock - private OperationResult customDataSourceOperationResultMock; - @Mock - private OperationResult jndiDataSourceOperationResultMock; - @Mock - private OperationResult jdbcDataSourceOperationResultMock; - @Mock - private OperationResult tableMetadataOperationResultMock; - - private ConnectionsService connectionsService; - - @BeforeMethod - public void before() { - initMocks(this); - connectionsService = new ConnectionsService(sessionStorageMock); - } - - @AfterMethod - public void after() { - reset(sessionStorageMock - , configurationMock - , jerseyRequestMock - , ftpConnectionJerseyRequestMock - , lfsConnectionJerseyRequestMock - , customDataSourceJerseyRequestMock - , jndiJdbcDataSourceJerseyRequestMock - , jdbcDataSourceJerseyRequestMock - , tableMetadataRequestMock - , operationResultMock - , ftpConnectionOperationResultMock - , lfsConnectionOperationResultMock - , customDataSourceOperationResultMock - , jndiDataSourceOperationResultMock - , jdbcDataSourceOperationResultMock - , tableMetadataOperationResultMock); - } - - @Test - public void should_return_proper_ftp_connection_operationResult_when_get() throws Exception { - //when - mockStatic(JerseyRequest.class); - when(JerseyRequest.buildRequest(eq(sessionStorageMock) - , eq(FtpConnection.class) - , eq(new String[]{CONNECTIONS_URI, TEST_UUID}) - , any(DefaultErrorHandler.class))).thenReturn(ftpConnectionJerseyRequestMock); - - doReturn(ftpConnectionOperationResultMock).when(ftpConnectionJerseyRequestMock).get(); - - OperationResult connection = connectionsService - .connection(FtpConnection.class, "someMiMeType", TEST_UUID) - .get(); - //then - assertSame(ftpConnectionOperationResultMock, connection); - verifyStatic(times(1)); - JerseyRequest.buildRequest(eq(sessionStorageMock) - , eq(FtpConnection.class) - , eq(new String[]{CONNECTIONS_URI, TEST_UUID}) - , any(DefaultErrorHandler.class)); - verify(ftpConnectionJerseyRequestMock).get(); - } - - @Test - public void should_return_proper_ftp_connection_operationResult_when_create() throws Exception { - //when - mockStatic(JerseyRequest.class); - when(JerseyRequest.buildRequest(eq(sessionStorageMock) - , eq(FtpConnection.class) - , eq(new String[]{CONNECTIONS_URI}) - , any(DefaultErrorHandler.class))).thenReturn(ftpConnectionJerseyRequestMock); - - doReturn(configurationMock).when(sessionStorageMock).getConfiguration(); - doReturn(MimeType.JSON).when(configurationMock).getContentMimeType(); - doReturn(ftpConnectionJerseyRequestMock).when(ftpConnectionJerseyRequestMock).setContentType(ContextMediaTypes.FTP_JSON); - doReturn(ftpConnectionOperationResultMock).when(ftpConnectionJerseyRequestMock).post(any(FtpConnection.class)); - - OperationResult connection = connectionsService - .connection(FtpConnection.class, ContextMediaTypes.FTP_TYPE, TEST_UUID) - .create(new FtpConnection()); - //then - assertSame(ftpConnectionOperationResultMock, connection); - verifyStatic(times(1)); - JerseyRequest.buildRequest(eq(sessionStorageMock) - , eq(FtpConnection.class) - , eq(new String[]{CONNECTIONS_URI}) - , any(DefaultErrorHandler.class)); - verify(sessionStorageMock).getConfiguration(); - verify(configurationMock).getContentMimeType(); - verify(ftpConnectionJerseyRequestMock).setContentType(ContextMediaTypes.FTP_JSON); - verify(ftpConnectionJerseyRequestMock).post(any(FtpConnection.class)); - } - - @Test - public void should_return_proper_ftp_connection_operationResult_when_update() throws Exception { - //when - mockStatic(JerseyRequest.class); - when(JerseyRequest.buildRequest(eq(sessionStorageMock) - , eq(FtpConnection.class) - , eq(new String[]{CONNECTIONS_URI, TEST_UUID}) - , any(DefaultErrorHandler.class))).thenReturn(ftpConnectionJerseyRequestMock); - - doReturn(configurationMock).when(sessionStorageMock).getConfiguration(); - doReturn(MimeType.JSON).when(configurationMock).getContentMimeType(); - doReturn(ftpConnectionJerseyRequestMock).when(ftpConnectionJerseyRequestMock).setContentType(ContextMediaTypes.FTP_JSON); - doReturn(ftpConnectionOperationResultMock).when(ftpConnectionJerseyRequestMock).put(any(FtpConnection.class)); - - OperationResult connection = connectionsService - .connection(FtpConnection.class, ContextMediaTypes.FTP_TYPE, TEST_UUID) - .update(new FtpConnection()); - //then - assertSame(ftpConnectionOperationResultMock, connection); - verifyStatic(times(1)); - JerseyRequest.buildRequest(eq(sessionStorageMock) - , eq(FtpConnection.class) - , eq(new String[]{CONNECTIONS_URI, TEST_UUID}) - , any(DefaultErrorHandler.class)); - verify(sessionStorageMock).getConfiguration(); - verify(configurationMock).getContentMimeType(); - verify(ftpConnectionJerseyRequestMock).setContentType(ContextMediaTypes.FTP_JSON); - verify(ftpConnectionJerseyRequestMock).put(any(FtpConnection.class)); - } - - @Test - public void should_return_proper_ftp_connection_operationResult_when_delete() throws Exception { - //when - mockStatic(JerseyRequest.class); - when(JerseyRequest.buildRequest(eq(sessionStorageMock) - , eq(Object.class) - , eq(new String[]{CONNECTIONS_URI, TEST_UUID}) - , any(DefaultErrorHandler.class))).thenReturn(jerseyRequestMock); - - doReturn(operationResultMock).when(jerseyRequestMock).delete(); - - OperationResult connection = connectionsService - .connection(TEST_UUID) - .delete(); - //then - assertSame(operationResultMock, connection); - verifyStatic(times(1)); - JerseyRequest.buildRequest(eq(sessionStorageMock) - , eq(Object.class) - , eq(new String[]{CONNECTIONS_URI, TEST_UUID}) - , any(DefaultErrorHandler.class)); - verify(jerseyRequestMock).delete(); - } - - @Test - public void should_return_proper_local_file_system_connection_operationResult_when_get() throws Exception { - //when - mockStatic(JerseyRequest.class); - when(JerseyRequest.buildRequest(eq(sessionStorageMock) - , eq(LfsConnection.class) - , eq(new String[]{CONNECTIONS_URI, TEST_UUID}) - , any(DefaultErrorHandler.class))).thenReturn(lfsConnectionJerseyRequestMock); - - doReturn(lfsConnectionOperationResultMock).when(lfsConnectionJerseyRequestMock).get(); - - OperationResult connection = connectionsService - .connection(LfsConnection.class, ContextMediaTypes.LOCAL_FILE_SYSTEM_TYPE, TEST_UUID) - .get(); - //then - assertSame(lfsConnectionOperationResultMock, connection); - verifyStatic(times(1)); - JerseyRequest.buildRequest(eq(sessionStorageMock) - , eq(LfsConnection.class) - , eq(new String[]{CONNECTIONS_URI, TEST_UUID}) - , any(DefaultErrorHandler.class)); - verify(lfsConnectionJerseyRequestMock).get(); - } - - @Test - public void should_return_proper_local_file_system_connection_operationResult_when_create() throws Exception { - //when - mockStatic(JerseyRequest.class); - when(JerseyRequest.buildRequest(eq(sessionStorageMock) - , eq(LfsConnection.class) - , eq(new String[]{CONNECTIONS_URI}) - , any(DefaultErrorHandler.class))).thenReturn(lfsConnectionJerseyRequestMock); - - doReturn(configurationMock).when(sessionStorageMock).getConfiguration(); - doReturn(MimeType.JSON).when(configurationMock).getContentMimeType(); - doReturn(lfsConnectionJerseyRequestMock).when(lfsConnectionJerseyRequestMock).setContentType(ContextMediaTypes.LOCAL_FILE_SYSTEM_JSON); - doReturn(lfsConnectionOperationResultMock).when(lfsConnectionJerseyRequestMock).post(any(LfsConnection.class)); - - OperationResult connection = connectionsService - .connection(LfsConnection.class, ContextMediaTypes.LOCAL_FILE_SYSTEM_TYPE, TEST_UUID) - .create(new LfsConnection()); - //then - assertSame(lfsConnectionOperationResultMock, connection); - verifyStatic(times(1)); - JerseyRequest.buildRequest(eq(sessionStorageMock) - , eq(LfsConnection.class) - , eq(new String[]{CONNECTIONS_URI}) - , any(DefaultErrorHandler.class)); - verify(sessionStorageMock).getConfiguration(); - verify(configurationMock).getContentMimeType(); - verify(lfsConnectionJerseyRequestMock).setContentType(ContextMediaTypes.LOCAL_FILE_SYSTEM_JSON); - verify(lfsConnectionJerseyRequestMock).post(any(LfsConnection.class)); - - } - - @Test - public void should_return_proper_custom_data_source_connection_operationResult_when_get() throws Exception { - //when - mockStatic(JerseyRequest.class); - when(JerseyRequest.buildRequest(eq(sessionStorageMock) - , eq(ClientCustomDataSource.class) - , eq(new String[]{CONNECTIONS_URI, TEST_UUID}) - , any(DefaultErrorHandler.class))).thenReturn(customDataSourceJerseyRequestMock); - - doReturn(customDataSourceOperationResultMock).when(customDataSourceJerseyRequestMock).get(); - - OperationResult connection = connectionsService - .connection(ClientCustomDataSource.class, ContextMediaTypes.CUSTOM_DATA_SOURCE_TYPE, TEST_UUID) - .get(); - //then - assertSame(customDataSourceOperationResultMock, connection); - verifyStatic(times(1)); - JerseyRequest.buildRequest(eq(sessionStorageMock) - , eq(ClientCustomDataSource.class) - , eq(new String[]{CONNECTIONS_URI, TEST_UUID}) - , any(DefaultErrorHandler.class)); - verify(customDataSourceJerseyRequestMock).get(); - - } - - @Test - public void should_return_proper_custom_data_source_connection_operationResult_when_create() throws Exception { - //when - mockStatic(JerseyRequest.class); - when(JerseyRequest.buildRequest(eq(sessionStorageMock) - , eq(ClientCustomDataSource.class) - , eq(new String[]{CONNECTIONS_URI}) - , any(DefaultErrorHandler.class))).thenReturn(customDataSourceJerseyRequestMock); - - doReturn(configurationMock).when(sessionStorageMock).getConfiguration(); - doReturn(MimeType.JSON).when(configurationMock).getContentMimeType(); - doReturn(customDataSourceJerseyRequestMock).when(customDataSourceJerseyRequestMock).setContentType(ContextMediaTypes.CUSTOM_DATA_SOURCE_JSON); - doReturn(customDataSourceOperationResultMock).when(customDataSourceJerseyRequestMock).post(any(ClientCustomDataSource.class)); - - OperationResult connection = connectionsService - .connection(ClientCustomDataSource.class, ContextMediaTypes.CUSTOM_DATA_SOURCE_TYPE, TEST_UUID) - .create(new ClientCustomDataSource()); - //then - assertSame(customDataSourceOperationResultMock, connection); - verifyStatic(times(1)); - JerseyRequest.buildRequest(eq(sessionStorageMock) - , eq(ClientCustomDataSource.class) - , eq(new String[]{CONNECTIONS_URI}) - , any(DefaultErrorHandler.class)); - verify(sessionStorageMock).getConfiguration(); - verify(configurationMock).getContentMimeType(); - verify(customDataSourceJerseyRequestMock).setContentType(ContextMediaTypes.CUSTOM_DATA_SOURCE_JSON); - verify(customDataSourceJerseyRequestMock).post(any(ClientCustomDataSource.class)); - - } - - @Test - public void should_return_proper_jndi_connection_operationResult_when_get() throws Exception { - //when - mockStatic(JerseyRequest.class); - when(JerseyRequest.buildRequest(eq(sessionStorageMock) - , eq(ClientJndiJdbcDataSource.class) - , eq(new String[]{CONNECTIONS_URI, TEST_UUID}) - , any(DefaultErrorHandler.class))).thenReturn(jndiJdbcDataSourceJerseyRequestMock); - - doReturn(jndiDataSourceOperationResultMock).when(jndiJdbcDataSourceJerseyRequestMock).get(); - - OperationResult connection = connectionsService - .connection(ClientJndiJdbcDataSource.class, ContextMediaTypes.JNDI_JDBC_DATA_SOURCE_TYPE, TEST_UUID) - .get(); - //then - assertSame(jndiDataSourceOperationResultMock, connection); - verifyStatic(times(1)); - JerseyRequest.buildRequest(eq(sessionStorageMock) - , eq(ClientJndiJdbcDataSource.class) - , eq(new String[]{CONNECTIONS_URI, TEST_UUID}) - , any(DefaultErrorHandler.class)); - verify(jndiJdbcDataSourceJerseyRequestMock).get(); - } - - - @Test - public void should_return_proper_jndi_connection_operationResult_when_create() throws Exception { - //when - mockStatic(JerseyRequest.class); - when(JerseyRequest.buildRequest(eq(sessionStorageMock) - , eq(ClientJndiJdbcDataSource.class) - , eq(new String[]{CONNECTIONS_URI}) - , any(DefaultErrorHandler.class))).thenReturn(jndiJdbcDataSourceJerseyRequestMock); - doReturn(configurationMock).when(sessionStorageMock).getConfiguration(); - doReturn(MimeType.JSON).when(configurationMock).getContentMimeType(); - doReturn(jndiJdbcDataSourceJerseyRequestMock).when(jndiJdbcDataSourceJerseyRequestMock).setContentType(ContextMediaTypes.JNDI_JDBC_DATA_SOURCE_JSON); - doReturn(jndiDataSourceOperationResultMock).when(jndiJdbcDataSourceJerseyRequestMock).post(any(ClientJndiJdbcDataSource.class)); - - OperationResult connection = connectionsService - .connection(ClientJndiJdbcDataSource.class, ContextMediaTypes.JNDI_JDBC_DATA_SOURCE_TYPE, TEST_UUID) - .create(new ClientJndiJdbcDataSource()); - //then - assertSame(jndiDataSourceOperationResultMock, connection); - verifyStatic(times(1)); - JerseyRequest.buildRequest(eq(sessionStorageMock) - , eq(ClientJndiJdbcDataSource.class) - , eq(new String[]{CONNECTIONS_URI}) - , any(DefaultErrorHandler.class)); - verify(sessionStorageMock).getConfiguration(); - verify(configurationMock).getContentMimeType(); - verify(jndiJdbcDataSourceJerseyRequestMock).setContentType(ContextMediaTypes.JNDI_JDBC_DATA_SOURCE_JSON); - verify(jndiJdbcDataSourceJerseyRequestMock).post(any(ClientJndiJdbcDataSource.class)); - - } - - @Test - public void should_return_proper_jdbc_connection_operationResult_when_get() throws Exception { - //when - mockStatic(JerseyRequest.class); - when(JerseyRequest.buildRequest(eq(sessionStorageMock) - , eq(ClientJdbcDataSource.class) - , eq(new String[]{CONNECTIONS_URI, TEST_UUID}) - , any(DefaultErrorHandler.class))).thenReturn(jdbcDataSourceJerseyRequestMock); - - doReturn(jdbcDataSourceOperationResultMock).when(jdbcDataSourceJerseyRequestMock).get(); - - OperationResult connection = connectionsService - .connection(ClientJdbcDataSource.class, ContextMediaTypes.JDBC_DATA_SOURCE_TYPE, TEST_UUID) - .get(); - //then - assertSame(jdbcDataSourceOperationResultMock, connection); - verifyStatic(times(1)); - JerseyRequest.buildRequest(eq(sessionStorageMock) - , eq(ClientJdbcDataSource.class) - , eq(new String[]{CONNECTIONS_URI, TEST_UUID}) - , any(DefaultErrorHandler.class)); - verify(jdbcDataSourceJerseyRequestMock).get(); - } - - - @Test - public void should_return_proper_jdbc_connection_operationResult_when_create() throws Exception { - //when - mockStatic(JerseyRequest.class); - when(JerseyRequest.buildRequest(eq(sessionStorageMock) - , eq(ClientJdbcDataSource.class) - , eq(new String[]{CONNECTIONS_URI}) - , any(DefaultErrorHandler.class))).thenReturn(jdbcDataSourceJerseyRequestMock); - doReturn(configurationMock).when(sessionStorageMock).getConfiguration(); - doReturn(MimeType.JSON).when(configurationMock).getContentMimeType(); - doReturn(jdbcDataSourceJerseyRequestMock).when(jdbcDataSourceJerseyRequestMock).setContentType(ContextMediaTypes.JDBC_DATA_SOURCE_JSON); - doReturn(jdbcDataSourceOperationResultMock).when(jdbcDataSourceJerseyRequestMock).post(any(ClientJdbcDataSource.class)); - - OperationResult connection = connectionsService - .connection(ClientJdbcDataSource.class, ContextMediaTypes.JDBC_DATA_SOURCE_TYPE, TEST_UUID) - .create(new ClientJdbcDataSource()); - //then - assertSame(jdbcDataSourceOperationResultMock, connection); - verifyStatic(times(1)); - JerseyRequest.buildRequest(eq(sessionStorageMock) - , eq(ClientJdbcDataSource.class) - , eq(new String[]{CONNECTIONS_URI}) - , any(DefaultErrorHandler.class)); - verify(sessionStorageMock).getConfiguration(); - verify(configurationMock).getContentMimeType(); - verify(jdbcDataSourceJerseyRequestMock).setContentType(ContextMediaTypes.JDBC_DATA_SOURCE_JSON); - verify(jdbcDataSourceJerseyRequestMock).post(any(ClientJdbcDataSource.class)); - } - - @Test - public void should_return_proper_operationResult_when_get_metadata() throws Exception { - //when - mockStatic(JerseyRequest.class); - when(JerseyRequest.buildRequest(eq(sessionStorageMock) - , eq(TableMetadata.class) - , eq(new String[]{CONNECTIONS_URI, TEST_UUID, "metadata"}) - , any(DefaultErrorHandler.class))).thenReturn(tableMetadataRequestMock); - doReturn(configurationMock).when(sessionStorageMock).getConfiguration(); - doReturn(MimeType.JSON).when(configurationMock).getAcceptMimeType(); - doReturn(tableMetadataRequestMock).when(tableMetadataRequestMock).setAccept(ContextMediaTypes.JDBC_DATA_SOURCE_JSON); - - doReturn(tableMetadataOperationResultMock).when(tableMetadataRequestMock).get(); - - OperationResult connection = connectionsService - .connection(TEST_UUID, TableMetadata.class, - ContextMediaTypes.JDBC_DATA_SOURCE_METADATA_TYPE) - .metadata(); - //then - assertSame(tableMetadataOperationResultMock, connection); - verifyStatic(times(1)); - JerseyRequest.buildRequest(eq(sessionStorageMock) - , eq(TableMetadata.class) - , eq(new String[]{CONNECTIONS_URI, TEST_UUID, "metadata"}) - , any(DefaultErrorHandler.class)); - verify(sessionStorageMock).getConfiguration(); - verify(configurationMock).getAcceptMimeType(); - verify(tableMetadataRequestMock).setAccept(ContextMediaTypes.JDBC_DATA_SOURCE_METADATA_JSON); - verify(tableMetadataRequestMock).get(); - } - - @Test(expectedExceptions = MandatoryParameterNotFoundException.class) - public void should_throw_exception_when_update_connection_is_null() throws Exception { - //when - connectionsService - .connection(TEST_UUID) - .update(null); - //then - // an exception should be thrown - - } - - @Test(expectedExceptions = MandatoryParameterNotFoundException.class) - public void should_throw_exception_when_create_connection_is_null() throws Exception { - //when - connectionsService - .connection(TEST_UUID) - .update(null); - //then - // an exception should be thrown - - } - - @Test(expectedExceptions = MandatoryParameterNotFoundException.class) - public void should_throw_exception_when_create_connection_uuid_is_null() throws Exception { - //when - connectionsService - .connection(null) - .get(); - //then - // an exception should be thrown - } - - - @Test(expectedExceptions = MandatoryParameterNotFoundException.class) - public void should_throw_exception_when_get_connection_uuid_is_empty() throws Exception { - //when - connectionsService - .connection("") - .get(); - //then - // an exception should be thrown - } - -} \ No newline at end of file diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/context/SingleContextAdapterTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/context/SingleContextAdapterTest.java index 76e4e1f6..c4122aa9 100644 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/context/SingleContextAdapterTest.java +++ b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/context/SingleContextAdapterTest.java @@ -23,8 +23,8 @@ import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.reset; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -149,7 +149,7 @@ public void should_return_proper_ftp_connection_operationResult_when_get() throw .get(); //then assertSame(ftpConnectionOperationResultMock, connection); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); JerseyRequest.buildRequest(eq(sessionStorageMock) , eq(FtpConnection.class) , eq(new String[]{CONTEXTS_URI, TEST_UUID}) @@ -174,7 +174,7 @@ public void should_return_proper_ftp_connection_operationResult_when_create() th .create(new FtpConnection()); //then assertSame(ftpConnectionOperationResultMock, connection); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); JerseyRequest.buildRequest(eq(sessionStorageMock) , eq(FtpConnection.class) , eq(new String[]{CONTEXTS_URI}) @@ -200,7 +200,7 @@ public void should_return_proper_ftp_connection_operationResult_when_update() th .update(new FtpConnection()); //then assertSame(ftpConnectionOperationResultMock, connection); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); JerseyRequest.buildRequest(eq(sessionStorageMock) , eq(FtpConnection.class) , eq(new String[]{CONTEXTS_URI, TEST_UUID}) @@ -225,7 +225,7 @@ public void should_return_proper_ftp_connection_operationResult_when_delete() th .delete(); //then assertSame(operationResultMock, connection); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); JerseyRequest.buildRequest(eq(sessionStorageMock) , eq(Object.class) , eq(new String[]{CONTEXTS_URI, TEST_UUID}) @@ -249,7 +249,7 @@ public void should_return_proper_local_file_system_connection_operationResult_wh .get(); //then assertSame(lfsConnectionOperationResultMock, connection); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); JerseyRequest.buildRequest(eq(sessionStorageMock) , eq(LfsConnection.class) , eq(new String[]{CONTEXTS_URI, TEST_UUID}) @@ -274,7 +274,7 @@ public void should_return_proper_local_file_system_connection_operationResult_wh .create(new LfsConnection()); //then assertSame(lfsConnectionOperationResultMock, connection); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); JerseyRequest.buildRequest(eq(sessionStorageMock) , eq(LfsConnection.class) , eq(new String[]{CONTEXTS_URI}) @@ -300,7 +300,7 @@ public void should_return_proper_custom_data_source_connection_operationResult_w .get(); //then assertSame(customDataSourceOperationResultMock, connection); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); JerseyRequest.buildRequest(eq(sessionStorageMock) , eq(ClientCustomDataSource.class) , eq(new String[]{CONTEXTS_URI, TEST_UUID}) @@ -326,7 +326,7 @@ public void should_return_proper_custom_data_source_connection_operationResult_w .create(new ClientCustomDataSource()); //then assertSame(customDataSourceOperationResultMock, connection); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); JerseyRequest.buildRequest(eq(sessionStorageMock) , eq(ClientCustomDataSource.class) , eq(new String[]{CONTEXTS_URI}) @@ -352,7 +352,7 @@ public void should_return_proper_jndi_connection_operationResult_when_get() thro .get(); //then assertSame(jndiDataSourceOperationResultMock, connection); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); JerseyRequest.buildRequest(eq(sessionStorageMock) , eq(ClientJndiJdbcDataSource.class) , eq(new String[]{CONTEXTS_URI, TEST_UUID}) @@ -377,7 +377,7 @@ public void should_return_proper_jndi_connection_operationResult_when_create() t .create(new ClientJndiJdbcDataSource()); //then assertSame(jndiDataSourceOperationResultMock, connection); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); JerseyRequest.buildRequest(eq(sessionStorageMock) , eq(ClientJndiJdbcDataSource.class) , eq(new String[]{CONTEXTS_URI}) @@ -403,7 +403,7 @@ public void should_return_proper_jdbc_connection_operationResult_when_get() thro .get(); //then assertSame(jdbcDataSourceOperationResultMock, connection); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); JerseyRequest.buildRequest(eq(sessionStorageMock) , eq(ClientJdbcDataSource.class) , eq(new String[]{CONTEXTS_URI, TEST_UUID}) @@ -428,7 +428,7 @@ public void should_return_proper_jdbc_connection_operationResult_when_create() t .create(new ClientJdbcDataSource()); //then assertSame(jdbcDataSourceOperationResultMock, connection); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); JerseyRequest.buildRequest(eq(sessionStorageMock) , eq(ClientJdbcDataSource.class) , eq(new String[]{CONTEXTS_URI}) @@ -460,7 +460,7 @@ public void should_return_proper_operationResult_when_create_context_and_get_met .createAndGetMetadata(new ClientDomain()); //then assertSame(presentationGroupElementOperationResultMock, metadata); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); JerseyRequest.buildRequest(eq(sessionStorageMock) , eq(PresentationGroupElement.class) , eq(new String[]{CONTEXTS_URI}) @@ -499,7 +499,7 @@ public void should_return_proper_operationResult_when_get_metadata() throws Exce .metadata(); //then assertSame(tableMetadataOperationResultMock, connection); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); JerseyRequest.buildRequest(eq(sessionStorageMock) , eq(TableMetadata.class) , eq(new String[]{CONTEXTS_URI, TEST_UUID, "metadata"}) diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/context/domain/DomainContextOperationResultTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/context/domain/DomainContextOperationResultTest.java index 90d867a6..35839529 100644 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/context/domain/DomainContextOperationResultTest.java +++ b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/context/domain/DomainContextOperationResultTest.java @@ -18,8 +18,9 @@ import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyString; +import static org.easymock.EasyMock.mock; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.reset; import static org.mockito.Mockito.spy; @@ -162,6 +163,7 @@ public void should_return_proper_operationResult_when_get_metadata_with_paramete public void should_return_proper_operationResult_when_get_metadata_for_expired_context() throws Exception { //given doReturn("/test_uuId").when(responseMock).getHeaderString("Location"); + doReturn(mock(ClientResourceLookup.class)).when(responseMock).readEntity(ClientResourceLookup.class); domainContextOperationResult = spy(new DomainContextOperationResult(responseMock, ClientResourceLookup.class, contextServiceMock)); doReturn(singleContextAdapterMock).when(contextServiceMock).context(anyString(), any(Class.class), anyString()); @@ -201,6 +203,7 @@ public void should_return_proper_operationResult_when_execute_query() throws Exc public void should_return_proper_operationResult_when_execute_query_for_expired_context() throws Exception { //given doReturn("/test_uuId").when(responseMock).getHeaderString("Location"); + doReturn(mock(ClientResourceLookup.class)).when(responseMock).readEntity(ClientResourceLookup.class); domainContextOperationResult = new DomainContextOperationResult<>(responseMock, ClientResourceLookup.class, contextServiceMock); doReturn(singleContextAdapterMock).when(contextServiceMock).context(anyString()); doThrow(ResourceNotFoundException.class).when(singleContextAdapterMock).executeQuery(any(ClientMultiLevelQuery.class)); @@ -210,7 +213,7 @@ public void should_return_proper_operationResult_when_execute_query_for_expired_ doReturn(responseMock).when(resourceLookupOperationResultMock).getResponse(); //when - OperationResult queryResultSet = domainContextOperationResult.executeQuery(new ClientMultiLevelQuery()); + domainContextOperationResult.executeQuery(new ClientMultiLevelQuery()); // then // an exception should be thrown diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/context/domain/DomainContextServiceTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/context/domain/DomainContextServiceTest.java index 11ff6dc7..ee36697e 100644 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/context/domain/DomainContextServiceTest.java +++ b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/context/domain/DomainContextServiceTest.java @@ -11,9 +11,9 @@ import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyString; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.reset; import static org.mockito.Mockito.times; diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/context/domain/SingleDomainContextAdapterTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/context/domain/SingleDomainContextAdapterTest.java index 8d0d7160..b3ef7855 100644 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/context/domain/SingleDomainContextAdapterTest.java +++ b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/context/domain/SingleDomainContextAdapterTest.java @@ -18,9 +18,9 @@ import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyString; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.reset; import static org.mockito.Mockito.verify; import static org.mockito.MockitoAnnotations.initMocks; diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/datadiscovery/DerivedTableContextManagerTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/datadiscovery/DerivedTableContextManagerTest.java index 3cd660f3..1f620b9d 100644 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/datadiscovery/DerivedTableContextManagerTest.java +++ b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/datadiscovery/DerivedTableContextManagerTest.java @@ -7,7 +7,7 @@ import com.jaspersoft.jasperserver.jaxrs.client.core.SessionStorage; import com.jaspersoft.jasperserver.jaxrs.client.core.enums.ContextMediaTypes; import com.jaspersoft.jasperserver.jaxrs.client.core.operationresult.OperationResult; -import org.mockito.internal.util.reflection.Whitebox; +import org.powermock.reflect.Whitebox; import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.testng.PowerMockTestCase; diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/datadiscovery/DomElContextManagerTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/datadiscovery/DomElContextManagerTest.java index d631d82e..4b6e6e12 100644 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/datadiscovery/DomElContextManagerTest.java +++ b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/datadiscovery/DomElContextManagerTest.java @@ -7,7 +7,7 @@ import com.jaspersoft.jasperserver.jaxrs.client.core.SessionStorage; import com.jaspersoft.jasperserver.jaxrs.client.core.enums.ContextMediaTypes; import com.jaspersoft.jasperserver.jaxrs.client.core.operationresult.OperationResult; -import org.mockito.internal.util.reflection.Whitebox; +import org.powermock.reflect.Whitebox; import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.testng.PowerMockTestCase; diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/datadiscovery/DomainContextManagerTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/datadiscovery/DomainContextManagerTest.java index d49bd91e..b50eb3ca 100644 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/datadiscovery/DomainContextManagerTest.java +++ b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/datadiscovery/DomainContextManagerTest.java @@ -2,13 +2,12 @@ import com.jaspersoft.jasperserver.dto.resources.domain.ClientDomain; import com.jaspersoft.jasperserver.dto.resources.domain.PresentationGroupElement; -import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.connections.SingleConnectionsAdapter; import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.context.ContextService; import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.context.SingleContextAdapter; import com.jaspersoft.jasperserver.jaxrs.client.core.SessionStorage; import com.jaspersoft.jasperserver.jaxrs.client.core.enums.ContextMediaTypes; import com.jaspersoft.jasperserver.jaxrs.client.core.operationresult.OperationResult; -import org.mockito.internal.util.reflection.Whitebox; +import org.powermock.reflect.Whitebox; import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.testng.PowerMockTestCase; @@ -29,7 +28,7 @@ * @version $Id$ * @see */ -@PrepareForTest({ContextService.class, SessionStorage.class, SingleConnectionsAdapter.class, DomainContextManager.class}) +@PrepareForTest({ContextService.class, SessionStorage.class, DomainContextManager.class}) public class DomainContextManagerTest extends PowerMockTestCase { private SessionStorage sessionStorageMock; private ContextService contextServiceMock; diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/datadiscovery/TopicContextManagerTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/datadiscovery/TopicContextManagerTest.java index d44c1116..5b617492 100644 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/datadiscovery/TopicContextManagerTest.java +++ b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/datadiscovery/TopicContextManagerTest.java @@ -2,13 +2,12 @@ import com.jaspersoft.jasperserver.dto.resources.ClientReportUnit; import com.jaspersoft.jasperserver.dto.resources.domain.ResourceGroupElement; -import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.connections.SingleConnectionsAdapter; import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.context.ContextService; import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.context.SingleContextAdapter; import com.jaspersoft.jasperserver.jaxrs.client.core.SessionStorage; import com.jaspersoft.jasperserver.jaxrs.client.core.enums.ContextMediaTypes; import com.jaspersoft.jasperserver.jaxrs.client.core.operationresult.OperationResult; -import org.mockito.internal.util.reflection.Whitebox; +import org.powermock.reflect.Whitebox; import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.testng.PowerMockTestCase; @@ -29,7 +28,7 @@ * @version $Id$ * @see */ -@PrepareForTest({ContextService.class, SessionStorage.class, SingleConnectionsAdapter.class, TopicContextManager.class}) +@PrepareForTest({ContextService.class, SessionStorage.class, TopicContextManager.class}) public class TopicContextManagerTest extends PowerMockTestCase { private SessionStorage sessionStorageMock; private ContextService contextServiceMock; diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/diagnostic/BatchDiagnosticCollectorsAdapterTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/diagnostic/BatchDiagnosticCollectorsAdapterTest.java index b1b2c3f2..fe651841 100644 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/diagnostic/BatchDiagnosticCollectorsAdapterTest.java +++ b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/diagnostic/BatchDiagnosticCollectorsAdapterTest.java @@ -9,7 +9,7 @@ import com.jaspersoft.jasperserver.jaxrs.client.core.operationresult.OperationResult; import java.io.InputStream; import org.mockito.Mock; -import org.mockito.internal.util.reflection.Whitebox; +import org.powermock.reflect.Whitebox; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.testng.PowerMockTestCase; import org.testng.annotations.AfterMethod; @@ -17,8 +17,8 @@ import org.testng.annotations.Test; import static com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest.buildRequest; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.reset; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -84,7 +84,7 @@ public void should_return_proper_operation_result_when_get_collectors_metadata() assertNotNull(retrieved); assertSame(retrieved, operationResultMock); verify(jerseyRequestMock).get(); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); buildRequest( eq(sessionStorageMock), eq(CollectorSettingsList.class), @@ -113,7 +113,7 @@ public void should_return_proper_operation_result_when_delete_collectors() { assertNotNull(retrieved); assertSame(retrieved, operationResultMock); verify(jerseyRequestMock).delete(); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); buildRequest( eq(sessionStorageMock), eq(CollectorSettingsList.class), @@ -144,7 +144,7 @@ public void should_return_proper_operation_result_when_update_collectors_setting assertSame(retrieved, operationResultMock); verify(jerseyRequestMock).post(any(PatchDescriptor.class)); verify(jerseyRequestMock).addHeader("X-HTTP-Method-Override", "PATCH"); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); buildRequest( eq(sessionStorageMock), eq(CollectorSettingsList.class), @@ -176,7 +176,7 @@ public void should_return_proper_operation_result_when_get_collector_content() { assertSame(retrieved, operationResultContentMock); verify(jerseyRequestContentMock).setAccept("application/zip"); verify(jerseyRequestContentMock).get(); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); buildRequest( eq(sessionStorageMock), eq(InputStream.class), diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/diagnostic/SingleDiagnosticCollectorAdapterTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/diagnostic/SingleDiagnosticCollectorAdapterTest.java index 49e1dc93..8603b5e8 100644 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/diagnostic/SingleDiagnosticCollectorAdapterTest.java +++ b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/diagnostic/SingleDiagnosticCollectorAdapterTest.java @@ -9,7 +9,7 @@ import com.jaspersoft.jasperserver.jaxrs.client.core.operationresult.OperationResult; import java.io.InputStream; import org.mockito.Mock; -import org.mockito.internal.util.reflection.Whitebox; +import org.powermock.reflect.Whitebox; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.testng.PowerMockTestCase; import org.testng.annotations.AfterMethod; @@ -17,8 +17,8 @@ import org.testng.annotations.Test; import static com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest.buildRequest; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.reset; import static org.mockito.Mockito.times; @@ -96,7 +96,7 @@ public void should_return_proper_operation_result_when_create() { assertNotNull(retrieved); assertSame(retrieved, operationResultMock); verify(jerseyRequestMock).post(collectorSettingsMock); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); buildRequest( eq(sessionStorageMock), eq(CollectorSettings.class), @@ -127,7 +127,7 @@ public void should_return_proper_operation_result_when_delete() { assertNotNull(retrieved); assertSame(retrieved, operationResultMock); verify(jerseyRequestMock).delete(); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); buildRequest( eq(sessionStorageMock), eq(CollectorSettings.class), @@ -159,7 +159,7 @@ public void should_return_proper_operation_result_when_get_collector_metadata() assertNotNull(retrieved); assertSame(retrieved, operationResultMock); verify(jerseyRequestMock).get(); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); buildRequest( eq(sessionStorageMock), eq(CollectorSettings.class), @@ -190,7 +190,7 @@ public void should_return_proper_operation_result_when_update_collector() { assertNotNull(retrieved); assertSame(retrieved, operationResultMock); verify(jerseyRequestMock).put(collectorSettingsMock); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); buildRequest( eq(sessionStorageMock), eq(CollectorSettings.class), @@ -223,7 +223,7 @@ public void should_return_proper_operation_result_when_update_collector_settings assertSame(retrieved, operationResultMock); verify(jerseyRequestMock).post(any(PatchDescriptor.class)); verify(jerseyRequestMock).addHeader("X-HTTP-Method-Override", "PATCH"); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); buildRequest( eq(sessionStorageMock), eq(CollectorSettings.class), @@ -257,7 +257,7 @@ public void should_return_proper_operation_result_when_get_collector_content() { assertSame(retrieved, operationResultContentMock); verify(jerseyRequestContentMock).setAccept("application/zip"); verify(jerseyRequestContentMock).get(); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); buildRequest( eq(sessionStorageMock), eq(InputStream.class), diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/domain/metadata/DomainMetadataAdapterTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/domain/metadata/DomainMetadataAdapterTest.java index 6610b1e9..d7e74c25 100644 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/domain/metadata/DomainMetadataAdapterTest.java +++ b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/domain/metadata/DomainMetadataAdapterTest.java @@ -13,7 +13,7 @@ import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.reset; import static org.mockito.MockitoAnnotations.initMocks; import static org.powermock.api.mockito.PowerMockito.doReturn; diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/domain/newDomain/DomainAdapterTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/domain/newDomain/DomainAdapterTest.java index e317a64e..74138f2d 100644 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/domain/newDomain/DomainAdapterTest.java +++ b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/domain/newDomain/DomainAdapterTest.java @@ -19,14 +19,14 @@ import static com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest.buildRequest; import static java.util.Arrays.asList; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.reset; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import static org.mockito.MockitoAnnotations.initMocks; -import static org.mockito.internal.util.reflection.Whitebox.getInternalState; +import static org.powermock.reflect.Whitebox.getInternalState; import static org.powermock.api.mockito.PowerMockito.doReturn; import static org.powermock.api.mockito.PowerMockito.mock; import static org.powermock.api.mockito.PowerMockito.mockStatic; @@ -187,7 +187,7 @@ public void should_invoke_private_static_method() { // Then assertNotNull(retrieved); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); buildRequest(eq(sessionStorageMock), eq(ClientDomain.class), eq(new String[]{"resources", URI}), diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/domain/schema/DomainSchemaAdapterTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/domain/schema/DomainSchemaAdapterTest.java index ca8635e9..cd000787 100644 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/domain/schema/DomainSchemaAdapterTest.java +++ b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/domain/schema/DomainSchemaAdapterTest.java @@ -21,14 +21,14 @@ import static com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest.buildRequest; import static java.util.Arrays.asList; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.reset; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import static org.mockito.MockitoAnnotations.initMocks; -import static org.mockito.internal.util.reflection.Whitebox.getInternalState; +import static org.powermock.reflect.Whitebox.getInternalState; import static org.powermock.api.mockito.PowerMockito.doReturn; import static org.powermock.api.mockito.PowerMockito.mock; import static org.powermock.api.mockito.PowerMockito.mockStatic; @@ -193,7 +193,7 @@ public void should_involve_static_method() { // Then assertNotNull(retrieved); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); buildRequest(eq(sessionStorageMock), eq(Schema.class), eq(new String[]{"resources", URI}), diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/importexport/exportservice/ExportRequestAdapterTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/importexport/exportservice/ExportRequestAdapterTest.java index a677b5b6..df4dd063 100644 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/importexport/exportservice/ExportRequestAdapterTest.java +++ b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/importexport/exportservice/ExportRequestAdapterTest.java @@ -1,5 +1,7 @@ package com.jaspersoft.jasperserver.jaxrs.client.apiadapters.importexport.exportservice; +import com.jaspersoft.jasperserver.dto.common.ErrorDescriptor; +import com.jaspersoft.jasperserver.dto.importexport.State; import com.jaspersoft.jasperserver.jaxrs.client.core.Callback; import com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest; import com.jaspersoft.jasperserver.jaxrs.client.core.RequestBuilder; @@ -7,8 +9,6 @@ import com.jaspersoft.jasperserver.jaxrs.client.core.SessionStorage; import com.jaspersoft.jasperserver.jaxrs.client.core.exceptions.ExportFailedException; import com.jaspersoft.jasperserver.jaxrs.client.core.operationresult.OperationResult; -import com.jaspersoft.jasperserver.dto.common.ErrorDescriptor; -import com.jaspersoft.jasperserver.dto.importexport.State; import org.mockito.Mock; import org.mockito.Mockito; import org.powermock.api.mockito.PowerMockito; @@ -21,13 +21,10 @@ import java.io.InputStream; import java.lang.reflect.Field; -import java.util.concurrent.ExecutionException; import java.util.concurrent.atomic.AtomicInteger; import static com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest.buildRequest; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.never; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.reset; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -35,10 +32,8 @@ import static org.mockito.MockitoAnnotations.initMocks; import static org.powermock.api.mockito.PowerMockito.mockStatic; import static org.powermock.api.mockito.PowerMockito.spy; -import static org.powermock.api.mockito.PowerMockito.verifyStatic; import static org.powermock.api.support.membermodification.MemberMatcher.field; import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNotSame; import static org.testng.Assert.assertSame; @@ -120,131 +115,6 @@ public void should_return_proper_OperationResult_object() { assertSame(opResult, operationResultStateDtoMock); } - @Test(testName = "fetch") - public void should_retrieve_streamed_OperationResult_object_when_status_is_finished() { - - // Given - mockStatic(JerseyRequest.class); - doReturn(operationResultStateDtoMock).when(adapterSpy).state(); - doReturn(stateMock).when(operationResultStateDtoMock).getEntity(); - doReturn("finished").when(stateMock).getPhase(); - - when(JerseyRequest.buildRequest(sessionStorageMock, InputStream.class, - new String[]{"export", taskId, "exportFile"})).thenReturn(requestInputStreamMock); - - doReturn(operationResultInputStreamMock).when(requestInputStreamMock).get(); - - // When - OperationResult retrieved = adapterSpy.fetch(); - - // Then - assertNotNull(retrieved); - assertSame(retrieved, operationResultInputStreamMock); - } - - @Test(enabled = false) - /** - * for {@link com.jaspersoft.jasperserver.jaxrs.client.apiadapters.importexport.exportservice.ExportRequestAdapter#asyncFetch(com.jaspersoft.jasperserver.jaxrs.client.core.Callback)} - */ - public void should_fetch_an_export_as_IS_when_job_finished() throws Exception { - - // Given - ExportRequestAdapter adapterSpy = PowerMockito.spy(new ExportRequestAdapter(sessionStorageMock, taskId)); - - PowerMockito.mockStatic(JerseyRequest.class); - PowerMockito.when(buildRequest(eq(sessionStorageMock), eq(InputStream.class), - eq(new String[]{"export", taskId, "exportFile"}))) - .thenReturn(requestInputStreamMock); - - PowerMockito.when(buildRequest(eq(sessionStorageMock), eq(State.class), - eq(new String[]{"export", taskId, "state"}))) - .thenReturn(requestStateDtoMock); - - PowerMockito.doReturn(operationResultInputStreamMock).when(requestInputStreamMock).get(); - PowerMockito.doReturn(operationResultStateDtoMock).when(requestStateDtoMock).get(); - PowerMockito.doReturn(stateMock).when(operationResultStateDtoMock).getEntity(); - PowerMockito.doReturn("finished").when(stateMock).getPhase(); - - final AtomicInteger newThreadId = new AtomicInteger(); - final int currentThreadId = (int) Thread.currentThread().getId(); - - final Callback, Void> callbackSpy = PowerMockito.spy(new Callback, Void>() { - @Override - public Void execute(OperationResult data) { - newThreadId.set((int) Thread.currentThread().getId()); - synchronized (this) { - this.notify(); - } - return null; - } - }); - - RequestExecution retrieved = adapterSpy.asyncFetch(callbackSpy); - - synchronized (callbackSpy) { - callbackSpy.wait(1000); - } - - Mockito.verify(callbackSpy).execute(operationResultInputStreamMock); - assertNotSame(currentThreadId, newThreadId.get()); - assertNotNull(retrieved); - } - - @Test(enabled = false) - /** - * for {@link com.jaspersoft.jasperserver.jaxrs.client.apiadapters.importexport.exportservice.ExportRequestAdapter#asyncFetch(com.jaspersoft.jasperserver.jaxrs.client.core.Callback)} - */ - public void should_throw_an_exception_in_separate_thread() throws Exception { - - // Given - ExportRequestAdapter adapterSpy = PowerMockito.spy(new ExportRequestAdapter(sessionStorageMock, taskId)); - - PowerMockito.mockStatic(JerseyRequest.class); - PowerMockito.when(buildRequest(eq(sessionStorageMock), eq(InputStream.class), - eq(new String[]{"export", taskId, "exportFile"}))) - .thenReturn(requestInputStreamMock); - - PowerMockito.when(buildRequest(eq(sessionStorageMock), eq(State.class), - eq(new String[]{"export", taskId, "state"}))) - .thenReturn(requestStateDtoMock); - - PowerMockito.doReturn(operationResultInputStreamMock).when(requestInputStreamMock).get(); - PowerMockito.doReturn(operationResultStateDtoMock).when(requestStateDtoMock).get(); - PowerMockito.doReturn(stateMock).when(operationResultStateDtoMock).getEntity(); - PowerMockito.doReturn(null).when(stateMock).getError(); - PowerMockito.doReturn("msg").when(stateMock).getMessage(); - - PowerMockito - .doReturn("inprogress") - .doReturn("failed") // task was failed - .when(stateMock) - .getPhase(); - - final AtomicInteger newThreadId = new AtomicInteger(); - final int currentThreadId = (int) Thread.currentThread().getId(); - - final Callback, Void> callbackSpy = PowerMockito.spy(new Callback, Void>() { - @Override - public Void execute(OperationResult data) { - newThreadId.set((int) Thread.currentThread().getId()); - synchronized (this) { - this.notify(); - } - return null; - } - }); - - RequestExecution retrieved = adapterSpy.asyncFetch(callbackSpy); - - synchronized (callbackSpy) { - callbackSpy.wait(1000); - } - - Mockito.verify(callbackSpy, never()).execute(operationResultInputStreamMock); - assertNotSame(currentThreadId, newThreadId.get()); - assertNotNull(retrieved); - } - @Test /** * for {@link com.jaspersoft.jasperserver.jaxrs.client.apiadapters.importexport.exportservice.ExportRequestAdapter#asyncState(com.jaspersoft.jasperserver.jaxrs.client.core.Callback)} @@ -276,7 +146,7 @@ public Void execute(OperationResult data) { }); PowerMockito.doReturn(operationResultStateDtoMock).when(requestStateDtoMock).get(); - PowerMockito.doReturn(null).when(callback).execute(operationResultStateDtoMock); + PowerMockito.doNothing().when(callback).execute(operationResultStateDtoMock); // When RequestExecution retrieved = taskAdapterSpy.asyncState(callback); @@ -319,7 +189,7 @@ public Void execute(OperationResult data) { }); PowerMockito.doReturn(operationResultStateDtoMock).when(requestStateDtoMock).get(); - PowerMockito.doReturn(null).when(callbackSpy).execute(operationResultStateDtoMock); + PowerMockito.doNothing().when(callbackSpy).execute(operationResultStateDtoMock); /* When */ RequestExecution retrieved = requestAdapterSpy.asyncState(callbackSpy); @@ -337,409 +207,6 @@ public Void execute(OperationResult data) { Mockito.verify(requestStateDtoMock, times(1)).get(); } - - @Test(enabled = false) - /** - * for {@link com.jaspersoft.jasperserver.jaxrs.client.apiadapters.importexport.exportservice.ExportRequestAdapter#asyncFetch(com.jaspersoft.jasperserver.jaxrs.client.core.Callback)} - */ - public void should_throw_an_exception_in_separate_thread_and_when_there_is_ErrorDescriptor() throws Exception { - - // Given - ExportRequestAdapter adapterSpy = PowerMockito.spy(new ExportRequestAdapter(sessionStorageMock, taskId)); - ErrorDescriptor descriptorMock = PowerMockito.mock(ErrorDescriptor.class); - - PowerMockito.mockStatic(JerseyRequest.class); - PowerMockito.when(buildRequest(eq(sessionStorageMock), eq(InputStream.class), - eq(new String[]{"export", taskId, "exportFile"}))) - .thenReturn(requestInputStreamMock); - - PowerMockito.when(buildRequest(eq(sessionStorageMock), eq(State.class), - eq(new String[]{"export", taskId, "state"}))) - .thenReturn(requestStateDtoMock); - - PowerMockito.doReturn(operationResultInputStreamMock).when(requestInputStreamMock).get(); - PowerMockito.doReturn(operationResultStateDtoMock).when(requestStateDtoMock).get(); - PowerMockito.doReturn(stateMock).when(operationResultStateDtoMock).getEntity(); - PowerMockito.doReturn(descriptorMock).when(stateMock).getError(); - PowerMockito.doReturn("msg").when(stateMock).getMessage(); - - PowerMockito - .doReturn("failed") - .doReturn("failed") // task was failed - .when(stateMock) - .getPhase(); - - final AtomicInteger newThreadId = new AtomicInteger(); - final int currentThreadId = (int) Thread.currentThread().getId(); - - final Callback, Void> callbackSpy = PowerMockito.spy(new Callback, Void>() { - @Override - public Void execute(OperationResult data) { - newThreadId.set((int) Thread.currentThread().getId()); - synchronized (this) { - this.notify(); - } - return null; - } - }); - - RequestExecution retrieved = adapterSpy.asyncFetch(callbackSpy); - - synchronized (callbackSpy) { - callbackSpy.wait(1000); - } - - Mockito.verify(callbackSpy, never()).execute(operationResultInputStreamMock); - assertNotSame(currentThreadId, newThreadId.get()); - assertNotNull(retrieved); - } - - @Test(enabled = false) - /** - * for {@link com.jaspersoft.jasperserver.jaxrs.client.apiadapters.importexport.exportservice.ExportRequestAdapter#asyncFetch(com.jaspersoft.jasperserver.jaxrs.client.core.Callback)} - */ - public void should_fetch_entity_when_second_thread_interrupter() throws Exception { - - /* Given */ - ExportRequestAdapter adapterSpy = PowerMockito.spy(new ExportRequestAdapter(sessionStorageMock, taskId)); - ErrorDescriptor descriptorMock = PowerMockito.mock(ErrorDescriptor.class); - - PowerMockito.mockStatic(JerseyRequest.class, Thread.class); - PowerMockito.when(buildRequest(eq(sessionStorageMock), eq(InputStream.class), - eq(new String[]{"export", taskId, "exportFile"}))) - .thenReturn(requestInputStreamMock); - - PowerMockito.when(buildRequest(eq(sessionStorageMock), eq(State.class), - eq(new String[]{"export", taskId, "state"}))) - .thenReturn(requestStateDtoMock); - - PowerMockito.doThrow(new InterruptedException()).when(Thread.class); - Thread.sleep(500L); - - PowerMockito.doReturn(operationResultInputStreamMock).when(requestInputStreamMock).get(); - PowerMockito.doReturn(operationResultStateDtoMock).when(requestStateDtoMock).get(); - PowerMockito.doReturn(stateMock).when(operationResultStateDtoMock).getEntity(); - PowerMockito.doReturn(descriptorMock).when(stateMock).getError(); - PowerMockito.doReturn("msg").when(stateMock).getMessage(); - - PowerMockito - .doReturn("inprogress") - .doReturn("inprogress") - .doReturn("finished") - .when(stateMock) - .getPhase(); - - final AtomicInteger newThreadId = new AtomicInteger(); - final int currentThreadId = (int) Thread.currentThread().getId(); - - final Callback, Void> callbackSpy = PowerMockito.spy(new Callback, Void>() { - @Override - public Void execute(OperationResult data) { - newThreadId.set((int) Thread.currentThread().getId()); - synchronized (this) { - this.notify(); - } - return null; - } - }); - - /* When */ - RequestExecution retrieved = adapterSpy.asyncFetch(callbackSpy); - - /* Wait */ - synchronized (callbackSpy) { - callbackSpy.wait(1000); - } - - /* Then */ - Mockito.verify(callbackSpy, times(1)).execute(operationResultInputStreamMock); - assertNotSame(currentThreadId, newThreadId.get()); - assertNotNull(retrieved); - } - - @Test - public void should_throw_an_exception_when_fetching_failed() throws Exception { - - /* Given */ - ExportRequestAdapter adapterSpy = Mockito.spy(new ExportRequestAdapter(sessionStorageMock, taskId)); - ErrorDescriptor descriptorMock = Mockito.mock(ErrorDescriptor.class); - - Mockito.doReturn(operationResultStateDtoMock).when(adapterSpy).state(); - Mockito.doReturn(stateMock).when(operationResultStateDtoMock).getEntity(); - Mockito.doReturn("failed").doReturn("failed").when(stateMock).getPhase(); - Mockito.doReturn(descriptorMock).when(stateMock).getError(); - - /* When */ - try { - adapterSpy.fetch(); - } catch (ExportFailedException e) { - - /* Then */ - verify(adapterSpy, times(1)).state(); - verify(stateMock, times(2)).getPhase(); - assertNotNull(e); - assertEquals(e.getMessage(), null); - } - } - - @Test - public void should_throw_an_exception_when_fetching_failed_and_there_is_no_ErrorDescriptor() throws Exception { - - /* Given */ - ExportRequestAdapter adapterSpy = Mockito.spy(new ExportRequestAdapter(sessionStorageMock, taskId)); - - Mockito.doReturn(operationResultStateDtoMock).when(adapterSpy).state(); - Mockito.doReturn(stateMock).when(operationResultStateDtoMock).getEntity(); - Mockito.doReturn("failed").doReturn("failed").when(stateMock).getPhase(); - Mockito.doReturn(null).when(stateMock).getError(); - - /* When */ - try { - adapterSpy.fetch(); - } catch (ExportFailedException e) { - - /* Then */ - verify(adapterSpy, times(1)).state(); - verify(stateMock, times(2)).getPhase(); - assertNotNull(e); - assertEquals(e.getMessage(), null); - } - } - - - @Test - public void should_fetch_streamed_OperationResult() { - - /* Given */ - PowerMockito.mockStatic(JerseyRequest.class, Thread.class); - PowerMockito.when(buildRequest(eq(sessionStorageMock), eq(InputStream.class), - eq(new String[]{"export", taskId, "exportFile"}))) - .thenReturn(requestInputStreamMock); - - ExportRequestAdapter adapterSpy = Mockito.spy(new ExportRequestAdapter(sessionStorageMock, taskId)); - - Mockito.doReturn(operationResultStateDtoMock).when(adapterSpy).state(); - Mockito.doReturn(operationResultInputStreamMock).when(requestInputStreamMock).get(); - Mockito.doReturn(stateMock).when(operationResultStateDtoMock).getEntity(); - Mockito.doReturn("inprogress").doReturn("inprogress").doReturn("finished").when(stateMock).getPhase(); - - /* When */ - - OperationResult result = adapterSpy.fetch(); - - /* Then */ - verifyStatic(times(1)); - buildRequest(eq(sessionStorageMock), eq(InputStream.class), eq(new String[]{"export", taskId, "exportFile"})); - - verify(requestInputStreamMock, times(1)).setAccept("application/zip"); - verify(requestInputStreamMock, times(1)).get(); - } - - @Test - public void should_fetch_export_asynchronously() throws InterruptedException { - - final AtomicInteger newThreadId = new AtomicInteger(); - final int currentThreadId = (int) Thread.currentThread().getId(); - - // ... - PowerMockito.mockStatic(JerseyRequest.class); - PowerMockito.when(buildRequest(eq(sessionStorageMock), - eq(InputStream.class), - eq(new String[]{"export", taskId, "exportFile"}))).thenReturn(requestInputStreamMock); - - ExportRequestAdapter adapterSpy = PowerMockito.spy(new ExportRequestAdapter(sessionStorageMock, taskId)); - - PowerMockito - .doReturn(operationResultInputStreamMock) - .when(adapterSpy) - .state(); - PowerMockito - .doReturn(operationResultInputStreamMock) - .when(requestInputStreamMock) - .get(); - PowerMockito - .doReturn(stateMock) - .when(operationResultInputStreamMock) - .getEntity(); - PowerMockito - .doReturn("inprogress") - .doReturn("inprogress") - .doReturn("finished") - .when(stateMock) - .getPhase(); - - - final Callback, Void> callbackSpy = PowerMockito.spy(new Callback, Void>() { - @Override - public Void execute(OperationResult data) { - newThreadId.set((int) Thread.currentThread().getId()); - synchronized (this) { - this.notify(); - } - return null; - } - }); - - /* When */ - RequestExecution retrieved = adapterSpy.asyncFetch(callbackSpy); - - /* Wait */ - synchronized (callbackSpy) { - callbackSpy.wait(5000); - } - - /* Then */ - Mockito.verify(callbackSpy, times(1)).execute(operationResultInputStreamMock); - assertNotSame(currentThreadId, newThreadId.get()); - assertNotNull(retrieved); - - Mockito.verify(stateMock, times(3)).getPhase(); - Mockito.verify(operationResultInputStreamMock, times(2)).getEntity(); - Mockito.verify(requestInputStreamMock, times(1)).get(); - } - - @Test - public void should_throw_exception_while_fetching_resource_() throws InterruptedException { - - final AtomicInteger newThreadId = new AtomicInteger(); - final int currentThreadId = (int) Thread.currentThread().getId(); - - // ... - PowerMockito.mockStatic(JerseyRequest.class); - PowerMockito.when(buildRequest(eq(sessionStorageMock), - eq(InputStream.class), - eq(new String[]{"export", taskId, "exportFile"}))).thenReturn(requestInputStreamMock); - - ExportRequestAdapter adapterSpy = PowerMockito.spy(new ExportRequestAdapter(sessionStorageMock, taskId)); - - PowerMockito - .doReturn(operationResultInputStreamMock) - .when(adapterSpy) - .state(); - PowerMockito - .doReturn(operationResultInputStreamMock) - .when(requestInputStreamMock) - .get(); - PowerMockito - .doReturn(stateMock) - .when(operationResultInputStreamMock) - .getEntity(); - PowerMockito - .doReturn("failed") - .doReturn("failed") - .when(stateMock) - .getPhase(); - PowerMockito - .doReturn("msg_") - .when(stateMock) - .getMessage(); - - - final Callback, Void> callbackSpy = PowerMockito.spy(new Callback, Void>() { - @Override - public Void execute(OperationResult data) { - newThreadId.set((int) Thread.currentThread().getId()); - synchronized (this) { - this.notify(); - } - return null; - } - }); - - /* When */ - RequestExecution retrieved = adapterSpy.asyncFetch(callbackSpy); - - /* Wait */ - synchronized (callbackSpy) { - callbackSpy.wait(1000); - } - - /* Then */ - assertNotSame(currentThreadId, newThreadId.get()); - assertNotNull(retrieved); - - try { - retrieved.getFuture().get(); - } catch (ExecutionException e) { - assertEquals(e.getMessage(), "com.jaspersoft.jasperserver.jaxrs.client.core.exceptions.ExportFailedException: msg_"); - } - } - - @Test - public void should_throw_exception_while_fetching_resource() throws InterruptedException { - - final AtomicInteger newThreadId = new AtomicInteger(); - final int currentThreadId = (int) Thread.currentThread().getId(); - - // ... - PowerMockito.mockStatic(JerseyRequest.class); - PowerMockito.when(buildRequest(eq(sessionStorageMock), - eq(InputStream.class), - eq(new String[]{"export", taskId, "exportFile"}))).thenReturn(requestInputStreamMock); - - ExportRequestAdapter adapterSpy = PowerMockito.spy(new ExportRequestAdapter(sessionStorageMock, taskId)); - - PowerMockito - .doReturn(operationResultInputStreamMock) - .when(adapterSpy) - .state(); - PowerMockito - .doReturn(operationResultInputStreamMock) - .when(requestInputStreamMock) - .get(); - PowerMockito - .doReturn(stateMock) - .when(operationResultInputStreamMock) - .getEntity(); - PowerMockito - .doReturn("failed") - .doReturn("failed") - .when(stateMock) - .getPhase(); - PowerMockito - .doReturn("msg_") - .when(stateMock) - .getMessage(); - PowerMockito - .doReturn(descriptorMock) - .when(stateMock) - .getError(); - PowerMockito - .doReturn("_msg") - .when(descriptorMock) - .getMessage(); - - - final Callback, Void> callbackSpy = PowerMockito.spy(new Callback, Void>() { - @Override - public Void execute(OperationResult data) { - newThreadId.set((int) Thread.currentThread().getId()); - synchronized (this) { - this.notify(); - } - return null; - } - }); - - /* When */ - RequestExecution retrieved = adapterSpy.asyncFetch(callbackSpy); - - /* Wait */ - synchronized (callbackSpy) { - callbackSpy.wait(1000); - } - - /* Then */ - assertNotSame(currentThreadId, newThreadId.get()); - assertNotNull(retrieved); - - try { - retrieved.getFuture().get(); - } catch (ExecutionException e) { - assertEquals(e.getMessage(), "com.jaspersoft.jasperserver.jaxrs.client.core.exceptions.ExportFailedException: _msg"); - } - } - @AfterMethod public void after() { reset(stateMock, sessionStorageMock, requestStateDtoMock, requestInputStreamMock, diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/importexport/exportservice/ExportServiceTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/importexport/exportservice/ExportServiceTest.java index 5d71392e..0024b291 100644 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/importexport/exportservice/ExportServiceTest.java +++ b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/importexport/exportservice/ExportServiceTest.java @@ -13,7 +13,6 @@ import static org.mockito.MockitoAnnotations.initMocks; import static org.powermock.api.support.membermodification.MemberMatcher.field; import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertSame; /** @@ -37,13 +36,6 @@ public void should_pass_param_to_parent_constructor() { assertSame(service.getSessionStorage(), storageMock); } - @Test - public void should_create_a_new_task_object_and_pass_session_into_the_constructor_of_task() { - ExportTaskAdapter task = service.newTask(); - assertNotNull(task); - assertSame(task.getSessionStorage(), storageMock); - } - @Test public void should_return_proper_ExportRequestAdapter_object() throws IllegalAccessException { ExportRequestAdapter adapter = service.task("k4ks3ds"); diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/importexport/exportservice/ExportTaskAdapterTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/importexport/exportservice/ExportTaskAdapterTest.java deleted file mode 100644 index 262ad3de..00000000 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/importexport/exportservice/ExportTaskAdapterTest.java +++ /dev/null @@ -1,444 +0,0 @@ -package com.jaspersoft.jasperserver.jaxrs.client.apiadapters.importexport.exportservice; - -import com.jaspersoft.jasperserver.dto.importexport.ExportTask; -import com.jaspersoft.jasperserver.dto.importexport.State; -import com.jaspersoft.jasperserver.jaxrs.client.core.Callback; -import com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest; -import com.jaspersoft.jasperserver.jaxrs.client.core.RequestBuilder; -import com.jaspersoft.jasperserver.jaxrs.client.core.RequestExecution; -import com.jaspersoft.jasperserver.jaxrs.client.core.SessionStorage; -import com.jaspersoft.jasperserver.jaxrs.client.core.exceptions.handling.DefaultErrorHandler; -import com.jaspersoft.jasperserver.jaxrs.client.core.operationresult.OperationResult; -import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.atomic.AtomicInteger; -import org.mockito.Mock; -import org.mockito.internal.util.reflection.Whitebox; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.testng.PowerMockTestCase; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import static org.hamcrest.core.IsInstanceOf.instanceOf; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyString; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.reset; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import static org.mockito.MockitoAnnotations.initMocks; -import static org.powermock.api.mockito.PowerMockito.doReturn; -import static org.powermock.api.mockito.PowerMockito.mockStatic; -import static org.powermock.api.support.membermodification.MemberMatcher.field; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNotSame; -import static org.testng.Assert.assertSame; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.assertNull; - -/** - * Unit tests for {@link com.jaspersoft.jasperserver.jaxrs.client.apiadapters.importexport.exportservice.ExportTaskAdapter} - */ -@PrepareForTest({JerseyRequest.class, ExportTaskAdapter.class, ExportTask.class}) -public class ExportTaskAdapterTest extends PowerMockTestCase { - - public static final String EXPORT_TASK_DTO = "exportTask"; - public static final String EXPORT_URI = "export"; - public static final String NEW_URI = "newUri"; - public static final String FIRST_URI = "firstUri"; - public static final String SECOND_URI = "secondUri"; - public static final String RESOURCE_TYPE_1 = "resourceType1"; - public static final String RESOURCE_TYPE_2 = "resourceType2"; - @Mock - private SessionStorage sessionStorageMock; - - @Mock - private JerseyRequest requestStateDtoMock; - - @Mock - private OperationResult operationResultStateDtoMock; - - @Mock - private Callback, Object> callbackMock; - - @Mock - private RequestBuilder requestBuilderMock; - - @Mock - private ExportTask taskDtoMock; - - @Mock - private ExportTask taskDtoCopyMock; - - @BeforeMethod - public void after() { - initMocks(this); - } - - @Test - public void should_create_an_object_and_prepare_ExportTaskDto_field() throws IllegalAccessException { - - // When - ExportTaskAdapter adapter = new ExportTaskAdapter(sessionStorageMock); - Field field = field(ExportTaskAdapter.class, EXPORT_TASK_DTO); - Object retrievedField = field.get(adapter); - - // Then - assertSame(adapter.getSessionStorage(), sessionStorageMock); - assertNotNull(retrievedField); - assertTrue(instanceOf(ExportTask.class).matches(retrievedField)); - - assertNull(((ExportTask) retrievedField).getParameters()); - assertNull(((ExportTask) retrievedField).getRoles()); - assertNull(((ExportTask) retrievedField).getUsers()); - assertNull(((ExportTask) retrievedField).getUris()); - } - - @Test(testName = "role") - public void should_add_new_role_to_roles_of_ExportTaskDto() throws IllegalAccessException { - ExportTaskAdapter adapter = spy(new ExportTaskAdapter(sessionStorageMock)); - String newRole = "newRole"; - ExportTaskAdapter retrievedAdapter = adapter.role(newRole); - - Field field = field(ExportTaskAdapter.class, EXPORT_TASK_DTO); - ExportTask retrieved = (ExportTask) field.get(adapter); - - verify(adapter, times(1)).role(newRole); - assertNotNull(retrievedAdapter); - assertTrue(retrieved.getRoles().size() == 1); - assertTrue(retrieved.getRoles().contains(newRole)); - } - - @Test(testName = "allRoles") - public void should_add_emptyList_to_roles_of_ExportTaskDto() throws IllegalAccessException { - ExportTaskAdapter adapter = spy(new ExportTaskAdapter(sessionStorageMock)); - ExportTaskAdapter retrievedAdapter = adapter.allRoles(); - - Field field = field(ExportTaskAdapter.class, EXPORT_TASK_DTO); - ExportTask retrieved = (ExportTask) field.get(adapter); - - verify(adapter, never()).role(anyString()); - assertNotNull(retrievedAdapter); - assertNotNull(retrieved.getRoles()); - assertTrue(retrieved.getRoles().isEmpty()); - } - - @Test(testName = "roles") - public void should_add_new_roles_of_ExportTaskDto_as_list() throws IllegalAccessException { - - // Given - final List fakeRoles = new ArrayList() {{ - add("SuperManRole"); - add("SlugRole"); - }}; - - ExportTaskAdapter adapter = spy(new ExportTaskAdapter(sessionStorageMock)); - - // When - ExportTaskAdapter retrievedAdapter = adapter.roles(fakeRoles); - Field field = field(ExportTaskAdapter.class, EXPORT_TASK_DTO); - ExportTask retrieved = (ExportTask) field.get(adapter); - - // Then - verify(adapter, times(1)).roles(fakeRoles); - assertNotNull(retrievedAdapter); - assertTrue(retrieved.getRoles().size() == 2); - assertTrue(retrieved.getRoles().contains("SlugRole")); - assertTrue(retrieved.getRoles().contains("SuperManRole")); - } - - @Test(testName = "user") - public void should_add_single_user_to_userList_of_ExportTaskDto() throws IllegalAccessException { - ExportTaskAdapter adapter = spy(new ExportTaskAdapter(sessionStorageMock)); - String newUser = "newUser"; - ExportTaskAdapter retrievedAdapter = adapter.user(newUser); - - Field field = field(ExportTaskAdapter.class, EXPORT_TASK_DTO); - ExportTask retrieved = (ExportTask) field.get(adapter); - - verify(adapter, times(1)).user(newUser); - assertNotNull(retrievedAdapter); - assertTrue(retrieved.getUsers().size() == 1); - assertTrue(retrieved.getUsers().contains(newUser)); - } - - @Test(testName = "users") - public void should_add_bunch_of_users_to_userList_of_ExportTaskDto() throws IllegalAccessException { - - // Given - final List girls = new ArrayList() {{ - add("Catherine"); - add("Angelina"); - add("Katy"); - }}; - - ExportTaskAdapter adapter = spy(new ExportTaskAdapter(sessionStorageMock)); - - // When - ExportTaskAdapter retrievedAdapter = adapter.users(girls); - Field field = field(ExportTaskAdapter.class, EXPORT_TASK_DTO); - ExportTask exportTaskDto = (ExportTask) field.get(adapter); - - // Then - verify(adapter, times(1)).users(girls); - assertNotNull(retrievedAdapter); - assertTrue(exportTaskDto.getUsers().size() == 3); - assertTrue(exportTaskDto.getUsers().contains("Catherine")); - assertTrue(exportTaskDto.getUsers().contains("Angelina")); - } - - @Test(testName = "users") - public void should_add_emptyList_to_userList_of_ExportTaskDto() throws IllegalAccessException { - - // Given - ExportTaskAdapter adapter = spy(new ExportTaskAdapter(sessionStorageMock)); - - // When - ExportTaskAdapter retrievedAdapter = adapter.allUsers(); - Field field = field(ExportTaskAdapter.class, EXPORT_TASK_DTO); - ExportTask exportTaskDto = (ExportTask) field.get(adapter); - - // Then - verify(adapter, never()).user(anyString()); - assertNotNull(retrievedAdapter); - assertNotNull(exportTaskDto.getUsers()); - assertTrue(exportTaskDto.getUsers().isEmpty()); - } - - @Test(testName = "organization") - public void should_add_an_organization_to_ExportTaskDto() throws IllegalAccessException { - String organization = "organization"; - ExportTaskAdapter adapter = spy(new ExportTaskAdapter(sessionStorageMock)); - ExportTaskAdapter retrievedAdapter = adapter.organization(organization); - - Field field = field(ExportTaskAdapter.class, EXPORT_TASK_DTO); - ExportTask retrieved = (ExportTask) field.get(adapter); - - verify(adapter, times(1)).organization(organization); - assertNotNull(retrievedAdapter); - assertEquals(organization, Whitebox.getInternalState(retrieved, "organization")); - } - @Test(testName = "uri") - public void should_add_a_single_uri_to_uriList_of_ExportTaskDto() throws IllegalAccessException { - ExportTaskAdapter adapter = spy(new ExportTaskAdapter(sessionStorageMock)); - ExportTaskAdapter retrievedAdapter = adapter.uri(NEW_URI); - - Field field = field(ExportTaskAdapter.class, EXPORT_TASK_DTO); - ExportTask retrieved = (ExportTask) field.get(adapter); - - verify(adapter, times(1)).uri(NEW_URI); - assertNotNull(retrievedAdapter); - assertTrue(retrieved.getUris().size() == 1); - assertTrue(retrieved.getUris().contains(NEW_URI)); - } - - @Test(testName = "uris") - public void should_add_list_of_uri_to_uriList_of_ExportTaskDto() throws IllegalAccessException { - - final List uris = new ArrayList() {{ - add(FIRST_URI); - add(SECOND_URI); - }}; - - ExportTaskAdapter adapter = spy(new ExportTaskAdapter(sessionStorageMock)); - - ExportTaskAdapter retrievedAdapter = adapter.uris(uris); - Field field = field(ExportTaskAdapter.class, EXPORT_TASK_DTO); - ExportTask exportTaskDto = (ExportTask) field.get(adapter); - - verify(adapter, times(1)).uris(uris); - assertNotNull(retrievedAdapter); - assertTrue(exportTaskDto.getUris().size() == 2); - assertTrue(exportTaskDto.getUris().contains(FIRST_URI)); - assertFalse(exportTaskDto.getUris().contains("notAUri")); - } - - @Test(testName = "scheduledJobs") - public void should_add_list_of_scheduled_jobs_to_list_of_ExportTaskDto() throws IllegalAccessException { - - final List uris = new ArrayList() {{ - add(FIRST_URI); - add(SECOND_URI); - }}; - - ExportTaskAdapter adapter = spy(new ExportTaskAdapter(sessionStorageMock)); - - ExportTaskAdapter retrievedAdapter = adapter.scheduledJobs(uris); - Field field = field(ExportTaskAdapter.class, EXPORT_TASK_DTO); - ExportTask exportTaskDto = (ExportTask) field.get(adapter); - - verify(adapter, times(1)).scheduledJobs(uris); - assertNotNull(retrievedAdapter); - assertTrue(exportTaskDto.getScheduledJobs().size() == 2); - assertTrue(exportTaskDto.getScheduledJobs().contains(FIRST_URI)); - assertTrue(exportTaskDto.getScheduledJobs().contains(SECOND_URI)); - assertFalse(exportTaskDto.getScheduledJobs().contains("notAUri")); - } - - @Test(testName = "scheduledJob") - public void should_add_a_single_scheduled_job_to_list_of_ExportTaskDtp() throws IllegalAccessException { - ExportTaskAdapter adapter = spy(new ExportTaskAdapter(sessionStorageMock)); - ExportTaskAdapter retrievedAdapter = adapter.scheduledJob(NEW_URI); - - Field field = field(ExportTaskAdapter.class, EXPORT_TASK_DTO); - ExportTask retrieved = (ExportTask) field.get(adapter); - - verify(adapter, times(1)).scheduledJob(NEW_URI); - assertNotNull(retrievedAdapter); - assertTrue(retrieved.getScheduledJobs().size() == 1); - assertTrue(retrieved.getScheduledJobs().contains(NEW_URI)); - } - - @Test(testName = "resourceType") - public void should_add_list_of_resource_types_to_list_of_ExportTaskDto() throws IllegalAccessException { - - final List uris = new ArrayList() {{ - add(RESOURCE_TYPE_1); - add(RESOURCE_TYPE_2); - }}; - - ExportTaskAdapter adapter = spy(new ExportTaskAdapter(sessionStorageMock)); - - ExportTaskAdapter retrievedAdapter = adapter.resourceTypes(uris); - Field field = field(ExportTaskAdapter.class, EXPORT_TASK_DTO); - ExportTask exportTaskDto = (ExportTask) field.get(adapter); - - verify(adapter, times(1)).resourceTypes(uris); - assertNotNull(retrievedAdapter); - assertTrue(exportTaskDto.getResourceTypes().size() == 2); - assertTrue(exportTaskDto.getResourceTypes().contains(RESOURCE_TYPE_1)); - assertTrue(exportTaskDto.getResourceTypes().contains(RESOURCE_TYPE_2)); - } - - @Test(testName = "resourceTypes") - public void should_add_a_single_resource_type_to_list_of_ExportTaskDtp() throws IllegalAccessException { - ExportTaskAdapter adapter = spy(new ExportTaskAdapter(sessionStorageMock)); - ExportTaskAdapter retrievedAdapter = adapter.resourceType(RESOURCE_TYPE_1); - - Field field = field(ExportTaskAdapter.class, EXPORT_TASK_DTO); - ExportTask retrieved = (ExportTask) field.get(adapter); - - verify(adapter, times(1)).resourceType(RESOURCE_TYPE_1); - assertNotNull(retrievedAdapter); - assertTrue(retrieved.getResourceTypes().size() == 1); - assertTrue(retrieved.getResourceTypes().contains(RESOURCE_TYPE_1)); - } - - @Test(testName = "parameter") - public void should_add_a_single_parameter_to_parameters_of_ExportTaskDto() throws IllegalAccessException { - - ExportTaskAdapter adapter = spy(new ExportTaskAdapter(sessionStorageMock)); - ExportTaskAdapter retrievedAdapter = adapter.parameter(ExportParameter.INCLUDE_MONITORING_EVENTS); - - Field field = field(ExportTaskAdapter.class, EXPORT_TASK_DTO); - ExportTask retrieved = (ExportTask) field.get(adapter); - - verify(adapter, times(1)).parameter(ExportParameter.INCLUDE_MONITORING_EVENTS); - assertNotNull(retrievedAdapter); - assertTrue(retrieved.getParameters().size() == 1); - assertTrue(retrieved.getParameters() - .contains(ExportParameter.INCLUDE_MONITORING_EVENTS.getParamName())); - } - - @Test(testName = "parameters") - public void should_add_parameters_to_params_of_ExportTaskDto_instance() throws IllegalAccessException { - - final List params = new ArrayList() {{ - add(ExportParameter.REPOSITORY_PERMISSIONS); - add(ExportParameter.INCLUDE_ACCESS_EVENTS); - }}; - - ExportTaskAdapter adapter = spy(new ExportTaskAdapter(sessionStorageMock)); - - ExportTaskAdapter retrievedAdapter = adapter.parameters(params); - Field field = field(ExportTaskAdapter.class, EXPORT_TASK_DTO); - ExportTask exportTaskDto = (ExportTask) field.get(adapter); - - verify(adapter, times(1)).parameters(params); - assertNotNull(retrievedAdapter); - assertTrue(exportTaskDto.getParameters().size() == 2); - assertTrue(exportTaskDto.getParameters() - .contains(ExportParameter.REPOSITORY_PERMISSIONS.getParamName())); - } - - @Test(testName = "create") - public void should_return_not_null_op_result() throws IllegalAccessException { - - // Given - ExportTaskAdapter adapter = spy(new ExportTaskAdapter(sessionStorageMock)); - mockStatic(JerseyRequest.class); - when(JerseyRequest.buildRequest(eq(sessionStorageMock), eq(State.class), eq(new String[]{EXPORT_URI}), - any(DefaultErrorHandler.class))) - .thenReturn(requestStateDtoMock); - - Field field = field(ExportTaskAdapter.class, EXPORT_TASK_DTO); - ExportTask exportTaskDto = (ExportTask) field.get(adapter); - when(requestStateDtoMock.post(exportTaskDto)).thenReturn(operationResultStateDtoMock); - - // When - OperationResult retrieved = adapter.create(); - - // Then - assertSame(retrieved, operationResultStateDtoMock); - } - - @Test - public void should_execute_create_operation_asynchronously() throws Exception { - - // Given - final AtomicInteger newThreadId = new AtomicInteger(); - final int currentThreadId = (int) Thread.currentThread().getId(); - - ExportTaskAdapter taskAdapterSpy = PowerMockito.spy(new ExportTaskAdapter(sessionStorageMock)); - PowerMockito.whenNew(ExportTask.class).withArguments(any((ExportTask.class))).thenReturn(taskDtoCopyMock); - PowerMockito.mockStatic(JerseyRequest.class); - - PowerMockito.when(JerseyRequest.buildRequest( - eq(sessionStorageMock), - eq(State.class), - eq(new String[]{EXPORT_URI}))) - .thenReturn(requestStateDtoMock); - - final Callback, Void> callback = PowerMockito.spy(new Callback, Void>() { - @Override - public Void execute(OperationResult data) { - newThreadId.set((int) Thread.currentThread().getId()); - synchronized (this) { - this.notify(); - } - return null; - } - }); - - doReturn(operationResultStateDtoMock).when(requestStateDtoMock).post(taskDtoCopyMock); - doReturn(null).when(callback).execute(operationResultStateDtoMock); - - // When - RequestExecution retrieved = taskAdapterSpy.asyncCreate(callback); - - // Wait - synchronized (callback) { - callback.wait(1000); - } - - // Then - assertNotNull(retrieved); - assertNotSame(currentThreadId, newThreadId.get()); - verify(callback, times(1)).execute(operationResultStateDtoMock); - verify(requestStateDtoMock, times(1)).post(taskDtoCopyMock); - } - - @AfterMethod - public void before() { - reset(sessionStorageMock, requestStateDtoMock, operationResultStateDtoMock, requestBuilderMock, - taskDtoMock, callbackMock, taskDtoCopyMock); - } -} \ No newline at end of file diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/importexport/importservice/ImportRequestAdapterTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/importexport/importservice/ImportRequestAdapterTest.java index 403f7af7..8c8480fe 100644 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/importexport/importservice/ImportRequestAdapterTest.java +++ b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/importexport/importservice/ImportRequestAdapterTest.java @@ -12,7 +12,7 @@ import java.util.List; import java.util.concurrent.atomic.AtomicInteger; import org.mockito.Mock; -import org.mockito.internal.util.reflection.Whitebox; +import org.powermock.reflect.Whitebox; import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.testng.PowerMockTestCase; @@ -22,8 +22,8 @@ import org.testng.annotations.Test; import static java.util.Arrays.asList; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.reset; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.times; @@ -42,9 +42,6 @@ public class ImportRequestAdapterTest extends PowerMockTestCase { public static final String TASK_ID = "taskId"; - private static final String IMPORT_TASK = "importTask"; - public static final String PARAM = "param"; - public static final String PARAM1 = "param1"; @Mock private SessionStorage storageMock; @@ -53,8 +50,6 @@ public class ImportRequestAdapterTest extends PowerMockTestCase { @Mock private JerseyRequest taskRequestMock; - @Mock - private JerseyRequest deleteRequestMock; @Mock private OperationResult stateOperationResultMock; @@ -62,8 +57,6 @@ public class ImportRequestAdapterTest extends PowerMockTestCase { @Mock private OperationResult taskOperationResultMock; - @Mock - private OperationResult deleteOperationResultMock; private String[] fakeArrayPathForState = new String[]{"import", TASK_ID, "state"}; private String[] fakeArrayPathForTask= new String[]{"import", TASK_ID}; @@ -88,62 +81,6 @@ public void should_pass_corresponding_params_to_the_constructor_and_invoke_paren assertEquals(retrievedSessionStorage, storageMock); } - @Test(testName = "parameter") - public void should_pass_param_to_the_importTask_object() throws IllegalAccessException { - ImportRequestAdapter adapter = spy(new ImportRequestAdapter(storageMock, TASK_ID)); - ImportRequestAdapter retrievedAdapter = adapter.parameter(PARAM); - - Field field = field(ImportRequestAdapter.class, IMPORT_TASK); - ImportTask retrieved = (ImportTask) field.get(adapter); - - verify(adapter, times(1)).parameter(PARAM); - assertNotNull(retrievedAdapter); - assertTrue(retrieved.getParameters().size() == 1); - - } - - @Test(testName = "parameter") - public void should_pass_organization_to_the_importTask_object() throws IllegalAccessException { - String orgId = "orgId"; - ImportRequestAdapter adapter = spy(new ImportRequestAdapter(storageMock, TASK_ID)); - ImportRequestAdapter retrievedAdapter = adapter.organization(orgId); - - Field field = field(ImportRequestAdapter.class, IMPORT_TASK); - ImportTask retrieved = (ImportTask) field.get(adapter); - - verify(adapter, times(1)).organization(orgId); - assertNotNull(retrievedAdapter); - assertNotNull(retrieved); - assertEquals(orgId, Whitebox.getInternalState(retrieved, "organization")); - } - - @Test(testName = "brokenDependencies") - public void should_pass_brokenDependencies_parameter_to_the_importTask_object() throws IllegalAccessException { - ImportRequestAdapter adapter = spy(new ImportRequestAdapter(storageMock, TASK_ID)); - ImportRequestAdapter retrievedAdapter = adapter.brokenDependensies(BrokenDependenciesParameter.FAIL); - - Field field = field(ImportRequestAdapter.class, IMPORT_TASK); - ImportTask retrieved = (ImportTask) field.get(adapter); - - verify(adapter, times(1)).brokenDependensies(BrokenDependenciesParameter.FAIL); - assertNotNull(retrievedAdapter); - assertNotNull(retrieved); - assertEquals(BrokenDependenciesParameter.FAIL.getValueName(), Whitebox.getInternalState(retrieved, "brokenDependencies")); - } - @Test(testName = "parameters") - public void should_pass_params_to_the_importTask_object() throws IllegalAccessException { - ImportRequestAdapter adapter = spy(new ImportRequestAdapter(storageMock, TASK_ID)); - List parameters = asList(PARAM, PARAM1); - ImportRequestAdapter retrievedAdapter = adapter.parameters(parameters); - - Field field = field(ImportRequestAdapter.class, IMPORT_TASK); - ImportTask retrieved = (ImportTask) field.get(adapter); - - verify(adapter, times(1)).parameters(parameters); - assertNotNull(retrievedAdapter); - assertTrue(retrieved.getParameters().size() == 2); - } - @Test(testName = "state") public void should_return_proper_OperationResult_object() { @@ -195,22 +132,6 @@ public void should_return_proper_OperationResult_object_when_restart_task() { // Then assertSame(opResult, taskOperationResultMock); } - @Test(testName = "restartTask") - public void should_return_proper_OperationResult_object_when_cancel_task() { - // Given - PowerMockito.mockStatic(JerseyRequest.class); - PowerMockito.when(JerseyRequest.buildRequest(eq(storageMock), - eq(Object.class), - eq(fakeArrayPathForTask))).thenReturn(deleteRequestMock); - PowerMockito.when(deleteRequestMock.delete()).thenReturn(deleteOperationResultMock); - - // When - ImportRequestAdapter adapter = new ImportRequestAdapter(storageMock, TASK_ID); - OperationResult opResult = adapter.cancelTask(); - - // Then - assertSame(opResult, deleteOperationResultMock); - } @Test public void should_retrieve_state_asynchronously () throws InterruptedException { @@ -238,7 +159,7 @@ public Void execute(OperationResult data) { } }); - PowerMockito.doReturn(null).when(callback).execute(stateOperationResultMock); + PowerMockito.doNothing().when(callback).execute(stateOperationResultMock); /* When */ RequestExecution retrieved = adapterSpy.asyncState(callback); diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/importexport/importservice/ImportServiceTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/importexport/importservice/ImportServiceTest.java index 3f56a2c8..ed977a65 100644 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/importexport/importservice/ImportServiceTest.java +++ b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/importexport/importservice/ImportServiceTest.java @@ -13,7 +13,6 @@ import static org.mockito.MockitoAnnotations.initMocks; import static org.powermock.api.support.membermodification.MemberMatcher.field; import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertSame; /** @@ -37,12 +36,6 @@ public void should_pass_param_to_parent_constructor() { assertSame(service.getSessionStorage(), storageMock); } - @Test - public void should_create_a_new_task_object_and_pass_session_into_the_constructor_of_task() { - ImportTaskRequestAdapter task = service.newTask(); - assertNotNull(task); - assertSame(task.getSessionStorage(), storageMock); - } @Test public void should_return_proper_ExportRequestAdapter_object() throws IllegalAccessException { diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/importexport/importservice/ImportTaskRequestAdapterTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/importexport/importservice/ImportTaskRequestAdapterTest.java deleted file mode 100644 index bbf60d08..00000000 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/importexport/importservice/ImportTaskRequestAdapterTest.java +++ /dev/null @@ -1,301 +0,0 @@ -package com.jaspersoft.jasperserver.jaxrs.client.apiadapters.importexport.importservice; - -import com.jaspersoft.jasperserver.jaxrs.client.core.Callback; -import com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest; -import com.jaspersoft.jasperserver.jaxrs.client.core.RequestBuilder; -import com.jaspersoft.jasperserver.jaxrs.client.core.RequestExecution; -import com.jaspersoft.jasperserver.jaxrs.client.core.SessionStorage; -import com.jaspersoft.jasperserver.jaxrs.client.core.exceptions.handling.DefaultErrorHandler; -import com.jaspersoft.jasperserver.jaxrs.client.core.operationresult.OperationResult; -import com.jaspersoft.jasperserver.dto.importexport.State; -import org.mockito.InOrder; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.testng.PowerMockTestCase; -import org.testng.Assert; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import javax.ws.rs.core.MultivaluedHashMap; -import javax.ws.rs.core.MultivaluedMap; -import java.io.File; -import java.io.InputStream; -import java.lang.reflect.Field; -import java.util.List; - -import static com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest.buildRequest; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.reset; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.MockitoAnnotations.initMocks; -import static org.powermock.api.mockito.PowerMockito.doReturn; -import static org.powermock.api.mockito.PowerMockito.mock; -import static org.powermock.api.mockito.PowerMockito.verifyPrivate; -import static org.powermock.api.support.membermodification.MemberMatcher.field; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertSame; -import static org.testng.Assert.assertTrue; - -/** - * Unit tests for {@link com.jaspersoft.jasperserver.jaxrs.client.apiadapters.importexport.importservice.ImportTaskRequestAdapter} - */ -@PrepareForTest({JerseyRequest.class, ImportTaskRequestAdapter.class}) -public class ImportTaskRequestAdapterTest extends PowerMockTestCase { - - @Mock - private File fileMock; - - @Mock - private SessionStorage sessionStorageMock; - - @Mock - private JerseyRequest requestStateDtoMock; - - @Mock - private OperationResult operationResultStateDtoMock; - - @Mock - private Callback, Object> callbackMock; - - @Mock - private MultivaluedHashMap mapMock; - - @Mock - private RequestBuilder requestBuilderMock; - - @BeforeMethod - public void after() { - initMocks(this); - } - - @Test - @SuppressWarnings("unchecked") - public void should_add_boolean_param_to_private_field() throws IllegalAccessException { - - // When - ImportTaskRequestAdapter expected = spy(new ImportTaskRequestAdapter(sessionStorageMock)); - ImportTaskRequestAdapter retrieved = expected.parameter(ImportParameter.INCLUDE_ACCESS_EVENTS, Boolean.TRUE); - - Field field = field(ImportTaskRequestAdapter.class, "params"); - MultivaluedMap retrievedParams = (MultivaluedMap) field.get(retrieved); - - // Then - verify(expected, times(1)).parameter(ImportParameter.INCLUDE_ACCESS_EVENTS, Boolean.TRUE); - assertSame(retrieved, expected); - - List booleanValue = retrievedParams.get(ImportParameter.INCLUDE_ACCESS_EVENTS.getParamName()); - Boolean val = Boolean.valueOf(booleanValue.get(0)); - - assertTrue(val); - } - - @Test - @SuppressWarnings("unchecked") - public void should_add_string_param_to_private_field() throws IllegalAccessException { - - // When - ImportTaskRequestAdapter expected = spy(new ImportTaskRequestAdapter(sessionStorageMock)); - ImportTaskRequestAdapter retrieved = expected.parameter(ImportParameter.ORGANIZATION, "org_1"); - - Field field = field(ImportTaskRequestAdapter.class, "params"); - MultivaluedMap retrievedParams = (MultivaluedMap) field.get(retrieved); - - // Then - verify(expected, times(1)).parameter(ImportParameter.ORGANIZATION, "org_1"); - assertSame(retrieved, expected); - assertNotNull(retrievedParams); - - List stringValues = retrievedParams.get(ImportParameter.ORGANIZATION.getParamName()); - String val = stringValues.get(0); - assertEquals(val, "org_1"); - - } - - @Test - @SuppressWarnings("unchecked") - public void should_add_enum_param_to_private_field() throws IllegalAccessException { - - // When - ImportTaskRequestAdapter expected = spy(new ImportTaskRequestAdapter(sessionStorageMock)); - ImportTaskRequestAdapter retrieved = expected.parameter(ImportParameter.BROKEN_DEPENDENCIES, BrokenDependenciesParameter.INCLUDE); - - Field field = field(ImportTaskRequestAdapter.class, "params"); - MultivaluedMap retrievedParams = (MultivaluedMap) field.get(retrieved); - - // Then - verify(expected, times(1)).parameter(ImportParameter.BROKEN_DEPENDENCIES, BrokenDependenciesParameter.INCLUDE); - assertSame(retrieved, expected); - - List enumValue = retrievedParams.get(ImportParameter.BROKEN_DEPENDENCIES.getParamName()); - List stringValues = retrievedParams.get(ImportParameter.BROKEN_DEPENDENCIES.getParamName()); - String val = stringValues.get(0); - assertEquals(val, "include"); - - } - - @Test(testName = "create_with_File_param") - public void should_invoke_private_method_and_return_op_result() throws Exception { - - // Given - ImportTaskRequestAdapter adapter = PowerMockito.spy(new ImportTaskRequestAdapter(sessionStorageMock)); - doReturn(operationResultStateDtoMock).when(adapter, "createImport", fileMock); - - // When - OperationResult retrieved = adapter.create(fileMock); - - // Then - verifyPrivate(adapter).invoke("createImport", eq(fileMock)); - assertNotNull(retrieved); - assertSame(retrieved, operationResultStateDtoMock); - } - - @Test(testName = "create_with_InputStream_param") - public void should_pass_InputStream_param_and_invoke_private_method() throws Exception { - - InputStream streamMock = mock(InputStream.class); - - // Given - ImportTaskRequestAdapter adapter = PowerMockito.spy(new ImportTaskRequestAdapter(sessionStorageMock)); - doReturn(operationResultStateDtoMock).when(adapter, "createImport", streamMock); - - // When - OperationResult retrieved = adapter.create(streamMock); - - // Then - verifyPrivate(adapter).invoke("createImport", eq(streamMock)); - assertNotNull(retrieved); - assertSame(retrieved, operationResultStateDtoMock); - } - - @Test(testName = "asyncCreate_with_File_param") - public void should_invoke_private_method_with_File_parameter_and_return_RequestExecution_object() throws Exception { - - // Given - RequestExecution requestExecutionMock = mock(RequestExecution.class); - ImportTaskRequestAdapter adapter = PowerMockito.spy(new ImportTaskRequestAdapter(sessionStorageMock)); - doReturn(requestExecutionMock).when(adapter, "asyncCreateImport", fileMock, callbackMock); - - // When - RequestExecution retrieved = adapter.asyncCreate(fileMock, callbackMock); - - // Then - assertNotNull(retrieved); - verifyPrivate(adapter).invoke("asyncCreateImport", eq(fileMock), eq(callbackMock)); - assertSame(retrieved, requestExecutionMock); - } - - @Test(testName = "asyncCreate_with_InputStream_param") - public void should_invoke_private_method_with_InputStream_parameter_and_return_RequestExecution_object() throws Exception { - // Given - RequestExecution requestExecutionMock = mock(RequestExecution.class); - InputStream streamMock = mock(InputStream.class); - ImportTaskRequestAdapter adapter = PowerMockito.spy(new ImportTaskRequestAdapter(sessionStorageMock)); - doReturn(requestExecutionMock).when(adapter, "asyncCreateImport", streamMock, callbackMock); - - // When - RequestExecution retrieved = adapter.asyncCreate(streamMock, callbackMock); - - // Then - assertNotNull(retrieved); - verifyPrivate(adapter).invoke("asyncCreateImport", eq(streamMock), eq(callbackMock)); - assertSame(retrieved, requestExecutionMock); - } - - @Test/*(timeOut = 2000)*/ - public void should_execute_create_operation_asynchronously() throws Exception { - - // Given - Object resultMock = PowerMockito.mock(Object.class); - ImportTaskRequestAdapter requestAdapterSpy = PowerMockito.spy(new ImportTaskRequestAdapter(sessionStorageMock)); - - PowerMockito.whenNew(MultivaluedHashMap.class).withNoArguments().thenReturn(mapMock); - PowerMockito.mockStatic(JerseyRequest.class); - PowerMockito.when( - buildRequest( - eq(sessionStorageMock), - eq(State.class), - eq(new String[]{"import"}))) - .thenReturn(requestStateDtoMock); - - InOrder inOrder = Mockito.inOrder(requestStateDtoMock); - - PowerMockito.doReturn(requestBuilderMock).when(requestStateDtoMock).setContentType("application/zip"); - PowerMockito.doReturn(requestBuilderMock).when(requestBuilderMock).addParams(mapMock); - PowerMockito.doReturn(operationResultStateDtoMock).when(requestStateDtoMock).post(fileMock); - PowerMockito.doReturn(resultMock).when(callbackMock).execute(operationResultStateDtoMock); - - // When - RequestExecution retrieved = requestAdapterSpy.asyncCreate(fileMock, callbackMock); - - // Then - Assert.assertNotNull(retrieved); - Assert.assertNotNull(resultMock); - - PowerMockito.verifyStatic(times(1)); - JerseyRequest.buildRequest( - eq(sessionStorageMock), - eq(State.class), - eq(new String[]{"import"})); - - Thread.sleep(500); - - Mockito.verify(callbackMock, times(1)).execute(operationResultStateDtoMock); - - inOrder.verify(requestStateDtoMock, times(1)).setContentType("application/zip"); - inOrder.verify(requestStateDtoMock, times(1)).post(fileMock); - - Mockito.verifyNoMoreInteractions(requestStateDtoMock); - Mockito.verifyNoMoreInteractions(callbackMock); - } - - @Test - public void should_create_resource_and_return_proper_op_result() throws Exception { - - // Given - ImportTaskRequestAdapter requestAdapterSpy = PowerMockito.spy(new ImportTaskRequestAdapter(sessionStorageMock)); - - PowerMockito.mockStatic(JerseyRequest.class); - PowerMockito.when( - buildRequest( - eq(sessionStorageMock), - eq(State.class), - eq(new String[]{"import"}), - any(DefaultErrorHandler.class))) - .thenReturn(requestStateDtoMock); - - PowerMockito.doReturn(requestBuilderMock).when(requestStateDtoMock).setContentType("application/zip"); - PowerMockito.doReturn(requestBuilderMock).when(requestBuilderMock).addParams(mapMock); - PowerMockito.doReturn(operationResultStateDtoMock).when(requestStateDtoMock).post(fileMock); - - InOrder inOrder = Mockito.inOrder(requestStateDtoMock); - - // When - OperationResult retrieved = requestAdapterSpy.create(fileMock); - - // Then - Assert.assertSame(retrieved, operationResultStateDtoMock); - - PowerMockito.verifyStatic(times(1)); - JerseyRequest.buildRequest( - eq(sessionStorageMock), - eq(State.class), - eq(new String[]{"import"}), - any(DefaultErrorHandler.class)); - - inOrder.verify(requestStateDtoMock, times(1)).setContentType("application/zip"); - inOrder.verify(requestStateDtoMock, times(1)).post(fileMock); - } - - @AfterMethod - public void before() { - reset(sessionStorageMock, requestStateDtoMock, operationResultStateDtoMock, callbackMock, - mapMock, requestBuilderMock); - } -} \ No newline at end of file diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/inputControls/InputControlsAdapterTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/inputControls/InputControlsAdapterTest.java index 724aeff9..dc824d29 100644 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/inputControls/InputControlsAdapterTest.java +++ b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/inputControls/InputControlsAdapterTest.java @@ -6,7 +6,6 @@ import com.jaspersoft.jasperserver.jaxrs.client.core.SessionStorage; import com.jaspersoft.jasperserver.jaxrs.client.core.exceptions.MandatoryParameterNotFoundException; import com.jaspersoft.jasperserver.jaxrs.client.core.operationresult.OperationResult; -import java.util.LinkedList; import org.mockito.Mock; import org.mockito.Mockito; import org.powermock.core.classloader.annotations.PrepareForTest; @@ -16,10 +15,12 @@ import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; +import java.util.LinkedList; + import static com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest.buildRequest; -import static org.mockito.Matchers.anyObject; -import static org.mockito.Matchers.anyString; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.reset; import static org.mockito.MockitoAnnotations.initMocks; import static org.powermock.api.mockito.PowerMockito.doReturn; @@ -35,7 +36,7 @@ /** * @author Tetiana Iefimenko */ -@PrepareForTest({InputControlsAdapter.class, JerseyRequest.class, OperationResult.class}) +@PrepareForTest({InputControlsAdapter.class, InputControlsValuesAdapter.class, JerseyRequest.class, OperationResult.class}) public class InputControlsAdapterTest extends PowerMockTestCase { @Mock @@ -57,7 +58,7 @@ public void before() { @Test(expectedExceptions = MandatoryParameterNotFoundException.class) public void should_throw_an_exception_when_uri_is_null() { // When - new InputControlsAdapter(sessionStorageMock).container(null).get(); + new InputControlsAdapter(sessionStorageMock).forReport(null).get(); // Then // should be thrown an exception } @@ -80,7 +81,7 @@ public void should_return_adapter_instance() throws Exception { InputControlsAdapter adapter= new InputControlsAdapter(sessionStorageMock); whenNew(InputControlsValuesAdapter.class).withArguments(eq(sessionStorageMock), anyString()).thenReturn(inputControlsValuesAdapterMock); // When - InputControlsValuesAdapter retrieved = adapter.values(); + InputControlsValuesAdapter retrieved = adapter.forReport("/uri").values(); // Then assertSame(retrieved, inputControlsValuesAdapterMock); } @@ -109,13 +110,13 @@ public void should_return_proper_operation_result_when_invoke_get() { .get(); InputControlsAdapter adapterSpy = spy(new InputControlsAdapter(sessionStorageMock)); - adapterSpy.container(uri); + adapterSpy.forReport(uri); // When OperationResult retrieved = adapterSpy.get(); // Then - verifyStatic(); + verifyStatic(JerseyRequest.class); buildRequest( eq(sessionStorageMock), eq(ReportInputControlsListWrapper.class), @@ -140,23 +141,23 @@ public void should_return_proper_operation_result_when_invoke_reorder() { doReturn(operationResultMock) .when(requestMock) - .put(anyObject()); + .put(any()); InputControlsAdapter adapterSpy = spy(new InputControlsAdapter(sessionStorageMock)); - adapterSpy.container(uri); + adapterSpy.forReport(uri); // When OperationResult retrieved = adapterSpy .reorder(new LinkedList()); // Then - verifyStatic(); + verifyStatic(JerseyRequest.class); buildRequest( eq(sessionStorageMock), eq(ReportInputControlsListWrapper.class), eq(new String[]{"reports", uri, "inputControls"})); - Mockito.verify(requestMock).put(anyObject()); + Mockito.verify(requestMock).put(any()); assertNotNull(retrieved); assertSame(retrieved, operationResultMock); } @@ -180,13 +181,13 @@ public void should_invoke_adding_parameter() { .get(); InputControlsAdapter adapterSpy = spy(new InputControlsAdapter(sessionStorageMock)); - adapterSpy.container(uri).excludeState(true); + adapterSpy.forReport(uri).excludeState(true); // When OperationResult retrieved = adapterSpy.get(); // Then - verifyStatic(); + verifyStatic(JerseyRequest.class); buildRequest( eq(sessionStorageMock), eq(ReportInputControlsListWrapper.class), diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/inputControls/InputControlsValuesAdapterTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/inputControls/InputControlsValuesAdapterTest.java index 2dddd45b..70b4d804 100644 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/inputControls/InputControlsValuesAdapterTest.java +++ b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/inputControls/InputControlsValuesAdapterTest.java @@ -15,8 +15,7 @@ import org.testng.annotations.Test; import static com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest.buildRequest; -import static org.mockito.Matchers.anyObject; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.reset; import static org.mockito.MockitoAnnotations.initMocks; import static org.powermock.api.mockito.PowerMockito.doReturn; @@ -96,7 +95,7 @@ public void should_return_proper_operation_result_when_invoke_get() { OperationResult retrieved = adapterSpy.get(); // Then - verifyStatic(); + verifyStatic(JerseyRequest.class); buildRequest( eq(sessionStorageMock), eq(InputControlStateListWrapper.class), @@ -134,7 +133,7 @@ public void should_invoke_use_cashed_data() { OperationResult retrieved = adapterSpy.get(); // Then - verifyStatic(); + verifyStatic(JerseyRequest.class); buildRequest( eq(sessionStorageMock), eq(InputControlStateListWrapper.class), @@ -147,79 +146,6 @@ public void should_invoke_use_cashed_data() { assertSame(retrieved, operationResultMock); } - @Test - public void should_return_proper_operation_result__when_invoke_post() { - - // Given - mockStatic(JerseyRequest.class); - when(buildRequest( - eq(sessionStorageMock), - eq(InputControlStateListWrapper.class), - eq(new String[]{"reports", uri, "inputControls", "param1;param2", "values"})) - ).thenReturn(requestMock); - - doReturn(operationResultMock) - .when(requestMock) - .post(anyObject()); - - InputControlsValuesAdapter adapterSpy = spy(new InputControlsValuesAdapter(sessionStorageMock, uri)); - - // When - OperationResult retrieved = adapterSpy - .parameter("param1", "value1") - .parameter("param2", "value2", "value3") - .run(); - - // Then - verifyStatic(); - buildRequest( - eq(sessionStorageMock), - eq(InputControlStateListWrapper.class), - eq(new String[]{"reports", uri, "inputControls", "param1;param2", "values"})); - - Mockito.verify(requestMock).post(anyObject()); - Mockito.verify(requestMock).post(anyObject()); - assertNotNull(retrieved); - assertSame(retrieved, operationResultMock); - } - - @Test - public void should_invoke_include_full_structure() { - - // Given - mockStatic(JerseyRequest.class); - when(buildRequest( - eq(sessionStorageMock), - eq(InputControlStateListWrapper.class), - eq(new String[]{"reports", uri, "inputControls", "values"})) - ).thenReturn(requestMock); - - doReturn(operationResultMock) - .when(requestMock) - .post(anyObject()); - - InputControlsValuesAdapter adapterSpy = spy(new InputControlsValuesAdapter(sessionStorageMock, uri)); - - // When - OperationResult retrieved = adapterSpy - .parameter("param1", "value1") - .parameter("param2", "value2") - .includeFullStructure(true) - .run(); - - // Then - verifyStatic(); - buildRequest( - eq(sessionStorageMock), - eq(InputControlStateListWrapper.class), - eq(new String[]{"reports", uri, "inputControls", "values"})); - - Mockito.verify(requestMock).post(anyObject()); - assertEquals(Whitebox.getInternalState(adapterSpy, "includeFullStructure"), Boolean.TRUE); - assertNotNull(retrieved); - assertSame(retrieved, operationResultMock); - } - @AfterMethod public void after() { reset(sessionStorageMock, requestMock, operationResultMock); diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/jobs/BatchJobsOperationsAdapterTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/jobs/BatchJobsOperationsAdapterTest.java deleted file mode 100644 index 957d7fe7..00000000 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/jobs/BatchJobsOperationsAdapterTest.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.jaspersoft.jasperserver.jaxrs.client.apiadapters.jobs; - -import com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest; -import com.jaspersoft.jasperserver.jaxrs.client.core.RestClientConfiguration; -import com.jaspersoft.jasperserver.jaxrs.client.core.SessionStorage; -import com.jaspersoft.jasperserver.jaxrs.client.core.operationresult.OperationResult; -import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.Job; -import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.jaxb.wrappers.JobSummaryListWrapper; -import javax.ws.rs.core.MultivaluedHashMap; -import org.mockito.Mock; -import org.mockito.internal.util.reflection.Whitebox; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.testng.PowerMockTestCase; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import static org.mockito.MockitoAnnotations.initMocks; -import static org.powermock.api.mockito.PowerMockito.mockStatic; -import static org.powermock.api.mockito.PowerMockito.verifyStatic; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertSame; - -/** - * @author Tetiana Iefimenko - * @deprecated - */ -@PrepareForTest({JerseyRequest.class}) -public class BatchJobsOperationsAdapterTest extends PowerMockTestCase { - - @Mock - private SessionStorage sessionStorageMock; - - @Mock - private JerseyRequest jobSummaryListWrapperJerseyRequest; - - @Mock - private OperationResult jobSummaryListWrapperOperationResult; - - @Mock - private RestClientConfiguration configurationMock; - - @Mock - private Job jobMock; - - @BeforeMethod - public void before() { - initMocks(this); - } - - @Test(testName = "constructor") - public void should_create_proper_SingleJobOperationsAdapter_object() throws IllegalAccessException { - - // When - BatchJobsOperationsAdapter adapter = new BatchJobsOperationsAdapter(sessionStorageMock); - - // Then - assertEquals(Whitebox.getInternalState(adapter, "sessionStorage"), sessionStorageMock); - assertEquals(Whitebox.getInternalState(adapter, "params"), new MultivaluedHashMap()); - } - - @Test - public void should_return_all_jobs() { - - // Given - mockStatic(JerseyRequest.class); - when(JerseyRequest.buildRequest(eq(sessionStorageMock), - eq(JobSummaryListWrapper.class), - eq(new String[]{"jobs"}))).thenReturn(jobSummaryListWrapperJerseyRequest); - when(jobSummaryListWrapperJerseyRequest.get()).thenReturn(jobSummaryListWrapperOperationResult); - when(sessionStorageMock.getConfiguration()).thenReturn(configurationMock); - - // When - BatchJobsOperationsAdapter adapter = spy(new BatchJobsOperationsAdapter(sessionStorageMock)); - OperationResult retrieved = adapter.search(); - - // Then - verifyStatic(times(1)); - JerseyRequest.buildRequest(eq(sessionStorageMock), eq(JobSummaryListWrapper.class), eq(new String[]{"jobs"})); - verify(jobSummaryListWrapperJerseyRequest, times(1)).get(); - assertNotNull(retrieved); - assertSame(retrieved, jobSummaryListWrapperOperationResult); - - } - -} diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/jobs/JobValidationErrorHandlerTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/jobs/JobValidationErrorHandlerTest.java deleted file mode 100644 index 3470852b..00000000 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/jobs/JobValidationErrorHandlerTest.java +++ /dev/null @@ -1,117 +0,0 @@ -package com.jaspersoft.jasperserver.jaxrs.client.apiadapters.jobs; - -import com.jaspersoft.jasperserver.jaxrs.client.core.exceptions.ValidationException; -import com.jaspersoft.jasperserver.jaxrs.client.core.exceptions.handling.DefaultErrorHandler; -import com.jaspersoft.jasperserver.dto.common.ErrorDescriptor; -import com.jaspersoft.jasperserver.jaxrs.client.dto.common.ValidationError; -import com.jaspersoft.jasperserver.jaxrs.client.dto.common.ValidationErrorsListWrapper; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.testng.PowerMockTestCase; -import org.testng.Assert; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import javax.ws.rs.core.Response; -import java.util.ArrayList; -import java.util.List; - -import static org.mockito.Mockito.reset; -import static org.mockito.Mockito.times; -import static org.mockito.MockitoAnnotations.initMocks; - -/** - * Unit tests for {@link com.jaspersoft.jasperserver.jaxrs.client.apiadapters.jobs.JobValidationErrorHandler} - * @deprecated - */ -@PrepareForTest({DefaultErrorHandler.class, JobValidationErrorHandler.class}) -public class JobValidationErrorHandlerTest extends PowerMockTestCase { - - @Mock - private Response responseMock; - - @Mock - private ValidationErrorsListWrapper wrapperMock; - - @BeforeMethod - public void before() { - initMocks(this); - } - - @Test(expectedExceptions = ValidationException.class) - public void should_throw_an_exception_when_retrieved_validation_errors() throws Exception { - - /* Given */ - - List errors = new ArrayList() {{ - add(new ValidationError("code1", new Object[]{}, "msg_1")); - add(new ValidationError("code2", new Object[]{}, "msg_2")); - }}; - - Mockito.when(responseMock.getHeaderString("Content-Type")).thenReturn("application/xml"); - Mockito.when(responseMock.readEntity(ValidationErrorsListWrapper.class)).thenReturn(wrapperMock); - Mockito.when(wrapperMock.getErrors()).thenReturn(errors); - - /* When */ - JobValidationErrorHandler handler = new JobValidationErrorHandler(); - handler.handleBodyError(responseMock); - - /* Then */ - Mockito.verify(responseMock, times(1)).getHeaderString("Content-Type"); - Mockito.verify(responseMock, times(1)).readEntity(ValidationErrorsListWrapper.class); - } - - @Test - public void should_handle_body_error() { - - /* Given */ - final ValidationErrorsListWrapper expected = null; - final int wantedNumberOfInvocations = 2; // invoke getHeaderString length in child and parent class - Mockito.when(responseMock.getHeaderString("Content-Type")).thenReturn("application/xml"); - Mockito.when(responseMock.readEntity(ValidationErrorsListWrapper.class)).thenReturn(expected); - - /* When */ - JobValidationErrorHandler handler = new JobValidationErrorHandler(); - handler.handleBodyError(responseMock); - - /* Then */ - Mockito.verify(responseMock, times(wantedNumberOfInvocations)).getHeaderString("Content-Type"); - } - - @Test - public void should_handle_body_error_when_content_type_of_response_in_text_html() { - - /* Given */ - final ValidationErrorsListWrapper expected = null; - Mockito.when(responseMock.getHeaderString("Content-Type")).thenReturn("text/html"); - Mockito.when(responseMock.readEntity(ValidationErrorsListWrapper.class)).thenReturn(expected); - - /* When */ - JobValidationErrorHandler handler = Mockito.spy(new JobValidationErrorHandler()); - handler.handleBodyError(responseMock); - - /* Then */ - Mockito.verify(responseMock, times(3)).getHeaderString("Content-Type"); - Mockito.verify(handler, times(1)).handleBodyError(responseMock); - } - - @Test - public void should_convert_error_descriptor_to_list() { - List errors = new ArrayList() {{ - add(new ValidationError("code1", new Object[]{}, "msg_1")); - add(new ValidationError("code2", new Object[]{}, "msg_2")); - }}; - Mockito.doReturn(errors).when(wrapperMock).getErrors(); - JobValidationErrorHandler handler = new JobValidationErrorHandler(); - List retrieved = handler.toErrorDescriptorList(wrapperMock); - Assert.assertTrue(retrieved.size() == 2); - Assert.assertSame(retrieved.get(0).getErrorCode(), "code1"); - } - - @AfterMethod - public void after() { - reset(responseMock, wrapperMock); - } -} \ No newline at end of file diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/jobs/JobsServiceTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/jobs/JobsServiceTest.java deleted file mode 100644 index d9935bba..00000000 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/jobs/JobsServiceTest.java +++ /dev/null @@ -1,463 +0,0 @@ -package com.jaspersoft.jasperserver.jaxrs.client.apiadapters.jobs; - -import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.jobs.calendar.CalendarType; -import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.jobs.calendar.SingleCalendarOperationsAdapter; -import com.jaspersoft.jasperserver.jaxrs.client.core.Callback; -import com.jaspersoft.jasperserver.jaxrs.client.core.enums.JRSVersion; -import com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest; -import com.jaspersoft.jasperserver.jaxrs.client.core.enums.MimeType; -import com.jaspersoft.jasperserver.jaxrs.client.core.RequestExecution; -import com.jaspersoft.jasperserver.jaxrs.client.core.RestClientConfiguration; -import com.jaspersoft.jasperserver.jaxrs.client.core.SessionStorage; -import com.jaspersoft.jasperserver.jaxrs.client.core.operationresult.OperationResult; -import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.Job; -import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.jaxb.wrappers.CalendarNameListWrapper; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.testng.PowerMockTestCase; -import org.testng.Assert; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import java.util.concurrent.atomic.AtomicInteger; - -import static com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest.buildRequest; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.reset; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoMoreInteractions; -import static org.mockito.Mockito.when; -import static org.mockito.MockitoAnnotations.initMocks; -import static org.powermock.api.mockito.PowerMockito.mockStatic; -import static org.powermock.api.mockito.PowerMockito.verifyStatic; -import static org.powermock.api.mockito.PowerMockito.whenNew; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertSame; - -/** - * Unit tests for {@link JobsService} - * @deprecated - */ -@PrepareForTest({JerseyRequest.class, JobsService.class}) -public class JobsServiceTest extends PowerMockTestCase { - - @Mock - private SessionStorage sessionStorageMock; - - @Mock - private BatchJobsOperationsAdapter expectedAdapterMock; - - @Mock - private SingleJobOperationsAdapter expectedJobOperationsAdapter; - - @Mock - private JerseyRequest jobRequestMock; - - @Mock - private JerseyRequest wrapperRequestMock; - - @Mock - private OperationResult expectedJobOperationResultMock; - - @Mock - private OperationResult expectedWrapperOperationResultMock; - - @Mock - private Job reportMock; - - @Mock - private RestClientConfiguration configurationMock; - - @Mock - private Callback, Object> callbackMock; - - @Mock - private RequestExecution executionMock; - - @Mock - private SingleCalendarOperationsAdapter expectedCalendarOperationsAdapterMock; - - @BeforeMethod - public void before() { - initMocks(this); - } - - @Test(testName = "jobs") - public void should_return_proper_adapter() throws Exception { - - // Given - JobsService serviceSpy = spy(new JobsService(sessionStorageMock)); - whenNew(BatchJobsOperationsAdapter.class) - .withParameterTypes(SessionStorage.class) - .withArguments(sessionStorageMock) - .thenReturn(expectedAdapterMock); - - // When - BatchJobsOperationsAdapter retrieved = serviceSpy.jobs(); - - // Then - assertSame(retrieved, expectedAdapterMock); - } - - @Test(testName = "job") - public void should_return_proper_SingleJobOperationsAdapter() throws Exception { - - // Given - JobsService serviceSpy = spy(new JobsService(sessionStorageMock)); - whenNew(SingleJobOperationsAdapter.class) - .withParameterTypes(SessionStorage.class, String.class) - .withArguments(sessionStorageMock, "9056") - .thenReturn(expectedJobOperationsAdapter); - - // When - SingleJobOperationsAdapter retrieved = serviceSpy.job(9056); - - // Then - verify(serviceSpy, times(1)).job(9056); - assertSame(retrieved, expectedJobOperationsAdapter); - } - - @Test(testName = "scheduleReport_for_v5_6_1") - public void should_return_proper_OperationResult_when_JRS_version_is_v5_6_1() { - - // Given - JobsService serviceSpy = spy(new JobsService(sessionStorageMock)); - - mockStatic(JerseyRequest.class); - when(JerseyRequest.buildRequest(eq(sessionStorageMock), - eq(Job.class), - eq(new String[]{"jobs"}), - any(JobValidationErrorHandler.class))).thenReturn(jobRequestMock); - when(jobRequestMock.put(reportMock)).thenReturn(expectedJobOperationResultMock); - when(sessionStorageMock.getConfiguration()).thenReturn(configurationMock); - when(configurationMock.getJrsVersion()).thenReturn(JRSVersion.v5_6_1); - when(configurationMock.getContentMimeType()).thenReturn(MimeType.XML); - - // When - serviceSpy.scheduleReport(reportMock); - - // Then - verifyStatic(times(1)); - JerseyRequest.buildRequest(eq(sessionStorageMock), - eq(Job.class), - eq(new String[]{"jobs"}), - any(JobValidationErrorHandler.class)); - verify(jobRequestMock, times(1)).put(reportMock); - verify(jobRequestMock, times(1)).setContentType("application/job+xml"); - verify(jobRequestMock, times(1)).setAccept("application/job+xml"); - } - - @Test(testName = "scheduleReport_for_v4_7_0") - public void should_return_proper_OperationResult_when_JRS_version_is_v4_7_0() { - - // Given - mockStatic(JerseyRequest.class); - when(JerseyRequest.buildRequest(eq(sessionStorageMock), - eq(Job.class), - eq(new String[]{"jobs"}), - any(JobValidationErrorHandler.class))).thenReturn(jobRequestMock); - when(jobRequestMock.put(reportMock)).thenReturn(expectedJobOperationResultMock); - when(sessionStorageMock.getConfiguration()).thenReturn(configurationMock); - when(configurationMock.getJrsVersion()).thenReturn(JRSVersion.v4_7_0); - when(configurationMock.getContentMimeType()).thenReturn(MimeType.JSON); - JobsService serviceSpy = spy(new JobsService(sessionStorageMock)); - - // When - OperationResult retrieved = serviceSpy.scheduleReport(reportMock); - - // Then - verifyStatic(times(1)); - JerseyRequest.buildRequest(eq(sessionStorageMock), - eq(Job.class), - eq(new String[]{"jobs"}), - any(JobValidationErrorHandler.class)); - verify(jobRequestMock, times(1)).put(reportMock); - verify(jobRequestMock, times(1)).setContentType("application/job+json"); - verify(jobRequestMock, times(1)).setAccept("application/job+json"); - - assertNotNull(retrieved); - assertSame(retrieved, expectedJobOperationResultMock); - } - - @Test(testName = "calendars") - public void should_return_proper_op_result_object() { - - // Given - JobsService serviceSpy = spy(new JobsService(sessionStorageMock)); - doReturn(expectedWrapperOperationResultMock).when(serviceSpy).calendars(null); - - // When - OperationResult retrieved = serviceSpy.calendars(); - - // Then - verify(serviceSpy, times(1)).calendars(); - verify(serviceSpy, times(1)).calendars(null); - verify(serviceSpy, never()).calendars(CalendarType.holiday); - verifyNoMoreInteractions(serviceSpy); - - assertSame(retrieved, expectedWrapperOperationResultMock); - } - - @Test(testName = "asyncCalendars") - public void should_return_RequestExecution_with_CalendarNameListWrapper_instance() { - - // Given - JobsService serviceSpy = spy(new JobsService(sessionStorageMock)); - doReturn(executionMock).when(serviceSpy).asyncCalendars(null, callbackMock); - - // When - RequestExecution retrieved = serviceSpy.asyncCalendars(callbackMock); - - // Then - verify(serviceSpy, times(1)).asyncCalendars(null, callbackMock); - verify(serviceSpy, never()).asyncCalendars(CalendarType.holiday, callbackMock); - - assertSame(retrieved, executionMock); - } - - @Test(testName = "calendars_with_param") - public void should_return_proper_op_result_object_when_param_is_not_null() { - - // Given - mockStatic(JerseyRequest.class); - when(JerseyRequest.buildRequest(eq(sessionStorageMock), - eq(CalendarNameListWrapper.class), - eq(new String[]{"jobs", "calendars"}))).thenReturn(wrapperRequestMock); - when(wrapperRequestMock.get()).thenReturn(expectedWrapperOperationResultMock); - JobsService serviceSpy = spy(new JobsService(sessionStorageMock)); - - // When - OperationResult retrieved = serviceSpy.calendars(CalendarType.daily); - - // Then - assertNotNull(retrieved); - assertSame(retrieved, expectedWrapperOperationResultMock); - - verifyStatic(times(1)); - JerseyRequest.buildRequest(eq(sessionStorageMock), - eq(CalendarNameListWrapper.class), - eq(new String[]{"jobs", "calendars"})); - - verify(wrapperRequestMock, times(1)).get(); - verify(wrapperRequestMock, times(1)).addParam("calendarType", CalendarType.daily.toString().toLowerCase()); - } - - - @Test(testName = "calendars_with_param") - public void should_return_proper_op_result_object_when_param_is_null() { - - // Given - mockStatic(JerseyRequest.class); - when(JerseyRequest.buildRequest(eq(sessionStorageMock), - eq(CalendarNameListWrapper.class), - eq(new String[]{"jobs", "calendars"}))).thenReturn(wrapperRequestMock); - when(wrapperRequestMock.get()).thenReturn(expectedWrapperOperationResultMock); - JobsService serviceSpy = spy(new JobsService(sessionStorageMock)); - - // When - OperationResult retrieved = serviceSpy.calendars(null); - - // Then - assertNotNull(retrieved); - assertSame(retrieved, expectedWrapperOperationResultMock); - - verifyStatic(times(1)); - JerseyRequest.buildRequest(eq(sessionStorageMock), - eq(CalendarNameListWrapper.class), - eq(new String[]{"jobs", "calendars"})); - - verify(wrapperRequestMock, times(1)).get(); - verify(wrapperRequestMock, never()).addParam("calendarType", CalendarType.daily.toString().toLowerCase()); - } - - - @Test(testName = "calendar") - public void should_return_an_calendar_adapter() throws Exception { - - // Given - final String calendarName = "testCalendar"; - JobsService serviceSpy = spy(new JobsService(sessionStorageMock)); - whenNew(SingleCalendarOperationsAdapter.class) - .withParameterTypes(SessionStorage.class, String.class) - .withArguments(sessionStorageMock, calendarName) - .thenReturn(expectedCalendarOperationsAdapterMock); - - // When - SingleCalendarOperationsAdapter retrieved = serviceSpy.calendar(calendarName); - - // Then - assertNotNull(retrieved); - assertSame(retrieved, expectedCalendarOperationsAdapterMock); - } - - @Test(testName = "calendar", expectedExceptions = IllegalArgumentException.class) - public void should_throw_an_exception_when_invalid_calendar_name() throws Exception { - JobsService serviceSpy = spy(new JobsService(sessionStorageMock)); - serviceSpy.calendar(""); - } - - @Test - public void should_get_calendars_asynchronously() throws InterruptedException { - - /* Given */ - PowerMockito.mockStatic(JerseyRequest.class); - PowerMockito.when(buildRequest(eq(sessionStorageMock), - eq(CalendarNameListWrapper.class), - eq(new String[]{"jobs", "calendars"}))).thenReturn(wrapperRequestMock); - - PowerMockito.doReturn(expectedWrapperOperationResultMock).when(wrapperRequestMock).get(); - JobsService serviceSpy = PowerMockito.spy(new JobsService(sessionStorageMock)); - - final AtomicInteger newThreadId = new AtomicInteger(); - final int currentThreadId = (int) Thread.currentThread().getId(); - - final Callback, Void> callback = PowerMockito.spy(new Callback, Void>() { - @Override - public Void execute(OperationResult data) { - newThreadId.set((int) Thread.currentThread().getId()); - synchronized (this) { - this.notify(); - } - return null; - } - }); - - PowerMockito.doReturn(null).when(callback).execute(expectedWrapperOperationResultMock); - - /* When */ - RequestExecution retrieved = serviceSpy.asyncCalendars(CalendarType.annual, callback); - - /* Wait */ - synchronized (callback) { - callback.wait(1000); - } - - /* Then */ - Assert.assertNotNull(retrieved); - Assert.assertNotSame(currentThreadId, newThreadId.get()); - - Mockito.verify(wrapperRequestMock).get(); - Mockito.verify(callback).execute(expectedWrapperOperationResultMock); - Mockito.verify(wrapperRequestMock).addParam("calendarType", "annual"); - } - - @Test - public void should_send_ScheduleReport_asynchronously_() throws InterruptedException { - - /* Given */ - PowerMockito.mockStatic(JerseyRequest.class); - PowerMockito.when(buildRequest(eq(sessionStorageMock), - eq(Job.class), - eq(new String[]{"jobs"}), - any(JobValidationErrorHandler.class))).thenReturn(jobRequestMock); - - PowerMockito.doReturn(expectedJobOperationResultMock).when(jobRequestMock).put(reportMock); - JobsService serviceSpy = PowerMockito.spy(new JobsService(sessionStorageMock)); - - final AtomicInteger newThreadId = new AtomicInteger(); - final int currentThreadId = (int) Thread.currentThread().getId(); - - final Callback, Void> callback = PowerMockito.spy(new Callback, Void>() { - @Override - public Void execute(OperationResult data) { - newThreadId.set((int) Thread.currentThread().getId()); - synchronized (this) { - this.notify(); - } - return null; - } - }); - - PowerMockito.doReturn(null).when(callback).execute(expectedJobOperationResultMock); - PowerMockito.doReturn(configurationMock).when(sessionStorageMock).getConfiguration(); - PowerMockito.doReturn(JRSVersion.v5_0_0).when(configurationMock).getJrsVersion(); - PowerMockito.doReturn(null).when(callback).execute(expectedJobOperationResultMock); - PowerMockito.doReturn(null).when(callback).execute(expectedJobOperationResultMock); - - /* When */ - RequestExecution retrieved = serviceSpy.asyncScheduleReport(reportMock, callback); - - /* Wait */ - synchronized (callback) { - callback.wait(1000); - } - - /* Then */ - Assert.assertNotNull(retrieved); - Assert.assertNotSame(currentThreadId, newThreadId.get()); - - Mockito.verify(jobRequestMock).put(reportMock); - Mockito.verify(jobRequestMock).setContentType("application/job+json"); - Mockito.verify(jobRequestMock).setAccept("application/job+json"); - Mockito.verify(callback).execute(expectedJobOperationResultMock); - Mockito.verify(sessionStorageMock).getConfiguration(); - Mockito.verify(configurationMock).getJrsVersion(); - } - - @Test - public void should_send_ScheduleReport_asynchronously() throws InterruptedException { - - /* Given */ - PowerMockito.mockStatic(JerseyRequest.class); - PowerMockito.when(buildRequest(eq(sessionStorageMock), - eq(Job.class), - eq(new String[]{"jobs"}), - any(JobValidationErrorHandler.class))).thenReturn(jobRequestMock); - - PowerMockito.doReturn(expectedJobOperationResultMock).when(jobRequestMock).put(reportMock); - JobsService serviceSpy = PowerMockito.spy(new JobsService(sessionStorageMock)); - - final AtomicInteger newThreadId = new AtomicInteger(); - final int currentThreadId = (int) Thread.currentThread().getId(); - - final Callback, Void> callback = PowerMockito.spy(new Callback, Void>() { - @Override - public Void execute(OperationResult data) { - newThreadId.set((int) Thread.currentThread().getId()); - synchronized (this) { - this.notify(); - } - return null; - } - }); - - PowerMockito.doReturn(null).when(callback).execute(expectedJobOperationResultMock); - PowerMockito.doReturn(configurationMock).when(sessionStorageMock).getConfiguration(); - PowerMockito.doReturn(JRSVersion.v5_6_1).when(configurationMock).getJrsVersion(); - PowerMockito.doReturn(null).when(callback).execute(expectedJobOperationResultMock); - PowerMockito.doReturn(null).when(callback).execute(expectedJobOperationResultMock); - - /* When */ - RequestExecution retrieved = serviceSpy.asyncScheduleReport(reportMock, callback); - - /* Wait */ - synchronized (callback) { - callback.wait(1000); - } - - /* Then */ - Assert.assertNotNull(retrieved); - Assert.assertNotSame(currentThreadId, newThreadId.get()); - - Mockito.verify(jobRequestMock).put(reportMock); - Mockito.verify(jobRequestMock).setContentType("application/job+xml"); - Mockito.verify(jobRequestMock).setAccept("application/job+xml"); - Mockito.verify(callback).execute(expectedJobOperationResultMock); - Mockito.verify(sessionStorageMock, times(3)).getConfiguration(); - Mockito.verify(configurationMock).getJrsVersion(); - } - - @AfterMethod - public void after() { - reset(sessionStorageMock, expectedAdapterMock, expectedJobOperationsAdapter, - jobRequestMock, expectedJobOperationResultMock, reportMock, configurationMock); - } -} \ No newline at end of file diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/jobs/SingleJobOperationsAdapterTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/jobs/SingleJobOperationsAdapterTest.java deleted file mode 100644 index 2999d5ee..00000000 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/jobs/SingleJobOperationsAdapterTest.java +++ /dev/null @@ -1,533 +0,0 @@ -package com.jaspersoft.jasperserver.jaxrs.client.apiadapters.jobs; - -import com.jaspersoft.jasperserver.jaxrs.client.core.Callback; -import com.jaspersoft.jasperserver.jaxrs.client.core.enums.JRSVersion; -import com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest; -import com.jaspersoft.jasperserver.jaxrs.client.core.enums.MimeType; -import com.jaspersoft.jasperserver.jaxrs.client.core.RequestExecution; -import com.jaspersoft.jasperserver.jaxrs.client.core.RestClientConfiguration; -import com.jaspersoft.jasperserver.jaxrs.client.core.SessionStorage; -import com.jaspersoft.jasperserver.jaxrs.client.core.operationresult.OperationResult; -import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.Job; -import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.JobState; -import org.mockito.InOrder; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.testng.PowerMockTestCase; -import org.testng.Assert; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import java.lang.reflect.Field; -import java.util.concurrent.atomic.AtomicInteger; - -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.reset; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import static org.mockito.MockitoAnnotations.initMocks; -import static org.powermock.api.mockito.PowerMockito.mockStatic; -import static org.powermock.api.mockito.PowerMockito.verifyStatic; -import static org.powermock.api.support.membermodification.MemberMatcher.field; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertSame; - -/** - * Unit tests for {@link com.jaspersoft.jasperserver.jaxrs.client.apiadapters.jobs.SingleJobOperationsAdapter} - * @deprecated - */ -@PrepareForTest({JerseyRequest.class}) -public class SingleJobOperationsAdapterTest extends PowerMockTestCase { - - @Mock - private SessionStorage sessionStorageMock; - - @Mock - private JerseyRequest jobRequestMock; - - @Mock - private JerseyRequest objectJerseyRequestMock; - - @Mock - private JerseyRequest jobStateJerseyRequestMock; - - @Mock - private OperationResult jobStateOperationResultMock; - - @Mock - private OperationResult jobOperationResultMock; - - @Mock - private OperationResult operationResultMock; - - @Mock - private RestClientConfiguration configurationMock; - - @Mock - private Job jobMock; - - private final String expectedJobId = "3819"; - - @BeforeMethod - public void before() { - initMocks(this); - } - - @Test(testName = "constructor") - public void should_create_proper_SingleJobOperationsAdapter_object() throws IllegalAccessException { - - // When - SingleJobOperationsAdapter adapter = spy(new SingleJobOperationsAdapter(sessionStorageMock, expectedJobId)); - - // Then - assertSame(adapter.getSessionStorage(), sessionStorageMock); - Field field = field(SingleJobOperationsAdapter.class, "jobId"); - String retrievedJobId = (String) field.get(adapter); - assertEquals(retrievedJobId, expectedJobId); - } - - @Test(testName = "group") - public void should_return_proper_job_operation_result_when_JRS_version_is_v5_6_1() { - - // Given - mockStatic(JerseyRequest.class); - when(JerseyRequest.buildRequest(eq(sessionStorageMock), eq(Job.class), eq(new String[]{"jobs", expectedJobId}))).thenReturn(jobRequestMock); - when(jobRequestMock.get()).thenReturn(jobOperationResultMock); - when(sessionStorageMock.getConfiguration()).thenReturn(configurationMock); - when(configurationMock.getJrsVersion()).thenReturn(JRSVersion.v5_6_1); - when(configurationMock.getContentMimeType()).thenReturn(MimeType.XML); - - // When - SingleJobOperationsAdapter adapter = spy(new SingleJobOperationsAdapter(sessionStorageMock, expectedJobId)); - OperationResult retrieved = adapter.get(); - - // Then - verifyStatic(times(1)); - JerseyRequest.buildRequest(eq(sessionStorageMock), eq(Job.class), eq(new String[]{"jobs", expectedJobId})); - verify(jobRequestMock, times(1)).get(); - verify(jobRequestMock, times(1)).setAccept("application/job+xml"); - - assertNotNull(retrieved); - assertSame(retrieved, jobOperationResultMock); - } - - @Test - public void should_return_proper_job_operation_result_when_JRS_version_is_v4_7_0() { - - // Given - mockStatic(JerseyRequest.class); - when(JerseyRequest.buildRequest(eq(sessionStorageMock), eq(Job.class), eq(new String[]{"jobs", expectedJobId}))).thenReturn(jobRequestMock); - when(jobRequestMock.get()).thenReturn(jobOperationResultMock); - when(sessionStorageMock.getConfiguration()).thenReturn(configurationMock); - when(configurationMock.getJrsVersion()).thenReturn(JRSVersion.v4_7_0); - when(configurationMock.getContentMimeType()).thenReturn(MimeType.JSON); - - // When - SingleJobOperationsAdapter adapter = spy(new SingleJobOperationsAdapter(sessionStorageMock, expectedJobId)); - OperationResult retrieved = adapter.get(); - - // Then - verifyStatic(times(1)); - JerseyRequest.buildRequest(eq(sessionStorageMock), eq(Job.class), eq(new String[]{"jobs", expectedJobId})); - verify(jobRequestMock, times(1)).get(); - verify(jobRequestMock, times(1)).setAccept("application/job+json"); - - assertNotNull(retrieved); - assertSame(retrieved, jobOperationResultMock); - } - - @Test - public void should_proper_op_result_instance() { - - // Given - mockStatic(JerseyRequest.class); - when(JerseyRequest.buildRequest(eq(sessionStorageMock), eq(JobState.class), - eq(new String[]{"jobs", expectedJobId, "state"}))).thenReturn(jobStateJerseyRequestMock); - when(jobStateJerseyRequestMock.get()).thenReturn(jobStateOperationResultMock); - - // When - SingleJobOperationsAdapter adapter = spy(new SingleJobOperationsAdapter(sessionStorageMock, expectedJobId)); - OperationResult retrieved = adapter.state(); - - // Then - verifyStatic(times(1)); - JerseyRequest.buildRequest(eq(sessionStorageMock), eq(JobState.class), - eq(new String[]{"jobs", expectedJobId, "state"})); - verify(jobStateJerseyRequestMock, times(1)).get(); - assertSame(retrieved, jobStateOperationResultMock); - } - - @Test(testName = "update") - public void should_return_prepared_op_result_when_jrs_version_is_5_6_1() { - - // Given - mockStatic(JerseyRequest.class); - when(JerseyRequest.buildRequest(eq(sessionStorageMock), eq(Job.class), eq(new String[]{"jobs", expectedJobId}), any(JobValidationErrorHandler.class))).thenReturn(jobRequestMock); - when(jobRequestMock.post(jobMock)).thenReturn(jobOperationResultMock); - when(sessionStorageMock.getConfiguration()).thenReturn(configurationMock); - when(configurationMock.getJrsVersion()).thenReturn(JRSVersion.v5_6_1); - when(configurationMock.getContentMimeType()).thenReturn(MimeType.XML); - when(configurationMock.getAcceptMimeType()).thenReturn(MimeType.XML); - - // When - SingleJobOperationsAdapter adapter = spy(new SingleJobOperationsAdapter(sessionStorageMock, expectedJobId)); - OperationResult retrieved = adapter.update(jobMock); - - // Then - verifyStatic(times(1)); - JerseyRequest.buildRequest(eq(sessionStorageMock), eq(Job.class), eq(new String[]{"jobs", expectedJobId}), any(JobValidationErrorHandler.class)); - verify(jobRequestMock, times(1)).post(jobMock); - verify(jobRequestMock, times(1)).setContentType("application/job+xml"); - verify(jobRequestMock, times(1)).setAccept("application/job+xml"); - - assertNotNull(retrieved); - assertSame(retrieved, jobOperationResultMock); - } - - @Test(testName = "update") - public void should_return_prepared_op_result_when_jrs_version_is_4_7_0() { - - // Given - mockStatic(JerseyRequest.class); - when(JerseyRequest.buildRequest(eq(sessionStorageMock), eq(Job.class), eq(new String[]{"jobs", expectedJobId}), any(JobValidationErrorHandler.class))).thenReturn(jobRequestMock); - when(jobRequestMock.post(jobMock)).thenReturn(jobOperationResultMock); - when(sessionStorageMock.getConfiguration()).thenReturn(configurationMock); - when(configurationMock.getJrsVersion()).thenReturn(JRSVersion.v4_7_0); - when(configurationMock.getContentMimeType()).thenReturn(MimeType.JSON); - when(configurationMock.getAcceptMimeType()).thenReturn(MimeType.JSON); - - // When - SingleJobOperationsAdapter adapter = spy(new SingleJobOperationsAdapter(sessionStorageMock, expectedJobId)); - OperationResult retrieved = adapter.update(jobMock); - - // Then - verifyStatic(times(1)); - JerseyRequest.buildRequest(eq(sessionStorageMock), eq(Job.class), eq(new String[]{"jobs", expectedJobId}), any(JobValidationErrorHandler.class)); - verify(jobRequestMock, times(1)).post(jobMock); - verify(jobRequestMock, times(1)).setContentType("application/job+json"); - verify(jobRequestMock, times(1)).setAccept("application/job+json"); - - assertNotNull(retrieved); - assertSame(retrieved, jobOperationResultMock); - } - - @Test(testName = "delete") - public void should_proper_op_result_instance_for_deleting_operation() { - - // Given - mockStatic(JerseyRequest.class); - when(JerseyRequest.buildRequest(eq(sessionStorageMock), eq(Object.class), - eq(new String[]{"jobs", expectedJobId}))).thenReturn(objectJerseyRequestMock); - when(objectJerseyRequestMock.delete()).thenReturn(operationResultMock); - - // When - SingleJobOperationsAdapter adapter = spy(new SingleJobOperationsAdapter(sessionStorageMock, expectedJobId)); - OperationResult retrieved = adapter.delete(); - - // Then - verifyStatic(times(1)); - JerseyRequest.buildRequest(eq(sessionStorageMock), eq(Object.class), eq(new String[]{"jobs", expectedJobId})); - verify(objectJerseyRequestMock, times(1)).delete(); - assertSame(retrieved, operationResultMock); - } - - @Test - public void should_return_RequestExecution_when_environment_is_specified() throws Exception { - - // Given - final AtomicInteger newThreadId = new AtomicInteger(); - final int currentThreadId = (int) Thread.currentThread().getId(); - - PowerMockito.mockStatic(JerseyRequest.class); - PowerMockito.when(JerseyRequest.buildRequest( - eq(sessionStorageMock), - eq(Job.class), - eq(new String[]{"jobs", "123435326"}), - any(JobValidationErrorHandler.class))).thenReturn(jobRequestMock); - - SingleJobOperationsAdapter adapterSpy = PowerMockito.spy(new SingleJobOperationsAdapter(sessionStorageMock, "123435326")); - Callback, Void> callback = PowerMockito.spy(new Callback, Void>() { - public Void execute(OperationResult data) { - newThreadId.set((int) Thread.currentThread().getId()); - synchronized (this) { - this.notify(); - } - return null; - } - }); - - PowerMockito.doReturn(jobOperationResultMock).when(jobRequestMock).post(jobMock); - PowerMockito.doReturn(null).when(callback).execute(jobOperationResultMock); - PowerMockito.doReturn(configurationMock).when(sessionStorageMock).getConfiguration(); - PowerMockito.doReturn(JRSVersion.v5_1_0).when(configurationMock).getJrsVersion(); - - InOrder inOrder = Mockito.inOrder(jobRequestMock); - - // When - RequestExecution retrieved = adapterSpy.asyncUpdate(jobMock, callback); - - // Wait - synchronized (callback) { - callback.wait(1000); - } - - // Then - Assert.assertNotNull(retrieved); - Assert.assertNotSame(currentThreadId, newThreadId.get()); - Mockito.verify(callback, times(1)).execute(jobOperationResultMock); - - inOrder.verify(jobRequestMock, times(1)).setContentType("application/job+json"); - inOrder.verify(jobRequestMock, times(1)).setAccept("application/job+json"); - inOrder.verify(jobRequestMock, times(1)).post(jobMock); - } - - @Test - public void should_return_RequestExecution_when_environment_is_specified_with_5_6_1_jrs_server_version() throws Exception { - - // Given - final AtomicInteger newThreadId = new AtomicInteger(); - final int currentThreadId = (int) Thread.currentThread().getId(); - - PowerMockito.mockStatic(JerseyRequest.class); - PowerMockito.when(JerseyRequest.buildRequest( - eq(sessionStorageMock), - eq(Job.class), - eq(new String[]{"jobs", "123435326"}), - any(JobValidationErrorHandler.class))).thenReturn(jobRequestMock); - - SingleJobOperationsAdapter adapterSpy = PowerMockito.spy(new SingleJobOperationsAdapter(sessionStorageMock, "123435326")); - Callback, Void> callback = PowerMockito.spy(new Callback, Void>() { - public Void execute(OperationResult data) { - newThreadId.set((int) Thread.currentThread().getId()); - synchronized (this) { - this.notify(); - } - return null; - } - }); - - PowerMockito.doReturn(jobOperationResultMock).when(jobRequestMock).post(jobMock); - PowerMockito.doReturn(null).when(callback).execute(jobOperationResultMock); - PowerMockito.doReturn(configurationMock).when(sessionStorageMock).getConfiguration(); - PowerMockito.doReturn(JRSVersion.v5_6_1).when(configurationMock).getJrsVersion(); - - InOrder inOrder = Mockito.inOrder(jobRequestMock); - - // When - RequestExecution retrieved = adapterSpy.asyncUpdate(jobMock, callback); - - // Wait - synchronized (callback) { - callback.wait(1000); - } - - // Then - Assert.assertNotNull(retrieved); - Assert.assertNotSame(currentThreadId, newThreadId.get()); - Mockito.verify(callback, times(1)).execute(jobOperationResultMock); - - inOrder.verify(jobRequestMock).setContentType("application/job+xml"); - inOrder.verify(jobRequestMock).setAccept("application/job+xml"); - inOrder.verify(jobRequestMock, times(1)).post(jobMock); - } - - @Test - public void should_invoke_asynchronous_method_get_and_return_RequestExecution_with_Future() throws InterruptedException { - - // Given - final AtomicInteger newThreadId = new AtomicInteger(); - final int currentThreadId = (int) Thread.currentThread().getId(); - - PowerMockito.mockStatic(JerseyRequest.class); - PowerMockito.when(JerseyRequest.buildRequest( - eq(sessionStorageMock), - eq(Job.class), - eq(new String[]{"jobs", "123435326"}))) - .thenReturn(jobRequestMock); - - SingleJobOperationsAdapter adapterSpy = PowerMockito.spy(new SingleJobOperationsAdapter(sessionStorageMock, "123435326")); - Callback, Void> callback = PowerMockito.spy(new Callback, Void>() { - public Void execute(OperationResult data) { - newThreadId.set((int) Thread.currentThread().getId()); - synchronized (this) { - this.notify(); - } - return null; - } - }); - - PowerMockito.doReturn(jobOperationResultMock).when(jobRequestMock).get(); - PowerMockito.doReturn(null).when(callback).execute(jobOperationResultMock); - PowerMockito.doReturn(configurationMock).when(sessionStorageMock).getConfiguration(); - PowerMockito.doReturn(JRSVersion.v5_6_1).when(configurationMock).getJrsVersion(); - PowerMockito.doReturn(MimeType.JSON).when(configurationMock).getAcceptMimeType(); - - InOrder inOrder = Mockito.inOrder(jobRequestMock); - - // When - RequestExecution retrieved = adapterSpy.asyncGet(callback); - - // Wait - synchronized (callback) { - callback.wait(1000); - } - - // Then - Assert.assertNotNull(retrieved); - Assert.assertNotSame(currentThreadId, newThreadId.get()); - Mockito.verify(callback, times(1)).execute(jobOperationResultMock); - - inOrder.verify(jobRequestMock).setAccept("application/job+json"); - inOrder.verify(jobRequestMock, times(1)).get(); - } - - - @Test - public void should_invoke_asynchronous_method_get_and_return_RequestExecution_with_Future_when_jrs_version_is_lower_Then_5_5_0() throws InterruptedException { - - // Given - final AtomicInteger newThreadId = new AtomicInteger(); - final int currentThreadId = (int) Thread.currentThread().getId(); - - PowerMockito.mockStatic(JerseyRequest.class); - PowerMockito.when(JerseyRequest.buildRequest( - eq(sessionStorageMock), - eq(Job.class), - eq(new String[]{"jobs", "123435326"}))) - .thenReturn(jobRequestMock); - - SingleJobOperationsAdapter adapterSpy = PowerMockito.spy(new SingleJobOperationsAdapter(sessionStorageMock, "123435326")); - Callback, Void> callback = PowerMockito.spy(new Callback, Void>() { - public Void execute(OperationResult data) { - newThreadId.set((int) Thread.currentThread().getId()); - synchronized (this) { - this.notify(); - } - return null; - } - }); - - PowerMockito.doReturn(jobOperationResultMock).when(jobRequestMock).get(); - PowerMockito.doReturn(null).when(callback).execute(jobOperationResultMock); - PowerMockito.doReturn(configurationMock).when(sessionStorageMock).getConfiguration(); - PowerMockito.doReturn(JRSVersion.v4_7_0).when(configurationMock).getJrsVersion(); - //PowerMockito.doReturn(MimeType.JSON).when(configurationMock).getAcceptMimeType(); - - InOrder inOrder = Mockito.inOrder(jobRequestMock); - - // When - RequestExecution retrieved = adapterSpy.asyncGet(callback); - - // Wait - synchronized (callback) { - callback.wait(1000); - } - - // Then - Assert.assertNotNull(retrieved); - Assert.assertNotSame(currentThreadId, newThreadId.get()); - Mockito.verify(callback, times(1)).execute(jobOperationResultMock); - - inOrder.verify(jobRequestMock).setAccept("application/job+json"); - inOrder.verify(jobRequestMock, times(1)).get(); - } - - - @Test - public void should_delete_job_asynchronously() throws InterruptedException { - - // Given - final AtomicInteger newThreadId = new AtomicInteger(); - final int currentThreadId = (int) Thread.currentThread().getId(); - - PowerMockito.mockStatic(JerseyRequest.class); - PowerMockito.when(JerseyRequest.buildRequest( - eq(sessionStorageMock), - eq(Object.class), - eq(new String[]{"jobs", "123435326"}))) - .thenReturn(objectJerseyRequestMock); - - SingleJobOperationsAdapter adapterSpy = PowerMockito.spy(new SingleJobOperationsAdapter(sessionStorageMock, "123435326")); - Callback callback = PowerMockito.spy(new Callback() { - public Void execute(OperationResult data) { - newThreadId.set((int) Thread.currentThread().getId()); - synchronized (this) { - this.notify(); - } - return null; - } - }); - - PowerMockito.doReturn(operationResultMock).when(objectJerseyRequestMock).delete(); - PowerMockito.doReturn(null).when(callback).execute(operationResultMock); - - // When - RequestExecution retrieved = adapterSpy.asyncDelete(callback); - - // Wait - synchronized (callback) { - callback.wait(1000); - } - - // Then - Assert.assertNotNull(retrieved); - Assert.assertNotSame(currentThreadId, newThreadId.get()); - Mockito.verify(objectJerseyRequestMock, times(1)).delete(); - Mockito.verify(callback, times(1)).execute(operationResultMock); - } - - @Test - public void should_retrieve_state_asynchronously() throws InterruptedException { - - // Given - final AtomicInteger newThreadId = new AtomicInteger(); - final int currentThreadId = (int) Thread.currentThread().getId(); - - PowerMockito.mockStatic(JerseyRequest.class); - PowerMockito.when(JerseyRequest.buildRequest( - eq(sessionStorageMock), - eq(JobState.class), - eq(new String[]{"jobs", "123435326", "state"}))) - .thenReturn(jobStateJerseyRequestMock); - - SingleJobOperationsAdapter adapterSpy = PowerMockito.spy(new SingleJobOperationsAdapter(sessionStorageMock, "123435326")); - Callback, Void> callback = PowerMockito.spy(new Callback, Void>() { - public Void execute(OperationResult data) { - newThreadId.set((int) Thread.currentThread().getId()); - synchronized (this) { - this.notify(); - } - return null; - } - }); - - PowerMockito.doReturn(jobStateOperationResultMock).when(jobStateJerseyRequestMock).get(); - PowerMockito.doReturn(null).when(callback).execute(jobStateOperationResultMock); - - // When - RequestExecution retrieved = adapterSpy.asyncState(callback); - - // Wait - synchronized (callback) { - callback.wait(1000); - } - - // Then - Assert.assertNotNull(retrieved); - Assert.assertNotSame(currentThreadId, newThreadId.get()); - Mockito.verify(jobStateJerseyRequestMock, times(1)).get(); - Mockito.verify(callback, times(1)).execute(jobStateOperationResultMock); - } - - @AfterMethod - public void after() { - reset(sessionStorageMock, jobRequestMock, jobOperationResultMock, configurationMock); - } -} \ No newline at end of file diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/jobs/calendar/SingleCalendarOperationsAdapterTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/jobs/calendar/SingleCalendarOperationsAdapterTest.java deleted file mode 100644 index 01cfe054..00000000 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/jobs/calendar/SingleCalendarOperationsAdapterTest.java +++ /dev/null @@ -1,596 +0,0 @@ -package com.jaspersoft.jasperserver.jaxrs.client.apiadapters.jobs.calendar; - -import com.jaspersoft.jasperserver.jaxrs.client.core.Callback; -import com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest; -import com.jaspersoft.jasperserver.jaxrs.client.core.RequestBuilder; -import com.jaspersoft.jasperserver.jaxrs.client.core.RequestExecution; -import com.jaspersoft.jasperserver.jaxrs.client.core.SessionStorage; -import com.jaspersoft.jasperserver.jaxrs.client.core.operationresult.OperationResult; -import com.jaspersoft.jasperserver.jaxrs.client.core.operationresult.WithEntityOperationResult; -import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.ReportJobCalendar; -import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.calendars.AnnualCalendar; -import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.calendars.BaseCalendar; -import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.calendars.Calendar; -import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.calendars.CronCalendar; -import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.calendars.DailyCalendar; -import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.calendars.HolidayCalendar; -import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.calendars.MonthlyCalendar; -import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.calendars.WeeklyCalendar; -import java.util.concurrent.atomic.AtomicInteger; -import javax.ws.rs.core.MultivaluedHashMap; -import javax.ws.rs.core.MultivaluedMap; -import javax.ws.rs.core.Response; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.internal.util.reflection.Whitebox; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.testng.PowerMockTestCase; -import org.testng.Assert; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import static com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest.buildRequest; -import static org.hamcrest.core.IsInstanceOf.instanceOf; -import static org.mockito.Matchers.anyString; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.reset; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.MockitoAnnotations.initMocks; -import static org.powermock.api.mockito.PowerMockito.doReturn; -import static org.powermock.api.mockito.PowerMockito.mockStatic; -import static org.powermock.api.mockito.PowerMockito.spy; -import static org.powermock.api.mockito.PowerMockito.verifyPrivate; -import static org.powermock.api.mockito.PowerMockito.verifyStatic; -import static org.powermock.api.mockito.PowerMockito.when; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertSame; -import static org.testng.AssertJUnit.assertTrue; - -/** - * Unit tests for {@link SingleCalendarOperationsAdapter - * @deprecated - */ -@PrepareForTest({JerseyRequest.class, SingleCalendarOperationsAdapter.class, MultivaluedHashMap.class}) -public class SingleCalendarOperationsAdapterTest extends PowerMockTestCase { - - @Mock - private SessionStorage sessionStorageMock; - - @Mock - private JerseyRequest requestMock; - - @Mock - private JerseyRequest objRequestMock; - - @Mock - private OperationResult getResultMock; - - @Mock - private OperationResult delResultMock; - - @Mock - private OperationResult operationResultMock; - - @Mock - private ReportJobCalendar reportJobCalendarMock; - - @Mock - private Response responseMock; - - @Mock - private RequestBuilder builderMock; - - @Mock - private WithEntityOperationResult withEntityOperationResultMock; - - @Mock - private Calendar calendarEntityMock; - - @Mock - private Callback, Object> callbackMock3; - - @Mock - private Callback resultObjectCallbackMock; - - private MultivaluedHashMap paramsSpy; - - @BeforeMethod - public void before() { - initMocks(this); - paramsSpy = spy(new MultivaluedHashMap()); - } - - - @AfterMethod - public void after() { - reset(sessionStorageMock, requestMock, objRequestMock, getResultMock, delResultMock, - operationResultMock, reportJobCalendarMock, responseMock, withEntityOperationResultMock, - calendarEntityMock, builderMock, callbackMock3, responseMock); - } - - @Test - public void should_pass_proper_params_to_super_class() { - - // When - SingleCalendarOperationsAdapter calendarOperationsAdapter = - new SingleCalendarOperationsAdapter(sessionStorageMock, "testCalendarName"); - - // Then - assertSame(calendarOperationsAdapter.getSessionStorage(), sessionStorageMock); - Object calendarName = Whitebox.getInternalState(calendarOperationsAdapter, "calendarName"); - Object params = Whitebox.getInternalState(calendarOperationsAdapter, "params"); - - assertNotNull(params); - assertSame(calendarName, "testCalendarName"); - - assertTrue(instanceOf(String.class).matches(calendarName)); - assertTrue(instanceOf(MultivaluedHashMap.class).matches(params)); - - - } - - @Test - @SuppressWarnings("unchecked") - public void should_set_parameter_field_of_adapter() { - - // Given - SingleCalendarOperationsAdapter adapter = new SingleCalendarOperationsAdapter(sessionStorageMock, "MyCal"); - - // When - adapter.parameter(CalendarParameter.REPLACE, "true"); - MultivaluedMap params = (MultivaluedMap) Whitebox.getInternalState(adapter, "params"); - - // Then - Assert.assertTrue(Boolean.valueOf(params.get("replace").get(0))); - } - - @Test(enabled = false) - public void parameter() throws Exception { - - // Given - PowerMockito.whenNew(MultivaluedHashMap.class).withNoArguments().thenReturn(paramsSpy); - SingleCalendarOperationsAdapter adapterSpy = Mockito.spy(new SingleCalendarOperationsAdapter(sessionStorageMock, "testCalendarName")); - - // When - SingleCalendarOperationsAdapter retrieved = adapterSpy.parameter(CalendarParameter.UPDATE_TRIGGERS, "testValue"); - - // Then - verify(adapterSpy, times(1)).parameter(CalendarParameter.UPDATE_TRIGGERS, "testValue"); - verify(paramsSpy, times(1)).add(CalendarParameter.UPDATE_TRIGGERS.getName(), "testValue"); - verify(paramsSpy, never()).getFirst(anyString()); - - Assert.assertSame(retrieved, adapterSpy); - Assert.assertTrue(paramsSpy.size() == 1); - } - - @Test - public void get() throws Exception { - - // Given - mockStatic(JerseyRequest.class); - when(buildRequest(eq(sessionStorageMock), eq(ReportJobCalendar.class), - eq(new String[]{"jobs", "calendars", "testCalendarName"}))).thenReturn(requestMock); - doReturn(getResultMock).when(requestMock).get(); - SingleCalendarOperationsAdapter adapterSpy = spy(new SingleCalendarOperationsAdapter(sessionStorageMock, - "testCalendarName")); - doReturn(operationResultMock).when(adapterSpy, "convertToLocalCalendarType", getResultMock); - - // When - OperationResult retrieved = adapterSpy.get(); - - // Then - verifyStatic(times(1)); - buildRequest(eq(sessionStorageMock), eq(ReportJobCalendar.class), - eq(new String[]{"jobs", "calendars", "testCalendarName"})); - verifyPrivate(adapterSpy, times(1)).invoke("convertToLocalCalendarType", getResultMock); - assertSame(retrieved, operationResultMock); - } - - @Test(testName = "private") - public void convertToLocalCalendarType1() throws Exception { - - // Given - final Calendar expected = new BaseCalendar(); - expected.setCalendarType(CalendarType.base); - - PowerMockito.mockStatic(JerseyRequest.class); - PowerMockito.when(buildRequest(eq(sessionStorageMock), - eq(ReportJobCalendar.class), - eq(new String[]{"jobs", "calendars", "testCalendarName"}))).thenReturn(requestMock); - PowerMockito.doReturn(getResultMock).when(requestMock).get(); - PowerMockito.doReturn(responseMock).when(getResultMock).getResponse(); - PowerMockito.doReturn(reportJobCalendarMock).when(getResultMock).getEntity(); - PowerMockito.doReturn("base").when(reportJobCalendarMock).getCalendarType(); - - SingleCalendarOperationsAdapter adapterSpy = PowerMockito.spy(new SingleCalendarOperationsAdapter(sessionStorageMock, "testCalendarName")); - - // When - OperationResult retrieved = adapterSpy.get(); - - // Then - assertEquals(retrieved.getEntity(), expected); - verifyPrivate(adapterSpy, times(1)).invoke("convertToLocalCalendarType", eq(getResultMock)); - verify(getResultMock, times(1)).getEntity(); - verify(reportJobCalendarMock, times(2)).getCalendarType(); - } - - @Test(testName = "private") - public void convertToLocalCalendarType2() throws Exception { - - // Given - final AnnualCalendar expected = PowerMockito.mock(AnnualCalendar.class); - Whitebox.setInternalState(expected, "calendarType", CalendarType.annual); - - PowerMockito.mockStatic(JerseyRequest.class); - PowerMockito.when(buildRequest(sessionStorageMock, - ReportJobCalendar.class, - new String[]{"jobs", "calendars", "testCalendarName"})).thenReturn(requestMock); - PowerMockito.whenNew(AnnualCalendar.class).withNoArguments().thenReturn(expected); - PowerMockito.doReturn(getResultMock).when(requestMock).get(); - PowerMockito.doReturn(responseMock).when(getResultMock).getResponse(); - PowerMockito.doReturn(reportJobCalendarMock).when(getResultMock).getEntity(); - PowerMockito.doReturn("annual").when(reportJobCalendarMock).getCalendarType(); - - SingleCalendarOperationsAdapter adapterSpy = PowerMockito.spy(new SingleCalendarOperationsAdapter(sessionStorageMock, "testCalendarName")); - - // When - OperationResult retrieved = adapterSpy.get(); - - // Then - assertEquals(retrieved.getEntity(), expected); - verifyPrivate(adapterSpy, times(1)).invoke("setCommonCalendarFields", expected, reportJobCalendarMock); - verify(getResultMock, times(1)).getEntity(); - verify(reportJobCalendarMock, times(2)).getCalendarType(); - } - - - @Test(testName = "private") - public void convertToLocalCalendarType3() throws Exception { - - // Given - final CronCalendar expected = PowerMockito.mock(CronCalendar.class); - Whitebox.setInternalState(expected, "calendarType", CalendarType.cron); - - PowerMockito.mockStatic(JerseyRequest.class); - PowerMockito.when(buildRequest(eq(sessionStorageMock), - eq(ReportJobCalendar.class), - eq(new String[]{"jobs", "calendars", "testCalendarName"}))).thenReturn(requestMock); - PowerMockito.whenNew(CronCalendar.class).withNoArguments().thenReturn(expected); - PowerMockito.doReturn(getResultMock).when(requestMock).get(); - PowerMockito.doReturn(responseMock).when(getResultMock).getResponse(); - PowerMockito.doReturn(reportJobCalendarMock).when(getResultMock).getEntity(); - PowerMockito.doReturn("cron").when(reportJobCalendarMock).getCalendarType(); - - SingleCalendarOperationsAdapter adapterSpy = PowerMockito.spy(new SingleCalendarOperationsAdapter(sessionStorageMock, "testCalendarName")); - - // When - OperationResult retrieved = adapterSpy.get(); - - // Then - assertEquals(retrieved.getEntity(), expected); - verifyPrivate(adapterSpy, times(1)).invoke("setCommonCalendarFields", expected, reportJobCalendarMock); - verifyPrivate(adapterSpy, times(1)).invoke("convertToLocalCalendarType", eq(getResultMock)); - verify(getResultMock, times(1)).getEntity(); - verify(reportJobCalendarMock, times(2)).getCalendarType(); - } - - @Test(testName = "private") - public void convertToLocalCalendarType4() throws Exception { - - // Given - final DailyCalendar expected = PowerMockito.mock(DailyCalendar.class); - Whitebox.setInternalState(expected, "invertTimeRange", false); - Whitebox.setInternalState(expected, "calendarType", CalendarType.daily); - - PowerMockito.mockStatic(JerseyRequest.class); - PowerMockito.when(buildRequest(eq(sessionStorageMock), - eq(ReportJobCalendar.class), - eq(new String[]{"jobs", "calendars", "testCalendarName"}))).thenReturn(requestMock); - PowerMockito.whenNew(DailyCalendar.class).withNoArguments().thenReturn(expected); - PowerMockito.doReturn(getResultMock).when(requestMock).get(); - PowerMockito.doReturn(responseMock).when(getResultMock).getResponse(); - PowerMockito.doReturn(reportJobCalendarMock).when(getResultMock).getEntity(); - PowerMockito.doReturn("daily").when(reportJobCalendarMock).getCalendarType(); - - SingleCalendarOperationsAdapter adapterSpy = PowerMockito.spy(new SingleCalendarOperationsAdapter(sessionStorageMock, "testCalendarName")); - - // When - OperationResult retrieved = adapterSpy.get(); - - // Then - assertEquals(retrieved.getEntity(), expected); - verifyPrivate(adapterSpy, times(1)).invoke("setCommonCalendarFields", expected, reportJobCalendarMock); - verifyPrivate(adapterSpy, times(1)).invoke("convertToLocalCalendarType", eq(getResultMock)); - verify(getResultMock, times(1)).getEntity(); - verify(reportJobCalendarMock, times(2)).getCalendarType(); - } - - @Test(testName = "private") - public void convertToLocalCalendarType5() throws Exception { - - // Given - final HolidayCalendar expected = PowerMockito.mock(HolidayCalendar.class); - Whitebox.setInternalState(expected, "calendarType", CalendarType.holiday); - - PowerMockito.mockStatic(JerseyRequest.class); - PowerMockito.when(buildRequest(eq(sessionStorageMock), - eq(ReportJobCalendar.class), - eq(new String[]{"jobs", "calendars", "testCalendarName"}))).thenReturn(requestMock); - PowerMockito.whenNew(HolidayCalendar.class).withNoArguments().thenReturn(expected); - PowerMockito.doReturn(getResultMock).when(requestMock).get(); - PowerMockito.doReturn(responseMock).when(getResultMock).getResponse(); - PowerMockito.doReturn(reportJobCalendarMock).when(getResultMock).getEntity(); - PowerMockito.doReturn("holiday").when(reportJobCalendarMock).getCalendarType(); - - SingleCalendarOperationsAdapter adapterSpy = PowerMockito.spy(new SingleCalendarOperationsAdapter(sessionStorageMock, "testCalendarName")); - - // When - OperationResult retrieved = adapterSpy.get(); - - // Then - assertEquals(retrieved.getEntity(), expected); - - verifyPrivate(adapterSpy, times(1)).invoke("setCommonCalendarFields", expected, reportJobCalendarMock); - verifyPrivate(adapterSpy, times(1)).invoke("convertToLocalCalendarType", eq(getResultMock)); - verify(getResultMock, times(1)).getEntity(); - verify(reportJobCalendarMock, times(2)).getCalendarType(); - } - - @Test(testName = "private") - public void convertToLocalCalendarType6() throws Exception { - - // Given - final MonthlyCalendar expected = PowerMockito.mock(MonthlyCalendar.class); - Whitebox.setInternalState(expected, "calendarType", CalendarType.monthly); - - PowerMockito.mockStatic(JerseyRequest.class); - PowerMockito.when(buildRequest(eq(sessionStorageMock), - eq(ReportJobCalendar.class), - eq(new String[]{"jobs", "calendars", "testCalendarName"}))).thenReturn(requestMock); - PowerMockito.whenNew(MonthlyCalendar.class).withNoArguments().thenReturn(expected); - PowerMockito.doReturn(getResultMock).when(requestMock).get(); - PowerMockito.doReturn(responseMock).when(getResultMock).getResponse(); - PowerMockito.doReturn(reportJobCalendarMock).when(getResultMock).getEntity(); - PowerMockito.doReturn("monthly").when(reportJobCalendarMock).getCalendarType(); - - SingleCalendarOperationsAdapter adapterSpy = PowerMockito.spy(new SingleCalendarOperationsAdapter(sessionStorageMock, "testCalendarName")); - - // When - OperationResult retrieved = adapterSpy.get(); - - // Then - assertEquals(retrieved.getEntity(), expected); - verifyPrivate(adapterSpy, times(1)).invoke("setCommonCalendarFields", expected, reportJobCalendarMock); - verifyPrivate(adapterSpy, times(1)).invoke("convertToLocalCalendarType", eq(getResultMock)); - verify(getResultMock, times(1)).getEntity(); - verify(reportJobCalendarMock, times(2)).getCalendarType(); - } - - @Test(testName = "private") - public void convertToLocalCalendarType7() throws Exception { - - // Given - final WeeklyCalendar expected = PowerMockito.mock(WeeklyCalendar.class); - Whitebox.setInternalState(expected, "calendarType", CalendarType.weekly); - - PowerMockito.mockStatic(JerseyRequest.class); - PowerMockito.when(buildRequest(eq(sessionStorageMock), - eq(ReportJobCalendar.class), - eq(new String[]{"jobs", "calendars", "testCalendarName"}))).thenReturn(requestMock); - PowerMockito.whenNew(WeeklyCalendar.class).withNoArguments().thenReturn(expected); - PowerMockito.doReturn(getResultMock).when(requestMock).get(); - PowerMockito.doReturn(responseMock).when(getResultMock).getResponse(); - PowerMockito.doReturn(reportJobCalendarMock).when(getResultMock).getEntity(); - PowerMockito.doReturn("weekly").when(reportJobCalendarMock).getCalendarType(); - - SingleCalendarOperationsAdapter adapterSpy = PowerMockito.spy(new SingleCalendarOperationsAdapter(sessionStorageMock, "testCalendarName")); - - // When - OperationResult retrieved = adapterSpy.get(); - - // Then - assertEquals(retrieved.getEntity(), expected); - verifyPrivate(adapterSpy, times(1)).invoke("setCommonCalendarFields", expected, reportJobCalendarMock); - verifyPrivate(adapterSpy, times(1)).invoke("convertToLocalCalendarType", eq(getResultMock)); - verify(getResultMock, times(1)).getEntity(); - verify(reportJobCalendarMock, times(2)).getCalendarType(); - } - - @Test - public void delete() throws Exception { - - // Given - mockStatic(JerseyRequest.class); - when(buildRequest(eq(sessionStorageMock), - eq(Object.class), - eq(new String[]{"jobs", "calendars", "testCalendarName"}))).thenReturn(objRequestMock); - doReturn(delResultMock).when(objRequestMock).delete(); - SingleCalendarOperationsAdapter adapterSpy = spy(new SingleCalendarOperationsAdapter(sessionStorageMock, "testCalendarName")); - - // When - OperationResult retrieved = adapterSpy.delete(); - - // Then - verifyStatic(times(1)); - buildRequest(eq(sessionStorageMock), eq(Object.class), eq(new String[]{"jobs", "calendars", "testCalendarName"})); - assertSame(retrieved, delResultMock); - } - - @Test - @SuppressWarnings("unchecked") - public void createNew() { - - // Given - mockStatic(JerseyRequest.class); - when(buildRequest(eq(sessionStorageMock), - eq(ReportJobCalendar.class), - eq(new String[]{"jobs", "calendars", "testCalendarName"}))).thenReturn(requestMock); - PowerMockito.when(requestMock.put(calendarEntityMock)).thenReturn(getResultMock); - SingleCalendarOperationsAdapter adapterSpy = spy(new SingleCalendarOperationsAdapter(sessionStorageMock, "testCalendarName")); - - // When - OperationResult retrieved = adapterSpy.createNew(calendarEntityMock); - - // Then - verifyStatic(times(1)); - buildRequest(eq(sessionStorageMock), - eq(ReportJobCalendar.class), - eq(new String[]{"jobs", "calendars", "testCalendarName"})); - assertSame(retrieved, getResultMock); - - MultivaluedMap retrievedParams = (MultivaluedMap) Whitebox.getInternalState(adapterSpy, "params"); - Mockito.verify(requestMock).addParams(retrievedParams); - Mockito.verify(requestMock).put(calendarEntityMock); - } - - @Test - public void asyncGet() throws Exception { - - // Given - final AtomicInteger newThreadId = new AtomicInteger(); - final int currentThreadId = (int) Thread.currentThread().getId(); - - PowerMockito.mockStatic(JerseyRequest.class); - PowerMockito.when( - buildRequest( - eq(sessionStorageMock), - eq(ReportJobCalendar.class), - eq(new String[]{"/jobs", "/calendars", "testCalendarName"}))) - .thenReturn(requestMock); - - SingleCalendarOperationsAdapter adapterSpy = spy(new SingleCalendarOperationsAdapter(sessionStorageMock, "testCalendarName")); - - Callback, Void> callback = PowerMockito.spy(new Callback, Void>() { - public Void execute(OperationResult data) { - newThreadId.set((int) Thread.currentThread().getId()); - synchronized (this) { - this.notify(); - } - return null; - } - }); - - PowerMockito.doReturn(operationResultMock).when(adapterSpy, "convertToLocalCalendarType", getResultMock); - PowerMockito.doReturn(getResultMock).when(requestMock).get(); - PowerMockito.doReturn(null).when(callback).execute(operationResultMock); - - // When - RequestExecution retrieved = adapterSpy.asyncGet(callback); - - // Wait - synchronized (callback) { - callback.wait(500); - } - - // Then - Assert.assertNotNull(retrieved); - Assert.assertNotSame(currentThreadId, newThreadId.get()); - //Mockito.verify(callback, times(1)).execute(operationResultMock); - //verifyPrivate(adapterSpy, times(1)).invoke("convertToLocalCalendarType", getResultMock); - } - - @Test(enabled = false) - public void asyncDelete() throws Exception { - - PowerMockito.mockStatic(JerseyRequest.class); - PowerMockito.when( - buildRequest( - eq(sessionStorageMock), - eq(Object.class), - eq(new String[]{"/jobs", "/calendars", "testCalendarName"}))) - .thenReturn(objRequestMock); - - SingleCalendarOperationsAdapter adapterSpy = spy(new SingleCalendarOperationsAdapter(sessionStorageMock, "testCalendarName")); - PowerMockito.doReturn(delResultMock).when(objRequestMock).delete(); - PowerMockito.doReturn(new Object()).when(resultObjectCallbackMock).execute(delResultMock); - - // When - adapterSpy.asyncDelete(resultObjectCallbackMock); - - // Then - verifyStatic(times(1)); - JerseyRequest.buildRequest( - eq(sessionStorageMock), - eq(Object.class), - eq(new String[]{"/jobs", "/calendars", "testCalendarName"})); - - Mockito.verify(resultObjectCallbackMock).execute(delResultMock); - } - - @Test - public void asyncCreateNew() throws Exception { - - PowerMockito.mockStatic(JerseyRequest.class); - PowerMockito.whenNew(MultivaluedHashMap.class).withNoArguments().thenReturn(paramsSpy); - PowerMockito.when( - buildRequest( - eq(sessionStorageMock), - eq(ReportJobCalendar.class), - eq(new String[]{"jobs", "calendars", "testCalendarName"}))) - .thenReturn(requestMock); - - SingleCalendarOperationsAdapter adapterSpy = PowerMockito.spy(new SingleCalendarOperationsAdapter(sessionStorageMock, "testCalendarName")); - - PowerMockito.doReturn(getResultMock).when(requestMock).put(calendarEntityMock); - PowerMockito.doReturn(new Object()).when(callbackMock3).execute(getResultMock); - PowerMockito.doReturn(builderMock).when(requestMock).addParams(paramsSpy); - // When - adapterSpy.asyncCreateNew(calendarEntityMock, callbackMock3); - - // Then - verifyStatic(times(1)); - JerseyRequest.buildRequest( - eq(sessionStorageMock), - eq(ReportJobCalendar.class), - eq(new String[]{"jobs", "calendars", "testCalendarName"})); - } - - @Test - public void should_delete_calendar_asynchronously() throws InterruptedException { - - /* Given */ - PowerMockito.mockStatic(JerseyRequest.class); - PowerMockito.when(buildRequest(eq(sessionStorageMock), - eq(Object.class), - eq(new String[]{"jobs", "calendars", "testCalendarName"}))).thenReturn(objRequestMock); - - PowerMockito.doReturn(delResultMock).when(objRequestMock).delete(); - - final AtomicInteger newThreadId = new AtomicInteger(); - final int currentThreadId = (int) Thread.currentThread().getId(); - - final Callback callback = PowerMockito.spy(new Callback() { - @Override - public Void execute(OperationResult data) { - newThreadId.set((int) Thread.currentThread().getId()); - synchronized (this) { - this.notify(); - } - return null; - } - }); - - SingleCalendarOperationsAdapter adapterSpy = PowerMockito.spy(new SingleCalendarOperationsAdapter(sessionStorageMock, "testCalendarName")); - - /* When */ - RequestExecution retrieved = adapterSpy.asyncDelete(callback); - - /* Wait */ - synchronized (callback) { - callback.wait(500); - } - - /* Then */ - Assert.assertNotNull(retrieved); - Assert.assertNotSame(currentThreadId, newThreadId.get()); - - Mockito.verify(objRequestMock).delete(); - Mockito.verify(callback).execute(delResultMock); - } - -} \ No newline at end of file diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/jobs/calendar/SingleCalendarOperationsAdapterTestNew.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/jobs/calendar/SingleCalendarOperationsAdapterTestNew.java index 2a9212dc..8f78aea7 100644 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/jobs/calendar/SingleCalendarOperationsAdapterTestNew.java +++ b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/jobs/calendar/SingleCalendarOperationsAdapterTestNew.java @@ -14,7 +14,7 @@ import javax.ws.rs.core.Response; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.internal.util.reflection.Whitebox; +import org.powermock.reflect.Whitebox; import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.testng.PowerMockTestCase; @@ -25,8 +25,8 @@ import static com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest.buildRequest; import static org.hamcrest.core.IsInstanceOf.instanceOf; -import static org.mockito.Matchers.anyString; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.never; import static org.mockito.Mockito.reset; import static org.mockito.Mockito.times; @@ -41,12 +41,6 @@ import static org.testng.AssertJUnit.assertSame; import static org.testng.AssertJUnit.assertTrue; -//import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.calendar.Calendar; -//import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.calendar.CronCalendar; -//import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.calendar.DailyCalendar; -//import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.calendar.HolidayCalendar; -//import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.calendar.MonthlyCalendar; -//import com.jaspersoft.jasperserver.jaxrs.client.dto.jobs.calendar.WeeklyCalendar; /** * Unit tests for {@link com.jaspersoft.jasperserver.jaxrs.client.apiadapters.jobs.calendar.SingleCalendarOperationsAdapter} @@ -171,7 +165,7 @@ public void get() throws Exception { OperationResult retrieved = adapterSpy.getCalendar(); // Then - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); buildRequest(eq(sessionStorageMock), eq(ClientJobCalendar.class), eq(new String[]{"jobs", "calendars", "testCalendarName"})); assertSame(retrieved, operationResultMock); @@ -192,7 +186,7 @@ public void delete() throws Exception { OperationResult retrieved = adapterSpy.delete(); // Then - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); buildRequest(eq(sessionStorageMock), eq(Object.class), eq(new String[]{"jobs", "calendars", "testCalendarName"})); assertSame(retrieved, delResultMock); } @@ -213,7 +207,7 @@ public void createNew() { OperationResult retrieved = adapterSpy.createNewCalendar(calendarEntityMock); // Then - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); buildRequest(eq(sessionStorageMock), eq(ClientJobCalendar.class), eq(new String[]{"jobs", "calendars", "testCalendarName"})); @@ -251,9 +245,8 @@ public Void execute(OperationResult data) { } }); - PowerMockito.doReturn(operationResultMock).when(adapterSpy, "convertToLocalCalendarType", operationResultMock); PowerMockito.doReturn(operationResultMock).when(requestMock).get(); - PowerMockito.doReturn(null).when(callback).execute(operationResultMock); + PowerMockito.doNothing().when(callback).execute(operationResultMock); // When RequestExecution retrieved = adapterSpy.asyncGetCalendar(callback); @@ -287,7 +280,7 @@ public void asyncDelete() throws Exception { adapterSpy.asyncDelete(resultObjectCallbackMock); // Then - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); JerseyRequest.buildRequest( eq(sessionStorageMock), eq(Object.class), @@ -316,7 +309,7 @@ public void asyncCreateNew() throws Exception { adapterSpy.asyncCreateNewCalendar(calendarEntityMock, callbackMock3); // Then - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); JerseyRequest.buildRequest( eq(sessionStorageMock), eq(ClientJobCalendar.class), diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/jobsNew/BatchJobsOperationsAdapterTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/jobsNew/BatchJobsOperationsAdapterTest.java index e2888093..b9e351d5 100644 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/jobsNew/BatchJobsOperationsAdapterTest.java +++ b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/jobsNew/BatchJobsOperationsAdapterTest.java @@ -9,13 +9,13 @@ import com.jaspersoft.jasperserver.jaxrs.client.core.operationresult.OperationResult; import javax.ws.rs.core.MultivaluedHashMap; import org.mockito.Mock; -import org.mockito.internal.util.reflection.Whitebox; +import org.powermock.reflect.Whitebox; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.testng.PowerMockTestCase; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -80,7 +80,7 @@ public void should_return_all_jobs() { OperationResult retrieved = adapter.searchJobs(); // Then - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); JerseyRequest.buildRequest(eq(sessionStorageMock), eq(ClientJobSummariesListWrapper.class), eq(new String[]{"jobs"})); verify(jobSummaryListWrapperJerseyRequest, times(1)).get(); assertNotNull(retrieved); diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/jobsNew/JobsServiceTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/jobsNew/JobsServiceTest.java index 3f11f7d8..e0ad72e5 100644 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/jobsNew/JobsServiceTest.java +++ b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/jobsNew/JobsServiceTest.java @@ -4,7 +4,6 @@ import com.jaspersoft.jasperserver.dto.job.ClientReportJob; import com.jaspersoft.jasperserver.dto.job.wrappers.ClientCalendarNameListWrapper; import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.jobs.BatchJobsOperationsAdapter; -import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.jobs.JobValidationErrorHandler; import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.jobs.JobsService; import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.jobs.SingleJobOperationsAdapter; import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.jobs.calendar.CalendarType; @@ -14,10 +13,7 @@ import com.jaspersoft.jasperserver.jaxrs.client.core.RequestExecution; import com.jaspersoft.jasperserver.jaxrs.client.core.RestClientConfiguration; import com.jaspersoft.jasperserver.jaxrs.client.core.SessionStorage; -import com.jaspersoft.jasperserver.jaxrs.client.core.enums.JRSVersion; -import com.jaspersoft.jasperserver.jaxrs.client.core.enums.MimeType; import com.jaspersoft.jasperserver.jaxrs.client.core.operationresult.OperationResult; -import java.util.concurrent.atomic.AtomicInteger; import org.mockito.Mock; import org.mockito.Mockito; import org.powermock.api.mockito.PowerMockito; @@ -28,9 +24,10 @@ import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; +import java.util.concurrent.atomic.AtomicInteger; + import static com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest.buildRequest; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.never; import static org.mockito.Mockito.reset; @@ -128,81 +125,19 @@ public void should_return_proper_SingleJobOperationsAdapter() throws Exception { assertSame(retrieved, expectedJobOperationsAdapter); } - @Test(testName = "scheduleReport_for_v5_6_1") - public void should_return_proper_OperationResult_when_JRS_version_is_v5_6_1() { - - // Given - JobsService serviceSpy = spy(new JobsService(sessionStorageMock)); - - mockStatic(JerseyRequest.class); - when(JerseyRequest.buildRequest(eq(sessionStorageMock), - eq(ClientReportJob.class), - eq(new String[]{"jobs"}), - any(JobValidationErrorHandler.class))).thenReturn(jobRequestMock); - when(jobRequestMock.put(reportMock)).thenReturn(expectedJobOperationResultMock); - when(sessionStorageMock.getConfiguration()).thenReturn(configurationMock); - when(configurationMock.getJrsVersion()).thenReturn(JRSVersion.v5_6_1); - when(configurationMock.getContentMimeType()).thenReturn(MimeType.XML); - - // When - serviceSpy.scheduleReport(reportMock); - - // Then - verifyStatic(times(1)); - JerseyRequest.buildRequest(eq(sessionStorageMock), - eq(ClientReportJob.class), - eq(new String[]{"jobs"}), - any(JobValidationErrorHandler.class)); - verify(jobRequestMock, times(1)).put(reportMock); - verify(jobRequestMock, times(1)).setContentType("application/job+xml"); - verify(jobRequestMock, times(1)).setAccept("application/job+xml"); - } - - @Test(testName = "scheduleReport_for_v4_7_0") - public void should_return_proper_OperationResult_when_JRS_version_is_v4_7_0() { - - // Given - mockStatic(JerseyRequest.class); - when(JerseyRequest.buildRequest(eq(sessionStorageMock), - eq(ClientReportJob.class), - eq(new String[]{"jobs"}), - any(JobValidationErrorHandler.class))).thenReturn(jobRequestMock); - when(jobRequestMock.put(reportMock)).thenReturn(expectedJobOperationResultMock); - when(sessionStorageMock.getConfiguration()).thenReturn(configurationMock); - when(configurationMock.getJrsVersion()).thenReturn(JRSVersion.v4_7_0); - when(configurationMock.getContentMimeType()).thenReturn(MimeType.JSON); - JobsService serviceSpy = spy(new JobsService(sessionStorageMock)); - - // When - OperationResult retrieved = serviceSpy.scheduleReport(reportMock); - - // Then - verifyStatic(times(1)); - JerseyRequest.buildRequest(eq(sessionStorageMock), - eq(ClientReportJob.class), - eq(new String[]{"jobs"}), - any(JobValidationErrorHandler.class)); - verify(jobRequestMock, times(1)).put(reportMock); - verify(jobRequestMock, times(1)).setContentType("application/job+json"); - verify(jobRequestMock, times(1)).setAccept("application/job+json"); - - assertNotNull(retrieved); - assertSame(retrieved, expectedJobOperationResultMock); - } - @Test(testName = "allCalendars") public void should_return_proper_op_result_object() { // Given JobsService serviceSpy = spy(new JobsService(sessionStorageMock)); - doReturn(expectedWrapperOperationResultMock).when(serviceSpy).calendar((ClientJobCalendar.Type )null); + doReturn(expectedWrapperOperationResultMock).when(serviceSpy).calendar((ClientJobCalendar.Type) null); // When OperationResult retrieved = serviceSpy.allCalendars(); // Then verify(serviceSpy, times(1)).allCalendars(); - verify(serviceSpy, times(1)).calendar(((ClientJobCalendar.Type)null)); + verify(serviceSpy, times(1)).calendar(((ClientJobCalendar.Type) null)); verify(serviceSpy, never()).calendar(ClientJobCalendar.Type.holiday); verifyNoMoreInteractions(serviceSpy); @@ -244,7 +179,7 @@ public void should_return_proper_op_result_object_when_param_is_not_null() { assertNotNull(retrieved); assertSame(retrieved, expectedWrapperOperationResultMock); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); JerseyRequest.buildRequest(eq(sessionStorageMock), eq(ClientCalendarNameListWrapper.class), eq(new String[]{"jobs", "calendars"})); @@ -266,13 +201,13 @@ public void should_return_proper_op_result_object_when_param_is_null() { JobsService serviceSpy = spy(new JobsService(sessionStorageMock)); // When - OperationResult retrieved = serviceSpy.calendar((ClientJobCalendar.Type)null); + OperationResult retrieved = serviceSpy.calendar((ClientJobCalendar.Type) null); // Then assertNotNull(retrieved); assertSame(retrieved, expectedWrapperOperationResultMock); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); JerseyRequest.buildRequest(eq(sessionStorageMock), eq(ClientCalendarNameListWrapper.class), eq(new String[]{"jobs", "calendars"})); @@ -333,7 +268,7 @@ public Void execute(OperationResult data) { } }); - PowerMockito.doReturn(null).when(callback).execute(expectedWrapperOperationResultMock); + PowerMockito.doNothing().when(callback).execute(expectedWrapperOperationResultMock); /* When */ RequestExecution retrieved = serviceSpy.asyncCalendar(ClientJobCalendar.Type.annual, callback); @@ -352,115 +287,9 @@ public Void execute(OperationResult data) { Mockito.verify(wrapperRequestMock).addParam("calendarType", "annual"); } - @Test - public void should_send_ScheduleReport_asynchronously_() throws InterruptedException { - - /* Given */ - PowerMockito.mockStatic(JerseyRequest.class); - PowerMockito.when(buildRequest(eq(sessionStorageMock), - eq(ClientReportJob.class), - eq(new String[]{"jobs"}), - any(JobValidationErrorHandler.class))).thenReturn(jobRequestMock); - - PowerMockito.doReturn(expectedJobOperationResultMock).when(jobRequestMock).put(reportMock); - JobsService serviceSpy = PowerMockito.spy(new JobsService(sessionStorageMock)); - - final AtomicInteger newThreadId = new AtomicInteger(); - final int currentThreadId = (int) Thread.currentThread().getId(); - - final Callback, Void> callback = PowerMockito.spy(new Callback, Void>() { - @Override - public Void execute(OperationResult data) { - newThreadId.set((int) Thread.currentThread().getId()); - synchronized (this) { - this.notify(); - } - return null; - } - }); - - PowerMockito.doReturn(null).when(callback).execute(expectedJobOperationResultMock); - PowerMockito.doReturn(configurationMock).when(sessionStorageMock).getConfiguration(); - PowerMockito.doReturn(JRSVersion.v5_0_0).when(configurationMock).getJrsVersion(); - PowerMockito.doReturn(null).when(callback).execute(expectedJobOperationResultMock); - PowerMockito.doReturn(null).when(callback).execute(expectedJobOperationResultMock); - - /* When */ - RequestExecution retrieved = serviceSpy.asyncScheduleReport(reportMock, callback); - - /* Wait */ - synchronized (callback) { - callback.wait(1000); - } - - /* Then */ - Assert.assertNotNull(retrieved); - Assert.assertNotSame(currentThreadId, newThreadId.get()); - - Mockito.verify(jobRequestMock).put(reportMock); - Mockito.verify(jobRequestMock).setContentType("application/job+json"); - Mockito.verify(jobRequestMock).setAccept("application/job+json"); - Mockito.verify(callback).execute(expectedJobOperationResultMock); - Mockito.verify(sessionStorageMock).getConfiguration(); - Mockito.verify(configurationMock).getJrsVersion(); - } - - @Test - public void should_send_ScheduleReport_asynchronously() throws InterruptedException { - - /* Given */ - PowerMockito.mockStatic(JerseyRequest.class); - PowerMockito.when(buildRequest(eq(sessionStorageMock), - eq(ClientReportJob.class), - eq(new String[]{"jobs"}), - any(JobValidationErrorHandler.class))).thenReturn(jobRequestMock); - - PowerMockito.doReturn(expectedJobOperationResultMock).when(jobRequestMock).put(reportMock); - JobsService serviceSpy = PowerMockito.spy(new JobsService(sessionStorageMock)); - - final AtomicInteger newThreadId = new AtomicInteger(); - final int currentThreadId = (int) Thread.currentThread().getId(); - - final Callback, Void> callback = PowerMockito.spy(new Callback, Void>() { - @Override - public Void execute(OperationResult data) { - newThreadId.set((int) Thread.currentThread().getId()); - synchronized (this) { - this.notify(); - } - return null; - } - }); - - PowerMockito.doReturn(null).when(callback).execute(expectedJobOperationResultMock); - PowerMockito.doReturn(configurationMock).when(sessionStorageMock).getConfiguration(); - PowerMockito.doReturn(JRSVersion.v5_6_1).when(configurationMock).getJrsVersion(); - PowerMockito.doReturn(null).when(callback).execute(expectedJobOperationResultMock); - PowerMockito.doReturn(null).when(callback).execute(expectedJobOperationResultMock); - - /* When */ - RequestExecution retrieved = serviceSpy.asyncScheduleReport(reportMock, callback); - - /* Wait */ - synchronized (callback) { - callback.wait(1000); - } - - /* Then */ - Assert.assertNotNull(retrieved); - Assert.assertNotSame(currentThreadId, newThreadId.get()); - - Mockito.verify(jobRequestMock).put(reportMock); - Mockito.verify(jobRequestMock).setContentType("application/job+xml"); - Mockito.verify(jobRequestMock).setAccept("application/job+xml"); - Mockito.verify(callback).execute(expectedJobOperationResultMock); - Mockito.verify(sessionStorageMock, times(3)).getConfiguration(); - Mockito.verify(configurationMock).getJrsVersion(); - } - @AfterMethod public void after() { reset(sessionStorageMock, expectedAdapterMock, expectedJobOperationsAdapter, - jobRequestMock, expectedJobOperationResultMock, reportMock, configurationMock); + jobRequestMock, expectedJobOperationResultMock, reportMock, configurationMock); } } \ No newline at end of file diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/jobsNew/SingleJobOperationsAdapterTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/jobsNew/SingleJobOperationsAdapterTest.java index 5c65ac66..30d4e0fe 100644 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/jobsNew/SingleJobOperationsAdapterTest.java +++ b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/jobsNew/SingleJobOperationsAdapterTest.java @@ -25,8 +25,8 @@ import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.reset; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.times; @@ -109,7 +109,7 @@ public void should_return_proper_job_operation_result_when_JRS_version_is_v5_6_1 OperationResult retrieved = adapter.getJob(); // Then - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); JerseyRequest.buildRequest(eq(sessionStorageMock), eq(ClientReportJob.class), eq(new String[]{"jobs", expectedJobId})); verify(jobRequestMock, times(1)).get(); verify(jobRequestMock, times(1)).setAccept("application/job+xml"); @@ -134,7 +134,7 @@ public void should_return_proper_job_operation_result_when_JRS_version_is_v4_7_0 OperationResult retrieved = adapter.getJob(); // Then - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); JerseyRequest.buildRequest(eq(sessionStorageMock), eq(ClientReportJob.class), eq(new String[]{"jobs", expectedJobId})); verify(jobRequestMock, times(1)).get(); verify(jobRequestMock, times(1)).setAccept("application/job+json"); @@ -157,7 +157,7 @@ public void should_proper_op_result_instance() { OperationResult retrieved = adapter.jobState(); // Then - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); JerseyRequest.buildRequest(eq(sessionStorageMock), eq(ClientJobState.class), eq(new String[]{"jobs", expectedJobId, "state"})); verify(jobStateJerseyRequestMock, times(1)).get(); @@ -181,7 +181,7 @@ public void should_return_prepared_op_result_when_jrs_version_is_5_6_1() { OperationResult retrieved = adapter.update(jobMock); // Then - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); JerseyRequest.buildRequest(eq(sessionStorageMock), eq(ClientReportJob.class), eq(new String[]{"jobs", expectedJobId}), any(JobValidationErrorHandler.class)); verify(jobRequestMock, times(1)).post(jobMock); verify(jobRequestMock, times(1)).setContentType("application/job+xml"); @@ -208,7 +208,7 @@ public void should_return_prepared_op_result_when_jrs_version_is_4_7_0() { OperationResult retrieved = adapter.update(jobMock); // Then - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); JerseyRequest.buildRequest(eq(sessionStorageMock), eq(ClientReportJob.class), eq(new String[]{"jobs", expectedJobId}), any(JobValidationErrorHandler.class)); verify(jobRequestMock, times(1)).post(jobMock); verify(jobRequestMock, times(1)).setContentType("application/job+json"); @@ -232,7 +232,7 @@ public void should_proper_op_result_instance_for_deleting_operation() { OperationResult retrieved = adapter.delete(); // Then - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); JerseyRequest.buildRequest(eq(sessionStorageMock), eq(Object.class), eq(new String[]{"jobs", expectedJobId})); verify(objectJerseyRequestMock, times(1)).delete(); assertSame(retrieved, operationResultMock); @@ -264,7 +264,7 @@ public Void execute(OperationResult data) { }); PowerMockito.doReturn(jobOperationResultMock).when(jobRequestMock).post(jobMock); - PowerMockito.doReturn(null).when(callback).execute(jobOperationResultMock); + PowerMockito.doNothing().when(callback).execute(jobOperationResultMock); PowerMockito.doReturn(configurationMock).when(sessionStorageMock).getConfiguration(); PowerMockito.doReturn(JRSVersion.v5_1_0).when(configurationMock).getJrsVersion(); @@ -314,7 +314,7 @@ public Void execute(OperationResult data) { }); PowerMockito.doReturn(jobOperationResultMock).when(jobRequestMock).post(jobMock); - PowerMockito.doReturn(null).when(callback).execute(jobOperationResultMock); + PowerMockito.doNothing().when(callback).execute(jobOperationResultMock); PowerMockito.doReturn(configurationMock).when(sessionStorageMock).getConfiguration(); PowerMockito.doReturn(JRSVersion.v5_6_1).when(configurationMock).getJrsVersion(); @@ -364,7 +364,7 @@ public Void execute(OperationResult data) { }); PowerMockito.doReturn(jobOperationResultMock).when(jobRequestMock).get(); - PowerMockito.doReturn(null).when(callback).execute(jobOperationResultMock); + PowerMockito.doNothing().when(callback).execute(jobOperationResultMock); PowerMockito.doReturn(configurationMock).when(sessionStorageMock).getConfiguration(); PowerMockito.doReturn(JRSVersion.v5_6_1).when(configurationMock).getJrsVersion(); PowerMockito.doReturn(MimeType.JSON).when(configurationMock).getAcceptMimeType(); @@ -415,7 +415,7 @@ public Void execute(OperationResult data) { }); PowerMockito.doReturn(jobOperationResultMock).when(jobRequestMock).get(); - PowerMockito.doReturn(null).when(callback).execute(jobOperationResultMock); + PowerMockito.doNothing().when(callback).execute(jobOperationResultMock); PowerMockito.doReturn(configurationMock).when(sessionStorageMock).getConfiguration(); PowerMockito.doReturn(JRSVersion.v4_7_0).when(configurationMock).getJrsVersion(); @@ -465,7 +465,7 @@ public Void execute(OperationResult data) { }); PowerMockito.doReturn(operationResultMock).when(objectJerseyRequestMock).delete(); - PowerMockito.doReturn(null).when(callback).execute(operationResultMock); + PowerMockito.doNothing().when(callback).execute(operationResultMock); // When RequestExecution retrieved = adapterSpy.asyncDelete(callback); @@ -508,7 +508,7 @@ public Void execute(OperationResult data) { }); PowerMockito.doReturn(jobStateOperationResultMock).when(jobStateJerseyRequestMock).get(); - PowerMockito.doReturn(null).when(callback).execute(jobStateOperationResultMock); + PowerMockito.doNothing().when(callback).execute(jobStateOperationResultMock); // When RequestExecution retrieved = adapterSpy.asyncJobState(callback); diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/permissions/PermissionResourceRequestAdapterTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/permissions/PermissionResourceRequestAdapterTest.java deleted file mode 100644 index 54b249e1..00000000 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/permissions/PermissionResourceRequestAdapterTest.java +++ /dev/null @@ -1,347 +0,0 @@ -package com.jaspersoft.jasperserver.jaxrs.client.apiadapters.permissions; - -import com.jaspersoft.jasperserver.dto.permissions.RepositoryPermissionListWrapper; -import com.jaspersoft.jasperserver.jaxrs.client.core.Callback; -import com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest; -import com.jaspersoft.jasperserver.jaxrs.client.core.RequestExecution; -import com.jaspersoft.jasperserver.jaxrs.client.core.RestClientConfiguration; -import com.jaspersoft.jasperserver.jaxrs.client.core.SessionStorage; -import com.jaspersoft.jasperserver.jaxrs.client.core.enums.MimeType; -import com.jaspersoft.jasperserver.jaxrs.client.core.operationresult.OperationResult; -import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.concurrent.atomic.AtomicInteger; -import javax.ws.rs.core.MultivaluedMap; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.testng.PowerMockTestCase; -import org.testng.Assert; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import static com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest.buildRequest; -import static java.util.Arrays.asList; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoMoreInteractions; -import static org.mockito.Mockito.when; -import static org.mockito.MockitoAnnotations.initMocks; -import static org.powermock.api.mockito.PowerMockito.mockStatic; -import static org.powermock.api.mockito.PowerMockito.verifyStatic; -import static org.powermock.api.support.membermodification.MemberMatcher.field; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertSame; -import static org.testng.Assert.assertTrue; - -/** - * Unit tests for {@link PermissionResourceRequestAdapter} - */ -@PrepareForTest({JerseyRequest.class}) -public class PermissionResourceRequestAdapterTest extends PowerMockTestCase { - - @Mock - private SessionStorage sessionStorageMock; - - @Mock - private JerseyRequest requestMock; - - @Mock - private RepositoryPermissionListWrapper wrapperMock; - - @Mock - private OperationResult expectedResultMock; - - @Mock - private RestClientConfiguration configurationMock; - - private String fakeUri = "resourceUri"; - - @BeforeMethod - public void before() { - initMocks(this); - } - - @Test(testName = "constructor") - @SuppressWarnings("unchecked") - public void should_set_fields_in_constructor_and_pass_session_to_parent_class() throws IllegalAccessException { - - // When - PermissionResourceRequestAdapter adapter = new PermissionResourceRequestAdapter(sessionStorageMock, fakeUri); - - // Reflection hack - Field resUri = field(PermissionResourceRequestAdapter.class, "resourceUri"); - Field params = field(PermissionResourceRequestAdapter.class, "params"); - String uri = (String) resUri.get(adapter); - MultivaluedMap paramsMap = (MultivaluedMap) params.get(adapter); - - // Then - assertSame(adapter.getSessionStorage(), sessionStorageMock); - assertNotNull(uri); - assertNotNull(paramsMap); - } - - @Test(testName = "permissionRecipient") - public void should_return_proper_adapter() throws IllegalAccessException { - - // Given - PermissionResourceRequestAdapter adapter = new PermissionResourceRequestAdapter(sessionStorageMock, fakeUri); - - // When - SinglePermissionRecipientRequestAdapter retrieved = adapter.permissionRecipient(PermissionRecipient.ROLE, "abc"); - - Field recipientField = field(SinglePermissionRecipientRequestAdapter.class, "recipient"); - Field pathField = field(SinglePermissionRecipientRequestAdapter.class, "path"); - - String recipient = (String) recipientField.get(retrieved); - ArrayList path = (ArrayList) pathField.get(retrieved); - - // Then - assertEquals(recipient, "role:%2Fabc"); - assertEquals(path, asList("permissions", fakeUri)); - } - - @Test(testName = "updateOrCreate") - public void should_return_proper_OperationResult_instance() { - - // Given - mockStatic(JerseyRequest.class); - when(JerseyRequest.buildRequest(sessionStorageMock, - RepositoryPermissionListWrapper.class, - new String[]{"permissions", fakeUri})).thenReturn(requestMock); - when(sessionStorageMock.getConfiguration()).thenReturn(configurationMock); - when(configurationMock.getContentMimeType()).thenReturn(MimeType.JSON); - doReturn(expectedResultMock).when(requestMock).put(wrapperMock); - - // When - PermissionResourceRequestAdapter adapter = new PermissionResourceRequestAdapter(sessionStorageMock, fakeUri); - OperationResult retrieved = adapter.createOrUpdate(wrapperMock); - - // Then - verifyStatic(times(1)); - JerseyRequest.buildRequest(sessionStorageMock, RepositoryPermissionListWrapper.class, new String[]{"permissions", fakeUri}); - - verify(requestMock, times(1)).setContentType("application/collection+json"); - verify(requestMock, times(1)).put(wrapperMock); - verifyNoMoreInteractions(requestMock); - - assertNotNull(retrieved); - assertEquals(retrieved, expectedResultMock); - } - - @Test(testName = "param") - @SuppressWarnings("unchecked") - public void should_set_field_of_adapter_and_invoke_param_method_only_once() throws IllegalAccessException { - - // Given - PermissionResourceRequestAdapter adapter = spy(new PermissionResourceRequestAdapter(sessionStorageMock, fakeUri)); - - // When - adapter.param(PermissionResourceParameter.EFFECTIVE_PERMISSIONS, "somePermissions"); - - Field paramsField = field(PermissionResourceRequestAdapter.class, "params"); - MultivaluedMap retrieved = (MultivaluedMap) paramsField.get(adapter); - - // Then - assertTrue(retrieved.size() == 1); - verify(adapter, times(1)).param(PermissionResourceParameter.EFFECTIVE_PERMISSIONS, "somePermissions"); - verify(adapter, never()).param(PermissionResourceParameter.EFFECTIVE_PERMISSIONS, "wrongPermissions"); - } - - @Test(testName = "get") - @SuppressWarnings("unchecked") - public void should_return_proper_op_result() throws IllegalAccessException { - - // Given - mockStatic(JerseyRequest.class); - when(JerseyRequest.buildRequest(sessionStorageMock, - RepositoryPermissionListWrapper.class, - new String[]{"permissions", fakeUri})).thenReturn(requestMock); - when(requestMock.get()).thenReturn(expectedResultMock); - - // When - PermissionResourceRequestAdapter adapter = new PermissionResourceRequestAdapter(sessionStorageMock, fakeUri); - OperationResult retrieved = adapter.get(); - - // Retrieving params field - Field field = field(PermissionResourceRequestAdapter.class, "params"); - MultivaluedMap paramsField = (MultivaluedMap) field.get(adapter); - - // Then - verify(requestMock, times(1)).get(); - verify(requestMock, times(1)).addParams(paramsField); - verify(requestMock, never()).delete(); - verifyNoMoreInteractions(requestMock); // IMPORTANT: must be only two corresponding invocations and - // no more on this Request object. - assertSame(retrieved, expectedResultMock); - } - - @Test(testName = "delete") - public void should_delete_permission_and_return_op_result() { - - // Given - mockStatic(JerseyRequest.class); - when(JerseyRequest.buildRequest(sessionStorageMock, - RepositoryPermissionListWrapper.class, - new String[]{"permissions", fakeUri})).thenReturn(requestMock); - when(requestMock.delete()).thenReturn(expectedResultMock); - - // When - PermissionResourceRequestAdapter adapter = new PermissionResourceRequestAdapter(sessionStorageMock, fakeUri); - OperationResult retrieved = adapter.delete(); // why isn't generified? what comes as a result? - - // Then - // Verify that static print is called with the specified parameter. - verifyStatic(times(1)); - JerseyRequest.buildRequest(eq(sessionStorageMock), - eq(RepositoryPermissionListWrapper.class), - eq(new String[]{"permissions", fakeUri})); - - // Verify that instance print is called only once - verify(requestMock, times(1)).delete(); - assertSame(retrieved, expectedResultMock); - } - - - @Test - public void should_retrieve_resource_asynchronously() throws InterruptedException { - - /* Given */ - PowerMockito.mockStatic(JerseyRequest.class); - PowerMockito.when(buildRequest(eq(sessionStorageMock), - eq(RepositoryPermissionListWrapper.class), - eq(new String[]{"permissions", "resourceUri"}))).thenReturn(requestMock); - PowerMockito.doReturn(expectedResultMock).when(requestMock).get(); - PermissionResourceRequestAdapter adapterSpy = PowerMockito.spy(new PermissionResourceRequestAdapter(sessionStorageMock, fakeUri)); - - final AtomicInteger newThreadId = new AtomicInteger(); - final int currentThreadId = (int) Thread.currentThread().getId(); - - final Callback, Void> callback = PowerMockito.spy(new Callback, Void>() { - @Override - public Void execute(OperationResult data) { - newThreadId.set((int) Thread.currentThread().getId()); - synchronized (this) { - this.notify(); - } - return null; - } - }); - - PowerMockito.doReturn(null).when(callback).execute(expectedResultMock); - - /* When */ - RequestExecution retrieved = adapterSpy.asyncGet(callback); - - synchronized (callback) { - callback.wait(1000); - } - - /* Then */ - Mockito.verify(requestMock).get(); - Mockito.verify(callback).execute(expectedResultMock); - Assert.assertNotNull(retrieved); - Assert.assertNotSame(currentThreadId, newThreadId.get()); - } - - @Test - public void should_delete_resource_asynchronously() throws InterruptedException { - - /* Given */ - PowerMockito.mockStatic(JerseyRequest.class); - PowerMockito.when(buildRequest(eq(sessionStorageMock), - eq(RepositoryPermissionListWrapper.class), - eq(new String[]{"permissions", "resourceUri"}))).thenReturn(requestMock); - PowerMockito.doReturn(expectedResultMock).when(requestMock).delete(); - PermissionResourceRequestAdapter adapterSpy = PowerMockito.spy(new PermissionResourceRequestAdapter(sessionStorageMock, fakeUri)); - - final AtomicInteger newThreadId = new AtomicInteger(); - final int currentThreadId = (int) Thread.currentThread().getId(); - - final Callback, Void> callback = PowerMockito.spy(new Callback, Void>() { - @Override - public Void execute(OperationResult data) { - newThreadId.set((int) Thread.currentThread().getId()); - synchronized (this) { - this.notify(); - } - return null; - } - }); - - PowerMockito.doReturn(null).when(callback).execute(expectedResultMock); - - /* When */ - RequestExecution retrieved = adapterSpy.asyncDelete(callback); - - synchronized (callback) { - callback.wait(1000); - } - - /* Then */ - Mockito.verify(requestMock).delete(); - Mockito.verify(callback).execute(expectedResultMock); - Assert.assertNotNull(retrieved); - Assert.assertNotSame(currentThreadId, newThreadId.get()); - } - - @Test - public void should_create_resource_asynchronously() throws InterruptedException { - - /* Given */ - PowerMockito.mockStatic(JerseyRequest.class); - PowerMockito.when(buildRequest(eq(sessionStorageMock), - eq(RepositoryPermissionListWrapper.class), - eq(new String[]{"permissions", "resourceUri"}))).thenReturn(requestMock); - PowerMockito.doReturn(expectedResultMock).when(requestMock).put(wrapperMock); - - PowerMockito.doReturn(configurationMock).when(sessionStorageMock).getConfiguration(); - PowerMockito.doReturn(MimeType.JSON).when(configurationMock).getContentMimeType(); - - PermissionResourceRequestAdapter adapterSpy = PowerMockito.spy(new PermissionResourceRequestAdapter(sessionStorageMock, fakeUri)); - - final AtomicInteger newThreadId = new AtomicInteger(); - final int currentThreadId = (int) Thread.currentThread().getId(); - - final Callback, Void> callback = PowerMockito.spy(new Callback, Void>() { - @Override - public Void execute(OperationResult data) { - newThreadId.set((int) Thread.currentThread().getId()); - synchronized (this) { - this.notify(); - } - return null; - } - }); - - PowerMockito.doReturn(null).when(callback).execute(expectedResultMock); - - /* When */ - RequestExecution retrieved = adapterSpy.asyncCreateOrUpdate(wrapperMock, callback); - - synchronized (callback) { - callback.wait(1000); - } - - /* Then */ - Assert.assertNotNull(retrieved); - Assert.assertNotSame(currentThreadId, newThreadId.get()); - - Mockito.verify(requestMock).put(wrapperMock); - Mockito.verify(callback).execute(expectedResultMock); - Mockito.verify(sessionStorageMock).getConfiguration(); - Mockito.verify(configurationMock).getContentMimeType(); - } - - @AfterMethod - public void after() { - Mockito.reset(sessionStorageMock, requestMock, wrapperMock, expectedResultMock, configurationMock); - } -} \ No newline at end of file diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/permissions/PermissionsServiceTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/permissions/PermissionsServiceTest.java deleted file mode 100644 index f37349d3..00000000 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/permissions/PermissionsServiceTest.java +++ /dev/null @@ -1,236 +0,0 @@ -package com.jaspersoft.jasperserver.jaxrs.client.apiadapters.permissions; - -import com.jaspersoft.jasperserver.dto.permissions.RepositoryPermission; -import com.jaspersoft.jasperserver.dto.permissions.RepositoryPermissionListWrapper; -import com.jaspersoft.jasperserver.jaxrs.client.core.Callback; -import com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest; -import com.jaspersoft.jasperserver.jaxrs.client.core.enums.MimeType; -import com.jaspersoft.jasperserver.jaxrs.client.core.RequestExecution; -import com.jaspersoft.jasperserver.jaxrs.client.core.RestClientConfiguration; -import com.jaspersoft.jasperserver.jaxrs.client.core.SessionStorage; -import com.jaspersoft.jasperserver.jaxrs.client.core.exceptions.handling.DefaultErrorHandler; -import com.jaspersoft.jasperserver.jaxrs.client.core.operationresult.OperationResult; -import org.mockito.InOrder; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.testng.PowerMockTestCase; -import org.testng.Assert; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import java.lang.reflect.Field; -import java.util.concurrent.atomic.AtomicInteger; - -import static com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest.buildRequest; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.reset; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import static org.mockito.MockitoAnnotations.initMocks; -import static org.powermock.api.mockito.PowerMockito.mock; -import static org.powermock.api.mockito.PowerMockito.mockStatic; -import static org.powermock.api.mockito.PowerMockito.spy; -import static org.powermock.api.mockito.PowerMockito.verifyStatic; -import static org.powermock.api.support.membermodification.MemberMatcher.field; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertSame; - -/** - * Unit tests for {@link PermissionsService} - */ -@PrepareForTest({JerseyRequest.class}) -public class PermissionsServiceTest extends PowerMockTestCase { - - @Mock - private SessionStorage sessionStorageMock; - - @Mock - private JerseyRequest requestMock; - - @Mock - private RepositoryPermission permissionMock; - - @Mock - private OperationResult resultMock; - - @Mock - private RestClientConfiguration configurationMock; - - @Mock - private RepositoryPermissionListWrapper wrapperMock; - - private String fakeUri = "uri"; - - @BeforeMethod - public void after() { - initMocks(this); - } - - @Test(testName = "resource") - public void should_return_proper_adapter() throws IllegalAccessException { - - // Given - PermissionsService service = new PermissionsService(sessionStorageMock); - - // When - PermissionResourceRequestAdapter adapter = service.resource(fakeUri); - SessionStorage retrieved = adapter.getSessionStorage(); - - Field field = field(PermissionResourceRequestAdapter.class, "resourceUri"); - String resourceUri = (String) field.get(adapter); - - // Then - assertSame(retrieved, sessionStorageMock); - assertEquals(resourceUri, fakeUri); - } - - @Test(testName = "resource", expectedExceptions = IllegalArgumentException.class) - public void should_throw_an_exception_when_invalid_param_has_been_passed() throws IllegalAccessException { - - // When - PermissionsService service = new PermissionsService(sessionStorageMock); - - // Then - service.resource(""); - } - - @Test(testName = "createNew_with_RepositoryPermission_param") - @SuppressWarnings("unchecked") - public void should_create_new_permission() { - - // Given - mockStatic(JerseyRequest.class); - when(JerseyRequest.buildRequest(eq(sessionStorageMock), eq(Object.class), eq(new String[]{"/permissions"}), any(DefaultErrorHandler.class))).thenReturn(requestMock); - when(requestMock.post(permissionMock)).thenReturn(resultMock); - - // When - PermissionsService service = new PermissionsService(sessionStorageMock); - OperationResult retrieved = service.createNew(permissionMock); - - // Then - verifyStatic(times(1)); - JerseyRequest.buildRequest(eq(sessionStorageMock), eq(Object.class), eq(new String[]{"/permissions"}), any(DefaultErrorHandler.class)); - - assertSame(retrieved, resultMock); - verify(requestMock, times(1)).post(permissionMock); - } - - @Test(testName = "createNew_with_list_of_wrapped_RepositoryPermission") - public void should_persist_list_of_permissions() { - - // Given - mockStatic(JerseyRequest.class); - when(JerseyRequest.buildRequest(eq(sessionStorageMock), eq(Object.class), eq(new String[]{"/permissions"}))).thenReturn(requestMock); - when(sessionStorageMock.getConfiguration()).thenReturn(configurationMock); - when(configurationMock.getContentMimeType()).thenReturn(MimeType.JSON); - doReturn(resultMock).when(requestMock).post(wrapperMock); - - // When - PermissionsService service = new PermissionsService(sessionStorageMock); - OperationResult retrieved = service.createNew(wrapperMock); - - // Then - verifyStatic(times(1)); - JerseyRequest.buildRequest(eq(sessionStorageMock), eq(Object.class), eq(new String[]{"/permissions"})); - verify(requestMock, times(1)).setContentType("application/collection+json"); - verify(requestMock, times(1)).post(wrapperMock); - assertSame(retrieved, resultMock); - } - - @Test - public void should_create_new_permission_in_separate_thread() throws InterruptedException { - - /* Given */ - RepositoryPermission permissionMock = mock(RepositoryPermission.class); - mockStatic(JerseyRequest.class); - PowerMockito.when(buildRequest(eq(sessionStorageMock), eq(Object.class), eq(new String[]{"/permissions"}))).thenReturn(requestMock); - PowerMockito.doReturn(resultMock).when(requestMock).post(permissionMock); - PermissionsService serviceSpy = spy(new PermissionsService(sessionStorageMock)); - - final AtomicInteger newThreadId = new AtomicInteger(); - final int currentThreadId = (int) Thread.currentThread().getId(); - - final Callback callback = spy(new Callback() { - @Override - public Void execute(OperationResult data) { - newThreadId.set((int) Thread.currentThread().getId()); - synchronized (this) { - this.notify(); - } - return null; - } - }); - - PowerMockito.doReturn(null).when(callback).execute(resultMock); - - /* When */ - RequestExecution retrieved = serviceSpy.asyncCreateNew(permissionMock, callback); - - synchronized (callback) { - callback.wait(1000); - } - - /* Then */ - verify(requestMock, times(1)).post(permissionMock); - verify(callback).execute(resultMock); - assertNotNull(retrieved); - Assert.assertNotSame(currentThreadId, newThreadId.get()); - } - - @Test - public void should_create_new_list_of_permission_in_separate_thread() throws InterruptedException { - - /* Given */ - RepositoryPermissionListWrapper permissionListWrapperMock = mock(RepositoryPermissionListWrapper.class); - mockStatic(JerseyRequest.class); - PowerMockito.when(buildRequest(eq(sessionStorageMock), eq(Object.class), eq(new String[]{"/permissions"}))).thenReturn(requestMock); - PowerMockito.doReturn(resultMock).when(requestMock).post(permissionListWrapperMock); - PowerMockito.doReturn(configurationMock).when(sessionStorageMock).getConfiguration(); - PermissionsService serviceSpy = spy(new PermissionsService(sessionStorageMock)); - - InOrder inOrder = Mockito.inOrder(requestMock); - - final AtomicInteger newThreadId = new AtomicInteger(); - final int currentThreadId = (int) Thread.currentThread().getId(); - - final Callback callback = spy(new Callback() { - @Override - public Void execute(OperationResult data) { - newThreadId.set((int) Thread.currentThread().getId()); - synchronized (this) { - this.notify(); - } - return null; - } - }); - - PowerMockito.doReturn(null).when(callback).execute(resultMock); - - /* When */ - RequestExecution retrieved = serviceSpy.asyncCreateNew(permissionListWrapperMock, callback); - - synchronized (callback) { - callback.wait(1000); - } - - /* Then */ - inOrder.verify(requestMock, times(1)).setContentType("application/collection+xml"); - inOrder.verify(requestMock, times(1)).post(permissionListWrapperMock); - - verify(callback).execute(resultMock); - assertNotNull(retrieved); - Assert.assertNotSame(currentThreadId, newThreadId.get()); - } - - @AfterMethod - public void before() { - reset(sessionStorageMock, wrapperMock, requestMock); - } -} \ No newline at end of file diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/permissions/SinglePermissionRecipientRequestAdapterTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/permissions/SinglePermissionRecipientRequestAdapterTest.java deleted file mode 100644 index 0ec6d6d5..00000000 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/permissions/SinglePermissionRecipientRequestAdapterTest.java +++ /dev/null @@ -1,284 +0,0 @@ -package com.jaspersoft.jasperserver.jaxrs.client.apiadapters.permissions; - -import com.jaspersoft.jasperserver.dto.permissions.RepositoryPermission; -import com.jaspersoft.jasperserver.jaxrs.client.core.Callback; -import com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest; -import com.jaspersoft.jasperserver.jaxrs.client.core.RequestExecution; -import com.jaspersoft.jasperserver.jaxrs.client.core.SessionStorage; -import com.jaspersoft.jasperserver.jaxrs.client.core.operationresult.OperationResult; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.testng.PowerMockTestCase; -import org.testng.Assert; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import java.util.concurrent.atomic.AtomicInteger; - -import static org.mockito.Matchers.anyString; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.reset; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.MockitoAnnotations.initMocks; -import static org.powermock.api.mockito.PowerMockito.doReturn; -import static org.powermock.api.mockito.PowerMockito.mockStatic; -import static org.powermock.api.mockito.PowerMockito.spy; -import static org.powermock.api.mockito.PowerMockito.verifyPrivate; -import static org.powermock.api.mockito.PowerMockito.verifyStatic; -import static org.powermock.api.mockito.PowerMockito.when; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertSame; - -/** -* Unit tests for {@link SinglePermissionRecipientRequestAdapter} -*/ -@PrepareForTest({SinglePermissionRecipientRequestAdapter.class, JerseyRequest.class}) -public class SinglePermissionRecipientRequestAdapterTest extends PowerMockTestCase { - - @Mock - private SessionStorage storageMock; - - @Mock - private JerseyRequest requestMock; - - @Mock - private OperationResult resultMock; - - @Mock - private RepositoryPermission permissionMock; - - - @BeforeMethod - public void after() { - initMocks(this); - } - - @Test - public void should_return_a_proper_op_result_with_repo_permission() throws Exception { - - // Given - SinglePermissionRecipientRequestAdapter adapterSpy = spy(new SinglePermissionRecipientRequestAdapter(storageMock, "resourceUri", "recipient")); - doReturn(requestMock).when(adapterSpy, "getBuilder", RepositoryPermission.class); - doReturn(resultMock).when(requestMock).get(); - - // When - OperationResult retrieved = adapterSpy.get(); - - // Then - verifyPrivate(adapterSpy, times(1)).invoke("getBuilder", eq(RepositoryPermission.class)); - verify(requestMock, times(1)).get(); - assertNotNull(retrieved); - } - - @Test - public void should_create_or_update_RepositoryPermission_and_return_result_of_operation() throws Exception { - - // Given - SinglePermissionRecipientRequestAdapter adapterSpy = spy(new SinglePermissionRecipientRequestAdapter(storageMock, "resourceUri", "recipient")); - doReturn(requestMock).when(adapterSpy, "getBuilder", RepositoryPermission.class); - doReturn(resultMock).when(requestMock).put(permissionMock); - - // When - OperationResult retrieved = adapterSpy.createOrUpdate(permissionMock); - - // Then - verifyPrivate(adapterSpy, times(1)).invoke("getBuilder", eq(RepositoryPermission.class)); - verify(requestMock, times(1)).put(permissionMock); - assertNotNull(retrieved); - assertSame(retrieved, resultMock); - } - - @Test - public void should_delete_RepositoryPermission_and_return_result() throws Exception { - - // Given - OperationResult opResultMock = PowerMockito.mock(OperationResult.class); - SinglePermissionRecipientRequestAdapter adapterSpy = spy(new SinglePermissionRecipientRequestAdapter(storageMock, "resourceUri", "recipient")); - doReturn(requestMock).when(adapterSpy, "getBuilder", Object.class); - doReturn(opResultMock).when(requestMock).delete(); - - // When - OperationResult retrieved = adapterSpy.delete(); - - // Then - verifyPrivate(adapterSpy, times(1)).invoke("getBuilder", eq(Object.class)); - verify(requestMock, times(1)).delete(); - assertNotNull(retrieved); - assertSame(retrieved, opResultMock); - } - - @Test - public void should_invoke_private_method_only_once() throws Exception { - - // Given - mockStatic(JerseyRequest.class); - when(JerseyRequest.buildRequest(eq(storageMock), - eq(RepositoryPermission.class), - eq(new String[]{"permissions", "resourceUri"}))).thenReturn(requestMock); - when(requestMock.get()).thenReturn(resultMock); - SinglePermissionRecipientRequestAdapter spy = spy(new SinglePermissionRecipientRequestAdapter(storageMock, "resourceUri", "recipient")); - - // When - OperationResult retrieved = spy.get(); - - // Then - verifyStatic(times(1)); - JerseyRequest.buildRequest(eq(storageMock), eq(RepositoryPermission.class), eq(new String[]{"permissions", "resourceUri"})); - - // Verify that private print is called only once. - verifyPrivate(spy, times(1)).invoke("getBuilder", RepositoryPermission.class); - - // Verify that addMatrixParam print is called with the specified parameters. - verify(requestMock).addMatrixParam(eq("recipient"), eq("recipient")); - - assertSame(retrieved, resultMock); - } - - @Test(expectedExceptions = IllegalArgumentException.class) - public void should_throw_NPE_exception_when_session_is_null() throws Exception { - - // Given - final SessionStorage NULL_STORAGE = null; - SinglePermissionRecipientRequestAdapter spy = spy(new SinglePermissionRecipientRequestAdapter(NULL_STORAGE, "resourceUri", "recipient")); - - // When - spy.get(); - - // Then expect NPE - } - - @Test - public void should_retrieve_permission_asynchronously() throws InterruptedException { - - /* Given */ - PowerMockito.mockStatic(JerseyRequest.class); - PowerMockito.when(JerseyRequest.buildRequest(eq(storageMock), - eq(RepositoryPermission.class), - eq(new String[]{"permissions", "resourceUri"}))).thenReturn(requestMock); - PowerMockito.doReturn(resultMock).when(requestMock).get(); - SinglePermissionRecipientRequestAdapter adapterSpy = PowerMockito.spy(new SinglePermissionRecipientRequestAdapter(storageMock, "resourceUri", "recipient")); - - final AtomicInteger newThreadId = new AtomicInteger(); - final int currentThreadId = (int) Thread.currentThread().getId(); - - final Callback, Void> callback = PowerMockito.spy(new Callback, Void>() { - @Override - public Void execute(OperationResult data) { - newThreadId.set((int) Thread.currentThread().getId()); - synchronized (this) { - this.notify(); - } - return null; - } - }); - - PowerMockito.doReturn(null).when(callback).execute(resultMock); - - /* When */ - RequestExecution retrieved = adapterSpy.asyncGet(callback); - - synchronized (callback) { - callback.wait(1000); - } - - /* Then */ - Mockito.verify(requestMock).get(); - Mockito.verify(callback).execute(resultMock); - Assert.assertNotNull(retrieved); - Assert.assertNotSame(currentThreadId, newThreadId.get()); - } - - @Test - public void should_delete_permission_asynchronously() throws InterruptedException { - - /* Given */ - JerseyRequest requestMock = (JerseyRequest) PowerMockito.mock(JerseyRequest.class); - PowerMockito.mockStatic(JerseyRequest.class); - PowerMockito.when(JerseyRequest.buildRequest(eq(storageMock), - eq(Object.class), - eq(new String[]{"permissions", "resourceUri"}))).thenReturn(requestMock); - PowerMockito.doReturn(resultMock).when(requestMock).delete(); - SinglePermissionRecipientRequestAdapter adapterSpy = PowerMockito.spy(new SinglePermissionRecipientRequestAdapter(storageMock, "resourceUri", "recipient")); - - final AtomicInteger newThreadId = new AtomicInteger(); - final int currentThreadId = (int) Thread.currentThread().getId(); - - final Callback callback = PowerMockito.spy(new Callback() { - @Override - public Void execute(OperationResult data) { - newThreadId.set((int) Thread.currentThread().getId()); - synchronized (this) { - this.notify(); - } - return null; - } - }); - - PowerMockito.doReturn(null).when(callback).execute(resultMock); - - /* When */ - RequestExecution retrieved = adapterSpy.asyncDelete(callback); - - synchronized (callback) { - callback.wait(1000); - } - - /* Then */ - Mockito.verify(requestMock).delete(); - Mockito.verify(callback).execute(resultMock); - Assert.assertNotNull(retrieved); - Assert.assertNotSame(currentThreadId, newThreadId.get()); - } - - @Test - public void should_create_resource_asynchronously() throws InterruptedException { - - PowerMockito.mockStatic(JerseyRequest.class); - PowerMockito.when(JerseyRequest.buildRequest(eq(storageMock), - eq(RepositoryPermission.class), - eq(new String[]{"permissions", "resourceUri"}))).thenReturn(requestMock); - PowerMockito.doReturn(resultMock).when(requestMock).put(permissionMock); - - SinglePermissionRecipientRequestAdapter adapterSpy = PowerMockito.spy(new SinglePermissionRecipientRequestAdapter(storageMock, "resourceUri", "recipient")); - final AtomicInteger newThreadId = new AtomicInteger(); - final int currentThreadId = (int) Thread.currentThread().getId(); - - final Callback, Void> callback = PowerMockito.spy(new Callback, Void>() { - @Override - public Void execute(OperationResult data) { - newThreadId.set((int) Thread.currentThread().getId()); - synchronized (this) { - this.notify(); - } - return null; - } - }); - - PowerMockito.doReturn(null).when(callback).execute(resultMock); - - /* When */ - RequestExecution retrieved = adapterSpy.asyncCreateOrUpdate(permissionMock, callback); - - /* Wait */ - synchronized (callback) { - callback.wait(1000); - } - - /* Then */ - Assert.assertNotNull(retrieved); - Assert.assertNotSame(currentThreadId, newThreadId.get()); - - Mockito.verify(requestMock).put(permissionMock); - Mockito.verify(requestMock).addMatrixParam(anyString(), anyString()); - Mockito.verify(callback).execute(resultMock); - } - - @AfterMethod - public void before() { - reset(requestMock, resultMock, storageMock, permissionMock); - } -} \ No newline at end of file diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/query/QueryExecutorAdapterTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/query/QueryExecutorAdapterTest.java index b13d8674..68c14241 100644 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/query/QueryExecutorAdapterTest.java +++ b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/query/QueryExecutorAdapterTest.java @@ -13,7 +13,7 @@ import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.reset; import static org.mockito.MockitoAnnotations.initMocks; diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/AttachmentTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/AttachmentTest.java deleted file mode 100644 index e0529482..00000000 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/AttachmentTest.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting; - -import com.jaspersoft.jasperserver.jaxrs.client.dto.reports.Attachment; -import org.testng.annotations.Test; - -import static org.testng.Assert.assertSame; - -public class AttachmentTest { - - @Test - /** - * for whole bunch of setters/getters - */ - public void should_set_fields_and_get_proper_values() { - - /* Given */ - - byte[] dummyContent = new byte[]{1, 2, 3}; - Attachment attachment = new Attachment(); - - /* When */ - attachment.setContent(dummyContent); - attachment.setMimeType("someType"); - attachment.setName("name"); - - /* Then */ - assertSame(attachment.getContent(), dummyContent); - assertSame(attachment.getMimeType(), "someType"); - assertSame(attachment.getName(), "name"); - } -} \ No newline at end of file diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/ExportExecutionRequestBuilderTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/ExportExecutionRequestBuilderTest.java deleted file mode 100644 index e738f1df..00000000 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/ExportExecutionRequestBuilderTest.java +++ /dev/null @@ -1,465 +0,0 @@ -package com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting; - -import com.jaspersoft.jasperserver.jaxrs.client.core.Callback; -import com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest; -import com.jaspersoft.jasperserver.jaxrs.client.core.RequestExecution; -import com.jaspersoft.jasperserver.jaxrs.client.core.SessionStorage; -import com.jaspersoft.jasperserver.jaxrs.client.core.exceptions.JSClientException; -import com.jaspersoft.jasperserver.jaxrs.client.core.operationresult.OperationResult; -import com.jaspersoft.jasperserver.jaxrs.client.dto.reports.AttachmentDescriptor; -import com.jaspersoft.jasperserver.jaxrs.client.dto.reports.ExportDescriptor; -import com.jaspersoft.jasperserver.jaxrs.client.dto.reports.HtmlReport; -import com.jaspersoft.jasperserver.jaxrs.client.dto.reports.ReportExecutionStatusEntity; -import org.apache.commons.io.IOUtils; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.testng.PowerMockTestCase; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.concurrent.atomic.AtomicInteger; - -import static com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest.buildRequest; -import static org.hamcrest.core.IsInstanceOf.instanceOf; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyString; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.reset; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.MockitoAnnotations.initMocks; -import static org.powermock.api.mockito.PowerMockito.doReturn; -import static org.powermock.api.mockito.PowerMockito.mockStatic; -import static org.powermock.api.mockito.PowerMockito.spy; -import static org.powermock.api.mockito.PowerMockito.verifyStatic; -import static org.powermock.api.mockito.PowerMockito.when; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNotSame; -import static org.testng.Assert.assertSame; -import static org.testng.Assert.assertTrue; - -/** -* Unit tests for {@link ExportExecutionRequestBuilder} -*/ -@PrepareForTest({JerseyRequest.class, IOUtils.class, ExportExecutionRequestBuilder.class}) -public class ExportExecutionRequestBuilderTest extends PowerMockTestCase { - - @Mock - private SessionStorage sessionStorageMock; - - @Mock - private ExportDescriptor descriptorMock; - - @Mock - private JerseyRequest stringJerseyRequestMock; - - @Mock - private JerseyRequest streamJerseyRequestMock; - - @Mock - private OperationResult resultMock; - - @Mock - private OperationResult streamedResultMock; - - @Mock - private JerseyRequest entityJerseyRequestMock; - - @Mock - private OperationResult statusEntityOperationResultMock; - - @Mock - private InputStream streamMock; - - @Mock - private ReportExecutionStatusEntity statusEntityMock; - - @Mock - private HtmlReport reportMock; - - @BeforeMethod - public void before() { - initMocks(this); - } - - @Test (enabled = false) - public void should_return_HtmlReport_instance_if_ExportDescriptor_is_a_proper_val() throws Exception { - - /* Given */ - String exportId = "exportId"; - String requestId = "requestId"; - - final AttachmentDescriptor desc = spy(new AttachmentDescriptor()); - desc.setContentType("json"); - desc.setFileName("myFile"); - - mockStatic(JerseyRequest.class); - when(buildRequest(sessionStorageMock, String.class, new String[]{"/reportExecutions", requestId, "/exports", exportId, "/outputResource"})).thenReturn(stringJerseyRequestMock); - - doReturn(resultMock).when(stringJerseyRequestMock).get(); - doReturn("entity").when(resultMock).getEntity(); - - doReturn(new ArrayList() {{ - add(desc); - }}).when(descriptorMock).getAttachments(); - - ExportExecutionRequestBuilder builderSpy = spy(new ExportExecutionRequestBuilder(sessionStorageMock, requestId, exportId)); - doReturn(statusEntityOperationResultMock).when(builderSpy).attachment(anyString()); - doReturn(streamMock).when(statusEntityOperationResultMock).getEntity(); - - mockStatic(IOUtils.class); - when(IOUtils.toByteArray(streamMock)).thenReturn(new byte[]{}); - - - /* When */ - HtmlReport retrieved = builderSpy.htmlReport(descriptorMock); - - - /* Then */ - assertNotNull(retrieved); - - verifyStatic(times(1)); - buildRequest(sessionStorageMock, String.class, new String[]{"/reportExecutions", requestId, "/exports", exportId, "/outputResource"}); - - verifyStatic(times(1)); - IOUtils.toByteArray(streamMock); - - verify(stringJerseyRequestMock, times(1)).get(); - verify(resultMock, times(1)).getEntity(); - verify(descriptorMock, times(1)).getAttachments(); - verify(desc, times(2)).getFileName(); - verify(builderSpy, times(1)).attachment(anyString()); - } - - @Test - public void should_retrieve_attachment_asynchronously() throws InterruptedException { - - /** Given **/ - String requestId = "requestId"; - String exportId = "exportId"; - String attachmentId = "attachmentId"; - - final AtomicInteger newThreadId = new AtomicInteger(); - final int currentThreadId = (int) Thread.currentThread().getId(); - - ExportExecutionRequestBuilder builderSpy = Mockito.spy(new ExportExecutionRequestBuilder(sessionStorageMock, requestId, exportId)); - - mockStatic(JerseyRequest.class); - Mockito.when(buildRequest(eq(sessionStorageMock), - eq(InputStream.class), - eq(new String[]{"reportExecutions", requestId, "exports", exportId, "attachments", attachmentId}))).thenReturn(streamJerseyRequestMock); - Mockito.when(buildRequest(eq(sessionStorageMock), - eq(ReportExecutionStatusEntity.class), - eq(new String[]{"reportExecutions", requestId, "exports", exportId, "status"}))).thenReturn(entityJerseyRequestMock); - - Mockito.doReturn(statusEntityOperationResultMock).when(entityJerseyRequestMock).get(); - Mockito.doReturn(streamedResultMock).when(streamJerseyRequestMock).get(); - Mockito.doReturn(statusEntityMock).when(statusEntityOperationResultMock).getEntity(); - Mockito.doReturn("execution").doReturn("ready").when(statusEntityMock).getValue(); - - final Callback, Void> callback = Mockito.spy(new Callback, Void>() { - @Override - public Void execute(OperationResult data) { - newThreadId.set((int) Thread.currentThread().getId()); - synchronized (this) { - this.notify(); - } - return null; - } - }); - - - /** When **/ - RequestExecution retrieved = builderSpy.asyncAttachment(attachmentId, callback); - - - /** Wait **/ - synchronized (callback) { - callback.wait(1000); - } - - - /** Then **/ - assertNotNull(retrieved); - assertNotSame(currentThreadId, newThreadId.get()); - - verify(streamJerseyRequestMock, times(1)).get(); - verify(entityJerseyRequestMock, times(2)).get(); - verify(statusEntityOperationResultMock, times(2)).getEntity(); - verify(statusEntityMock, times(2)).getValue(); - verify(callback).execute(streamedResultMock); - } - - @Test(expectedExceptions = IllegalArgumentException.class) - public void should_throw_exception_when_invalid_attachmentId() { - - String requestId = "requestId"; - String exportId = "exportId"; - - ExportExecutionRequestBuilder builderSpy = spy(new ExportExecutionRequestBuilder(sessionStorageMock, requestId, exportId)); - builderSpy.asyncAttachment("", new Callback, Object>() { - @Override - public Object execute(OperationResult data) { - return null; - } - }); - } - - @Test - public void should_retrieve_output_resource_asynchronously() throws InterruptedException { - - /** Given **/ - String requestId = "requestId"; - String exportId = "exportId"; - - final AtomicInteger newThreadId = new AtomicInteger(); - final int currentThreadId = (int) Thread.currentThread().getId(); - - ExportExecutionRequestBuilder builderSpy = spy(new ExportExecutionRequestBuilder(sessionStorageMock, requestId, exportId)); - - mockStatic(JerseyRequest.class); - when(buildRequest(eq(sessionStorageMock), - eq(InputStream.class), - eq(new String[]{"reportExecutions", requestId, "exports", exportId, "outputResource"}))).thenReturn(streamJerseyRequestMock); - - - doReturn(streamedResultMock).when(streamJerseyRequestMock).get(); - - final Callback, Void> callback = spy(new Callback, Void>() { - @Override - public Void execute(OperationResult data) { - newThreadId.set((int) Thread.currentThread().getId()); - synchronized (this) { - this.notify(); - } - return null; - } - }); - - /** When **/ - RequestExecution retrieved = builderSpy.asyncOutputResource(callback); - - /** Wait **/ - synchronized (callback) { - callback.wait(1000); - } - - /** Then **/ - assertNotNull(retrieved); - assertNotSame(currentThreadId, newThreadId.get()); - - verify(streamJerseyRequestMock, times(1)).get(); - verify(callback).execute(streamedResultMock); - } - - @Test - public void should_send_html_report_asynchronously() throws InterruptedException { - - /** Given **/ - String requestId = "requestId"; - String exportId = "exportId"; - - final AtomicInteger newThreadId = new AtomicInteger(); - final int currentThreadId = (int) Thread.currentThread().getId(); - - ExportExecutionRequestBuilder builderSpy = spy(new ExportExecutionRequestBuilder(sessionStorageMock, requestId, exportId)); - PowerMockito.doReturn(reportMock).when(builderSpy).htmlReport(any(ExportDescriptor.class)); - - final Callback callback = spy(new Callback() { - @Override - public Void execute(HtmlReport data) { - newThreadId.set((int) Thread.currentThread().getId()); - synchronized (this) { - this.notify(); - } - return null; - } - }); - - - /** When **/ - RequestExecution retrieved = builderSpy.asyncHtmlReport(new ExportDescriptor(), callback); - - - /** Wait **/ - synchronized (callback) { - callback.wait(1000); - } - - - /** Then **/ - assertNotNull(retrieved); - assertNotSame(currentThreadId, newThreadId.get()); - - Mockito.verify(callback).execute(reportMock); - Mockito.verify(builderSpy).htmlReport(any(ExportDescriptor.class)); - } - - @Test - public void should_return_operation_result() { - - /** Given **/ - String requestId = "requestId"; - String exportId = "exportId"; - - mockStatic(JerseyRequest.class); - when(buildRequest(eq(sessionStorageMock), - eq(InputStream.class), - eq(new String[]{"reportExecutions", requestId, "exports", exportId, "outputResource"}))).thenReturn(streamJerseyRequestMock); - doReturn(streamedResultMock).when(streamJerseyRequestMock).get(); - - ExportExecutionRequestBuilder builderSpy = spy(new ExportExecutionRequestBuilder(sessionStorageMock, requestId, exportId)); - OperationResult retrieved = builderSpy.outputResource(); - - assertSame(retrieved, streamedResultMock); - verifyStatic(); - buildRequest(eq(sessionStorageMock), - eq(InputStream.class), - eq(new String[]{"reportExecutions", requestId, "exports", exportId, "outputResource"})); - } - - - @Test - public void should_retrieve_status_entity_asynchronously() throws InterruptedException { - - /** Given **/ - String requestId = "requestId"; - String exportId = "exportId"; - - final AtomicInteger newThreadId = new AtomicInteger(); - final int currentThreadId = (int) Thread.currentThread().getId(); - - ExportExecutionRequestBuilder builderSpy = spy(new ExportExecutionRequestBuilder(sessionStorageMock, requestId, exportId)); - - mockStatic(JerseyRequest.class); - when(buildRequest(eq(sessionStorageMock), - eq(ReportExecutionStatusEntity.class), - eq(new String[]{"reportExecutions", requestId, "exports", exportId, "status"}))).thenReturn(entityJerseyRequestMock); - doReturn(statusEntityOperationResultMock).when(entityJerseyRequestMock).get(); - - final Callback, Void> callback = spy(new Callback, Void>() { - @Override - public Void execute(OperationResult data) { - newThreadId.set((int) Thread.currentThread().getId()); - synchronized (this) { - this.notify(); - } - return null; - } - }); - - - /** When **/ - RequestExecution retrieved = builderSpy.asyncStatus(callback); - - - /** Wait **/ - synchronized (callback) { - callback.wait(1000); - } - - - /** Then **/ - assertNotNull(retrieved); - assertNotSame(currentThreadId, newThreadId.get()); - - verify(entityJerseyRequestMock, times(1)).get(); - verify(callback).execute(statusEntityOperationResultMock); - - } - - @Test - public void should_get_attachment_as_stream() { - - /** Given **/ - String requestId = "requestId"; - String exportId = "exportId"; - String attachmentId = "attachmentId"; - - mockStatic(JerseyRequest.class); - when(buildRequest(eq(sessionStorageMock), - eq(InputStream.class), - eq(new String[]{"reportExecutions", requestId, "exports", exportId, "attachments", attachmentId}))).thenReturn(streamJerseyRequestMock); - PowerMockito.doReturn(streamedResultMock).when(streamJerseyRequestMock).get(); - - ExportExecutionRequestBuilder builderSpy = spy(new ExportExecutionRequestBuilder(sessionStorageMock, requestId, exportId)); - - PowerMockito.doReturn(statusEntityOperationResultMock).when(builderSpy).status(); - PowerMockito.doReturn(statusEntityMock).when(statusEntityOperationResultMock).getEntity(); - PowerMockito.doReturn("execution").doReturn("ready").when(statusEntityMock).getValue(); - // - /** When **/ - OperationResult retrieved = builderSpy.attachment(attachmentId); - - /** Then **/ - verifyStatic(); - buildRequest(eq(sessionStorageMock), - eq(InputStream.class), - eq(new String[]{"reportExecutions", requestId, "exports", exportId, "attachments", attachmentId})); - - assertNotNull(retrieved); - Mockito.verify(builderSpy, times(2)).status(); - Mockito.verify(streamJerseyRequestMock).get(); - Mockito.verify(statusEntityOperationResultMock, times(2)).getEntity(); - Mockito.verify(statusEntityMock, times(2)).getValue(); - } - - @Test(expectedExceptions = IllegalArgumentException.class) - public void should_throw_exception_when_invalid_id() { - - String requestId = "requestId"; - String exportId = "exportId"; - ExportExecutionRequestBuilder builderSpy = spy(new ExportExecutionRequestBuilder(sessionStorageMock, requestId, exportId)); - builderSpy.attachment("/"); - - } - - @Test - public void should_throw_exception_when_cannot_read_stream() throws FileNotFoundException { - - String requestId = "requestId"; - String exportId = "exportId"; - - mockStatic(JerseyRequest.class); - PowerMockito.when(buildRequest(eq(sessionStorageMock), - eq(String.class), - eq(new String[]{"reportExecutions", requestId, "exports", exportId, "outputResource"}))).thenReturn(stringJerseyRequestMock); - - PowerMockito.doReturn(resultMock).when(stringJerseyRequestMock).get(); - PowerMockito.doReturn("____").when(resultMock).getEntity(); - - ExportExecutionRequestBuilder builderSpy = spy(new ExportExecutionRequestBuilder(sessionStorageMock, requestId, exportId)); - - PowerMockito.doReturn(streamedResultMock).when(builderSpy).attachment(anyString()); - PowerMockito.doReturn(new InputStream() { - @Override - public int read() throws IOException { - throw new IOException(); - } - }).when(streamedResultMock).getEntity(); - - ExportDescriptor descriptor = new ExportDescriptor(); - descriptor.setAttachments(Arrays.asList(new AttachmentDescriptor())); - - try { - builderSpy.htmlReport(descriptor); - } catch (Exception e) { - assertTrue(instanceOf(JSClientException.class).matches(e)); - assertEquals(e.getMessage(), "Error while reading thumbnail content"); - } - } - - @AfterMethod - public void after() { - reset(sessionStorageMock, descriptorMock, stringJerseyRequestMock, resultMock, streamMock, statusEntityOperationResultMock); - } -} \ No newline at end of file diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/HtmlReportTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/HtmlReportTest.java deleted file mode 100644 index 5865c032..00000000 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/HtmlReportTest.java +++ /dev/null @@ -1,80 +0,0 @@ -package com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting; - -import com.jaspersoft.jasperserver.jaxrs.client.dto.reports.Attachment; -import com.jaspersoft.jasperserver.jaxrs.client.dto.reports.HtmlReport; -import org.testng.annotations.Test; - -import java.util.ArrayList; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; - -/** - * Unit tests for {@link com.jaspersoft.jasperserver.jaxrs.client.dto.reports.HtmlReport} - */ -public class HtmlReportTest { - - @Test - /** - * for {@link com.jaspersoft.jasperserver.jaxrs.client.dto.reports.HtmlReport#HtmlReport(String)} - */ - public void should_create_object_with_proper_params() { - - /* When */ - HtmlReport report = new HtmlReport("_id"); - - /* Then */ - assertNotNull(report.getAttachments()); - assertEquals(report.getId(), "_id"); - - } - - @Test - /** - * for getters and setters of {@link com.jaspersoft.jasperserver.jaxrs.client.dto.reports.HtmlReport} class - */ - public void should_set_fields_and_get_proper_values() { - - /* Given */ - HtmlReport report = new HtmlReport("id"); - - /* When */ - report.setAttachments(new ArrayList() {{ - add(new Attachment()); - add(new Attachment()); - add(new Attachment()); - }}); - report.setAttachmentsPrefix("fakePrefix"); - report.setHtml("fakeHtml"); - report.setId("newId"); - - /* Then */ - assertEquals(report.getHtml(), "fakeHtml"); - assertNotEquals(report.getId(), "id"); - assertEquals(report.getId(), "newId"); - assertEquals(report.getAttachmentsPrefix(), "fakePrefix"); - assertTrue(report.getAttachments().size() == 3); - } - - @Test - public void should_add_and_remove_only_one_element() { - - /* Given */ - Attachment attachment = new Attachment(); - HtmlReport report = new HtmlReport("id"); - report.setAttachments(new ArrayList()); - - // {Check 1} - assertTrue(report.getAttachments().isEmpty()); - - // {Check 2} - report.addAttachment(attachment); - assertTrue(report.getAttachments().size() == 1); - - // {Check 3} - report.removeAttachment(attachment); - assertTrue(report.getAttachments().isEmpty()); - } -} \ No newline at end of file diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/PageRangeTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/PageRangeTest.java deleted file mode 100644 index e1070c13..00000000 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/PageRangeTest.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting; - -import org.mockito.internal.util.reflection.Whitebox; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.testng.PowerMockTestCase; -import org.testng.annotations.Test; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertSame; -import static org.testng.Assert.assertTrue; - -@PrepareForTest(PageRange.class) -public class PageRangeTest extends PowerMockTestCase { - - @Test - public void should_set_fields_with_proper_params() throws Exception { - - /* Given */ - PageRange rangeSpy = PowerMockito.spy(new PageRange(10L, 20L)); - PowerMockito.whenNew(PageRange.class).withArguments(10L, 20L).thenReturn(rangeSpy); - - /* When */ - PageRange retrieved = new PageRange(10L, 20L); - - /* Then */ - long startIndex = (Long) Whitebox.getInternalState(retrieved, "startIndex"); - long endIndex = (Long) Whitebox.getInternalState(retrieved, "endIndex"); - - assertSame(retrieved, rangeSpy); - assertTrue(startIndex == 10L); - assertTrue(endIndex == 20L); - } - - @Test - public void should_return_proper_string_when_startIndex_is_diff_Then_endIndex() { - PageRange range = new PageRange(10L, 20L); - String retrieved = range.getRange(); - assertEquals(retrieved, "10-20"); - } - - @Test - public void should_return_proper_string_when_startIndex_is_the_same_as_endIndex() { - PageRange range = new PageRange(250L, 250L); - String retrieved = range.getRange(); - assertEquals(retrieved, "250"); - } -} \ No newline at end of file diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/ReportExecutionRequestBuilderTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/ReportExecutionRequestBuilderTest.java deleted file mode 100644 index c05b57f4..00000000 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/ReportExecutionRequestBuilderTest.java +++ /dev/null @@ -1,366 +0,0 @@ -package com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting; - -import com.jaspersoft.jasperserver.jaxrs.client.core.Callback; -import com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest; -import com.jaspersoft.jasperserver.jaxrs.client.core.RequestExecution; -import com.jaspersoft.jasperserver.jaxrs.client.core.SessionStorage; -import com.jaspersoft.jasperserver.jaxrs.client.core.operationresult.OperationResult; -import com.jaspersoft.jasperserver.jaxrs.client.dto.reports.ExportExecutionDescriptor; -import com.jaspersoft.jasperserver.jaxrs.client.dto.reports.ExportExecutionOptions; -import com.jaspersoft.jasperserver.jaxrs.client.dto.reports.ReportExecutionDescriptor; -import com.jaspersoft.jasperserver.jaxrs.client.dto.reports.ReportExecutionStatusEntity; -import org.mockito.ArgumentCaptor; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.internal.util.reflection.Whitebox; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.testng.PowerMockTestCase; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import java.util.concurrent.atomic.AtomicInteger; - -import static com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest.buildRequest; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.reset; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.MockitoAnnotations.initMocks; -import static org.powermock.api.mockito.PowerMockito.doReturn; -import static org.powermock.api.mockito.PowerMockito.mockStatic; -import static org.powermock.api.mockito.PowerMockito.spy; -import static org.powermock.api.mockito.PowerMockito.verifyStatic; -import static org.powermock.api.mockito.PowerMockito.when; -import static org.powermock.api.mockito.PowerMockito.whenNew; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNotSame; -import static org.testng.Assert.assertSame; - -/** - * Unit tests for {@link com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting.ReportExecutionRequestBuilder} - * - * @author Alexander Krasnyanskiy - */ -@PrepareForTest({JerseyRequest.class, ReportExecutionRequestBuilder.class, ReportExecutionStatusEntity.class}) -public class ReportExecutionRequestBuilderTest extends PowerMockTestCase { - - @Mock - private SessionStorage sessionStorageMock; - - @Mock - private ExportExecutionOptions optionsMock; - - @Mock - private ReportExecutionStatusEntity statusEntityMock; - - @Mock - private JerseyRequest requestMock; - - @Mock - private JerseyRequest reportExecutionDescriptorJerseyRequestMock; - - @Mock - private JerseyRequest exportExecutionDescriptorJerseyRequestMock; - - @Mock - private JerseyRequest reportExecutionStatusEntityJerseyRequestMock; - - @Mock - private OperationResult resultMock; - - @Mock - private OperationResult reportExecutionDescriptorOperationResultMock; - - @Mock - private OperationResult exportExecutionDescriptorOperationResultMock; - - @Mock - private OperationResult reportExecutionStatusEntityOperationResultMock; - - @BeforeMethod - public void before() { - initMocks(this); - } - - @Test - /** - * for {@link com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting.ReportExecutionRequestBuilder#asyncStatus(com.jaspersoft.jasperserver.jaxrs.client.core.Callback)} - */ - public void should_return_ReportExecution_instance_with_proper_Future() throws InterruptedException { - - /* Given */ - final AtomicInteger newThreadId = new AtomicInteger(); - int currentThreadId = (int) Thread.currentThread().getId(); - - mockStatic(JerseyRequest.class); - when(buildRequest(eq(sessionStorageMock), eq(ReportExecutionStatusEntity.class), eq(new String[]{"reportExecutions", "requestId", "status"}))).thenReturn(requestMock); - - ReportExecutionRequestBuilder builderSpy = PowerMockito.spy(new ReportExecutionRequestBuilder(sessionStorageMock, "requestId")); - - Callback, Void> callback = spy(new Callback, Void>() { - @Override - public Void execute(OperationResult data) { - newThreadId.set((int) Thread.currentThread().getId()); - synchronized (this) { - this.notify(); - } - return null; - } - }); - - doReturn(resultMock).when(requestMock).get(); - doReturn(null).when(callback).execute(resultMock); - - /* When */ - RequestExecution retrieved = builderSpy.asyncStatus(callback); - - /* Wait */ - synchronized (callback) { - callback.wait(1000); - } - - /* Then */ - assertNotNull(retrieved); - assertNotSame(currentThreadId, newThreadId.get()); - verify(callback, times(1)).execute(resultMock); - verify(requestMock, times(1)).get(); - - //verifyStatic(times(1)); - //buildRequest(eq(storageMock), eq(ReportExecutionStatusEntity.class), eq(new String[]{"/reportExecutions", "requestId", "/status"})); - } - - @Test - /** - * for {@link com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting.ReportExecutionRequestBuilder#asyncExecutionDetails(com.jaspersoft.jasperserver.jaxrs.client.core.Callback)} - */ - public void should_retrieve_proper_ReportExecutionDescriptor_in_separate_thread() throws InterruptedException { - - /* Given */ - final AtomicInteger newThreadId = new AtomicInteger(); - int currentThreadId = (int) Thread.currentThread().getId(); - - mockStatic(JerseyRequest.class); - when(buildRequest(eq(sessionStorageMock), eq(ReportExecutionDescriptor.class), eq(new String[]{"reportExecutions", "requestId"}))).thenReturn(reportExecutionDescriptorJerseyRequestMock); - - ReportExecutionRequestBuilder builderSpy = PowerMockito.spy(new ReportExecutionRequestBuilder(sessionStorageMock, "requestId")); - - Callback, Void> callback = spy(new Callback, Void>() { - @Override - public Void execute(OperationResult data) { - newThreadId.set((int) Thread.currentThread().getId()); - synchronized (this) { - this.notify(); - } - return null; - } - }); - - doReturn(reportExecutionDescriptorOperationResultMock).when(reportExecutionDescriptorJerseyRequestMock).get(); - doReturn(null).when(callback).execute(reportExecutionDescriptorOperationResultMock); - - /* When */ - RequestExecution retrieved = builderSpy.asyncExecutionDetails(callback); - - /* Wait */ - synchronized (callback) { - callback.wait(1000); - } - - /* Then */ - assertNotNull(retrieved); - assertNotSame(currentThreadId, newThreadId.get()); - verify(callback, times(1)).execute(reportExecutionDescriptorOperationResultMock); - verify(reportExecutionDescriptorJerseyRequestMock, times(1)).get(); - - // todo: please find out the way to verify invocation of static protectedMethod - //verifyStatic(times(1)); - //buildRequest(eq(storageMock), eq(ReportExecutionDescriptor.class), eq(new String[]{"/reportExecutions", "requestId"})); - } - - @Test - /** - * for {@link com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting.ReportExecutionRequestBuilder#asyncRunExport(com.jaspersoft.jasperserver.jaxrs.client.dto.reports.ExportExecutionOptions, com.jaspersoft.jasperserver.jaxrs.client.core.Callback)} - */ - public void should_send_ExportExecutionOptions_asynchronously_and_return_proper_RequestExecution_instance() throws InterruptedException { - - /* Given */ - final AtomicInteger newThreadId = new AtomicInteger(); - int currentThreadId = (int) Thread.currentThread().getId(); - - mockStatic(JerseyRequest.class); - when(buildRequest(eq(sessionStorageMock), eq(ExportExecutionDescriptor.class), eq(new String[]{"reportExecutions", "requestId", "exports"}))).thenReturn(exportExecutionDescriptorJerseyRequestMock); - - ReportExecutionRequestBuilder builderSpy = PowerMockito.spy(new ReportExecutionRequestBuilder(sessionStorageMock, "requestId")); - - Callback, Void> callback = spy(new Callback, Void>() { - @Override - public Void execute(OperationResult data) { - newThreadId.set((int) Thread.currentThread().getId()); - synchronized (this) { - this.notify(); - } - return null; - } - }); - - doReturn(exportExecutionDescriptorOperationResultMock).when(exportExecutionDescriptorJerseyRequestMock).post(optionsMock); - doReturn(null).when(callback).execute(exportExecutionDescriptorOperationResultMock); - - /* When */ - RequestExecution retrieved = builderSpy.asyncRunExport(optionsMock, callback); - - /* Wait */ - synchronized (callback) { - callback.wait(1000); - } - - /* Then */ - assertNotNull(retrieved); - assertNotSame(currentThreadId, newThreadId.get()); - verify(callback, times(1)).execute(exportExecutionDescriptorOperationResultMock); - verify(exportExecutionDescriptorJerseyRequestMock, times(1)).post(optionsMock); - } - - @Test - /** - * for {@link com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting.ReportExecutionRequestBuilder#asyncCancelExecution(com.jaspersoft.jasperserver.jaxrs.client.core.Callback)} - */ - public void should_cancel_execution_of_report_asynchronously() throws Exception { - - /* Given */ - final AtomicInteger newThreadId = new AtomicInteger(); - int currentThreadId = (int) Thread.currentThread().getId(); - - whenNew(ReportExecutionStatusEntity.class).withNoArguments().thenReturn(statusEntityMock); - - mockStatic(JerseyRequest.class); - when(buildRequest(eq(sessionStorageMock), - eq(ReportExecutionStatusEntity.class), - eq(new String[]{"reportExecutions", "requestId", "status"}))).thenReturn(reportExecutionStatusEntityJerseyRequestMock); - - ReportExecutionRequestBuilder builderSpy = PowerMockito.spy(new ReportExecutionRequestBuilder(sessionStorageMock, "requestId")); - Callback, Void> callback = spy(new Callback, Void>() { - @Override - public Void execute(OperationResult data) { - newThreadId.set((int) Thread.currentThread().getId()); - synchronized (this) { - this.notify(); - } - return null; - } - }); - - doReturn(reportExecutionStatusEntityOperationResultMock).when(reportExecutionStatusEntityJerseyRequestMock).put(statusEntityMock); - doReturn(null).when(callback).execute(reportExecutionStatusEntityOperationResultMock); - - /* When */ - RequestExecution retrieved = builderSpy.asyncCancelExecution(callback); - - /* Wait */ - synchronized (callback) { - callback.wait(1000); - } - - /* Then */ - assertNotNull(retrieved); - assertNotSame(currentThreadId, newThreadId.get()); - verify(callback, times(1)).execute(reportExecutionStatusEntityOperationResultMock); - verify(reportExecutionStatusEntityJerseyRequestMock, times(1)).put(statusEntityMock); - } - - @Test - public void should_return_operation_result_with_proper_entity() { - mockStatic(JerseyRequest.class); - when(buildRequest(eq(sessionStorageMock), - eq(ReportExecutionStatusEntity.class), - eq(new String[]{"reportExecutions", "requestId", "status"}))).thenReturn(reportExecutionStatusEntityJerseyRequestMock); - doReturn(reportExecutionStatusEntityOperationResultMock).when(reportExecutionStatusEntityJerseyRequestMock).get(); - ReportExecutionRequestBuilder builderSpy = PowerMockito.spy(new ReportExecutionRequestBuilder(sessionStorageMock, "requestId")); - - OperationResult retrieved = builderSpy.status(); - assertSame(retrieved, reportExecutionStatusEntityOperationResultMock); - } - - @Test - public void test_return_execution_details() { - mockStatic(JerseyRequest.class); - when(buildRequest(eq(sessionStorageMock), - eq(ReportExecutionDescriptor.class), - eq(new String[]{"reportExecutions", "requestId"}))).thenReturn(reportExecutionDescriptorJerseyRequestMock); - doReturn(reportExecutionDescriptorOperationResultMock).when(reportExecutionDescriptorJerseyRequestMock).get(); - ReportExecutionRequestBuilder builderSpy = PowerMockito.spy(new ReportExecutionRequestBuilder(sessionStorageMock, "requestId")); - - OperationResult retrieved = builderSpy.executionDetails(); - assertSame(retrieved, reportExecutionDescriptorOperationResultMock); - - } - - - @Test - public void test_cancel_execution() { - - ArgumentCaptor captor = ArgumentCaptor.forClass(ReportExecutionStatusEntity.class); - - mockStatic(JerseyRequest.class); - Mockito.when(buildRequest(eq(sessionStorageMock), - eq(ReportExecutionStatusEntity.class), - eq(new String[]{"reportExecutions", "requestId", "status"}))).thenReturn(reportExecutionStatusEntityJerseyRequestMock); - Mockito.doReturn(resultMock).when(reportExecutionStatusEntityJerseyRequestMock).put(any(ReportExecutionStatusEntity.class)); - - ReportExecutionRequestBuilder builder = new ReportExecutionRequestBuilder(sessionStorageMock, "requestId"); - - OperationResult retrieved = builder.cancelExecution(); - assertSame(retrieved, resultMock); - - verifyStatic(); - buildRequest(eq(sessionStorageMock), - eq(ReportExecutionStatusEntity.class), - eq(new String[]{"reportExecutions", "requestId", "status"})); - - verify(reportExecutionStatusEntityJerseyRequestMock).put(captor.capture()); - assertEquals(captor.getValue().getValue(), "cancelled"); - } - - @Test - public void test_run_export_and_return_descriptor() { - - mockStatic(JerseyRequest.class); - Mockito.when(buildRequest(eq(sessionStorageMock), - eq(ExportExecutionDescriptor.class), - eq(new String[]{"reportExecutions", "requestId", "exports"}))).thenReturn(exportExecutionDescriptorJerseyRequestMock); - Mockito.doReturn(resultMock).when(exportExecutionDescriptorJerseyRequestMock).post(optionsMock); - - ReportExecutionRequestBuilder builder = new ReportExecutionRequestBuilder(sessionStorageMock, "requestId"); - OperationResult retrieved = builder.runExport(optionsMock); - - verifyStatic(); - buildRequest(eq(sessionStorageMock), - eq(ExportExecutionDescriptor.class), - eq(new String[]{"reportExecutions", "requestId", "exports"})); - - assertNotNull(retrieved); - assertSame(retrieved, resultMock); - } - - @Test - public void should_set_export_id() { - - ReportExecutionRequestBuilder builder = new ReportExecutionRequestBuilder(sessionStorageMock, "requestId"); - ExportExecutionRequestBuilder retrieved = builder.export("_id"); - - assertNotNull(retrieved); - assertEquals(Whitebox.getInternalState(retrieved, "exportId"), "_id"); - } - - @AfterMethod - public void after() { - reset(sessionStorageMock, optionsMock, requestMock, reportExecutionDescriptorJerseyRequestMock, - exportExecutionDescriptorJerseyRequestMock, resultMock, reportExecutionDescriptorOperationResultMock, - exportExecutionDescriptorOperationResultMock, reportExecutionStatusEntityJerseyRequestMock, - reportExecutionStatusEntityOperationResultMock, statusEntityMock); - } -} \ No newline at end of file diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/ReportingServiceTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/ReportingServiceTest.java index 2c96b0ae..7f7a96f8 100644 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/ReportingServiceTest.java +++ b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/ReportingServiceTest.java @@ -1,13 +1,8 @@ package com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting; -import com.jaspersoft.jasperserver.jaxrs.client.core.Callback; import com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest; -import com.jaspersoft.jasperserver.jaxrs.client.core.RequestExecution; import com.jaspersoft.jasperserver.jaxrs.client.core.SessionStorage; -import com.jaspersoft.jasperserver.jaxrs.client.core.operationresult.OperationResult; -import com.jaspersoft.jasperserver.jaxrs.client.dto.reports.ReportExecutionDescriptor; import com.jaspersoft.jasperserver.jaxrs.client.dto.reports.ReportExecutionRequest; -import java.util.TimeZone; import org.mockito.Mock; import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PrepareForTest; @@ -16,25 +11,12 @@ import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import java.lang.String; -import java.util.concurrent.atomic.AtomicInteger; - -import static com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest.buildRequest; -import static org.mockito.Matchers.eq; import static org.mockito.Mockito.reset; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; import static org.mockito.MockitoAnnotations.initMocks; -import static org.powermock.api.mockito.PowerMockito.doReturn; import static org.powermock.api.mockito.PowerMockito.mock; -import static org.powermock.api.mockito.PowerMockito.mockStatic; -import static org.powermock.api.mockito.PowerMockito.spy; import static org.powermock.api.mockito.PowerMockito.verifyNew; -import static org.powermock.api.mockito.PowerMockito.verifyStatic; -import static org.powermock.api.mockito.PowerMockito.when; import static org.powermock.api.mockito.PowerMockito.whenNew; import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNotSame; import static org.testng.Assert.assertSame; /** @@ -46,157 +28,16 @@ public class ReportingServiceTest extends PowerMockTestCase { @Mock private SessionStorage sessionStorageMock; - @Mock - private JerseyRequest requestMock; - @Mock private ReportExecutionRequest executionRequestMock; - @Mock - private OperationResult resultMock; @BeforeMethod public void before() { initMocks(this); } - @Test - /** - * for {@link ReportingService#asyncNewReportExecutionRequest(ReportExecutionRequest, com.jaspersoft.jasperserver.jaxrs.client.core.Callback)} - */ - public void should_return_wrapped_ReportExecutionDescriptor() throws InterruptedException { - - // Given - final AtomicInteger newThreadId = new AtomicInteger(); - int currentThreadId = (int) Thread.currentThread().getId(); - - mockStatic(JerseyRequest.class); - when(buildRequest(eq(sessionStorageMock), - eq(ReportExecutionDescriptor.class), - eq(new String[]{"reportExecutions"}))).thenReturn(requestMock); - - ReportingService serviceSpy = PowerMockito.spy(new ReportingService(sessionStorageMock)); - Callback, Void> callback = spy(new Callback, Void>() { - @Override - public Void execute(OperationResult data) { - newThreadId.set((int) Thread.currentThread().getId()); - synchronized (this) { - this.notify(); - } - return null; - } - }); - - doReturn(resultMock).when(requestMock).post(executionRequestMock); - doReturn(null).when(callback).execute(resultMock); - - // When - RequestExecution retrieved = serviceSpy.asyncNewReportExecutionRequest(executionRequestMock, callback); - - // Wait - synchronized (callback) { - callback.wait(1000); - } - - // Then - assertNotNull(retrieved); - assertNotSame(currentThreadId, newThreadId.get()); - verify(callback, times(1)).execute(resultMock); - verify(requestMock, times(1)).post(executionRequestMock); - } - - @Test - /** - * for {@link ReportingService#newReportExecutionRequest(ReportExecutionRequest)} - */ - public void should_return_operation_result_with_proper_object() { - - // Given - mockStatic(JerseyRequest.class); - when(buildRequest(eq(sessionStorageMock), eq(ReportExecutionDescriptor.class), - eq(new String[]{"reportExecutions"}))).thenReturn(requestMock); - - doReturn(resultMock).when(requestMock).post(executionRequestMock); - ReportingService serviceSpy = PowerMockito.spy(new ReportingService(sessionStorageMock)); - - // When - OperationResult retrieved = serviceSpy.newReportExecutionRequest(executionRequestMock); - - // Then - assertNotNull(retrieved); - assertSame(retrieved, resultMock); - - verifyStatic(times(1)); - buildRequest(eq(sessionStorageMock), eq(ReportExecutionDescriptor.class), eq(new String[]{"reportExecutions"})); - } - - @Test - /** - * for {@link ReportingService#newReportExecutionRequest(ReportExecutionRequest)} - */ - public void should_set_time_zone_and_return_operation_result_with_proper_object() { - - // Given - mockStatic(JerseyRequest.class); - when(buildRequest(eq(sessionStorageMock), eq(ReportExecutionDescriptor.class), - eq(new String[]{"reportExecutions"}))).thenReturn(requestMock); - - doReturn(TimeZone.getTimeZone("America/Los_Angeles")).when(executionRequestMock).getTimeZone(); - doReturn(requestMock).when(requestMock).addHeader("Accept-Timezone", "America/Los_Angeles"); - doReturn(resultMock).when(requestMock).post(executionRequestMock); - ReportingService serviceSpy = PowerMockito.spy(new ReportingService(sessionStorageMock)); - - // When - OperationResult retrieved = serviceSpy.newReportExecutionRequest(executionRequestMock); - - // Then - assertNotNull(retrieved); - assertSame(retrieved, resultMock); - - verifyStatic(times(1)); - buildRequest(eq(sessionStorageMock), eq(ReportExecutionDescriptor.class), eq(new String[]{"reportExecutions"})); - verify(requestMock).addHeader("Accept-Timezone", "America/Los_Angeles"); - } - - @Test - /** - * for {@link ReportingService#reportExecutionRequest(String)} - */ - public void should_return_proper_builder_instance() throws Exception { - - // Given - ReportExecutionRequestBuilder builderMock = mock(ReportExecutionRequestBuilder.class); - whenNew(ReportExecutionRequestBuilder.class).withArguments(sessionStorageMock, "id").thenReturn(builderMock); - ReportingService serviceSpy = PowerMockito.spy(new ReportingService(sessionStorageMock)); - - // When - ReportExecutionRequestBuilder retrieved = serviceSpy.reportExecutionRequest("id"); - - // Then - assertNotNull(retrieved); - assertSame(retrieved, builderMock); - verifyNew(ReportExecutionRequestBuilder.class).withArguments(sessionStorageMock, "id"); - } - - @Test - /** - * for {@link ReportingService#runningReportsAndJobs()} - */ - public void should_return_proper_ReportsAndJobsSearch_instance() throws Exception { - // Given - ReportsAndJobsSearchAdapter adapterMock = mock(ReportsAndJobsSearchAdapter.class); - whenNew(ReportsAndJobsSearchAdapter.class).withArguments(sessionStorageMock).thenReturn(adapterMock); - ReportingService serviceSpy = PowerMockito.spy(new ReportingService(sessionStorageMock)); - - // When - ReportsAndJobsSearchAdapter retrieved = serviceSpy.runningReportsAndJobs(); - - // Then - assertNotNull(retrieved); - assertSame(retrieved, adapterMock); - verifyNew(ReportsAndJobsSearchAdapter.class).withArguments(sessionStorageMock); - } @Test /** @@ -220,6 +61,6 @@ public void should_return_proper_ReportsAdapter_instance() throws Exception { @AfterMethod public void after() { - reset(sessionStorageMock, requestMock, executionRequestMock, resultMock); + reset(sessionStorageMock, executionRequestMock); } } \ No newline at end of file diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/ReportsAdapterTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/ReportsAdapterTest.java index f6a3fa15..c0914a58 100644 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/ReportsAdapterTest.java +++ b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/ReportsAdapterTest.java @@ -3,8 +3,6 @@ import com.jaspersoft.jasperserver.dto.reports.ReportParameter; import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting.reportoptions.ReportOptionsAdapter; import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting.reportoptions.ReportOptionsUtil; -import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting.reportparameters.ReorderingReportParametersAdapter; -import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting.reportparameters.ReportParametersAdapter; import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting.util.ReportOutputFormat; import com.jaspersoft.jasperserver.jaxrs.client.core.SessionStorage; import org.mockito.Mock; @@ -23,16 +21,14 @@ import static org.mockito.Mockito.reset; import static org.mockito.Mockito.times; import static org.mockito.MockitoAnnotations.initMocks; -import static org.powermock.api.mockito.PowerMockito.mock; import static org.powermock.api.mockito.PowerMockito.mockStatic; import static org.powermock.api.mockito.PowerMockito.spy; import static org.powermock.api.mockito.PowerMockito.verifyNew; import static org.powermock.api.mockito.PowerMockito.when; -import static org.powermock.api.mockito.PowerMockito.whenNew; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertSame; -@PrepareForTest({ReorderingReportParametersAdapter.class, ReportParametersAdapter.class, /*RunReportAdapter.class,*/ ReportsAdapter.class, ReportOptionsUtil.class}) +@PrepareForTest({ReportsAdapter.class, ReportOptionsUtil.class}) public class ReportsAdapterTest extends PowerMockTestCase { public static final String REPORT_UNIT_URI = "reportUnitUri"; @@ -40,8 +36,6 @@ public class ReportsAdapterTest extends PowerMockTestCase { @Mock private SessionStorage sessionStorageMock; - @Mock - private ReorderingReportParametersAdapter reportParametersAdapterMock; @Mock private ReportOptionsAdapter reportOptionsAdapterMock; @@ -49,9 +43,6 @@ public class ReportsAdapterTest extends PowerMockTestCase { @Mock private RunReportAdapter reportAdapterMock; - @Mock - private ReportParametersAdapter parametersAdapterMock; - @BeforeMethod public void before() { initMocks(this); @@ -125,35 +116,6 @@ public void should_return_proper_ReportOptionsAdapter_object_by_options_list() t verifyNew(ReportOptionsAdapter.class, times(1)).withArguments(sessionStorageMock, REPORT_UNIT_URI, map); } - @Test - public void should_return_proper_ReorderingReportParametersAdapter_object() throws Exception { - - /* When */ - PowerMockito.whenNew(ReorderingReportParametersAdapter.class).withArguments(sessionStorageMock, REPORT_UNIT_URI).thenReturn(reportParametersAdapterMock); - - ReportsAdapter adapterSpy = new ReportsAdapter(sessionStorageMock, REPORT_UNIT_URI); - ReorderingReportParametersAdapter retrieved = adapterSpy.reportParameters(); - - assertSame(retrieved, reportParametersAdapterMock); - verifyNew(ReorderingReportParametersAdapter.class, times(1)).withArguments(sessionStorageMock, REPORT_UNIT_URI); - } - - @Test - public void should_return_proper_ReportParametersAdapter_instance() throws Exception { - - /* Given */ - ReportParametersAdapter parametersAdapterMock = mock(ReportParametersAdapter.class); - whenNew(ReportParametersAdapter.class).withArguments(sessionStorageMock, REPORT_UNIT_URI, "1;2;3;4;5;").thenReturn(parametersAdapterMock); - ReportsAdapter adapterSpy = new ReportsAdapter(sessionStorageMock, REPORT_UNIT_URI); - - /* When */ - ReportParametersAdapter retrieved = adapterSpy.reportParameters("1", "2", "3", "4", "5"); - - /* Then */ - assertSame(retrieved, parametersAdapterMock); - verifyNew(ReportParametersAdapter.class, times(1)).withArguments(sessionStorageMock, REPORT_UNIT_URI, "1;2;3;4;5;"); - } - @Test public void should_convert_params_into_the_adapter_with_pages() throws Exception { @@ -263,6 +225,6 @@ public void should_convert_params_into_the_adapter_without_pages_as_string() thr @AfterMethod public void after() { - reset(sessionStorageMock, /*formatMock, */reportAdapterMock, parametersAdapterMock, reportOptionsAdapterMock, reportParametersAdapterMock); + reset(sessionStorageMock, reportAdapterMock, reportOptionsAdapterMock); } } \ No newline at end of file diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/ReportsAndJobsSearchAdapterTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/ReportsAndJobsSearchAdapterTest.java deleted file mode 100644 index 80083233..00000000 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/ReportsAndJobsSearchAdapterTest.java +++ /dev/null @@ -1,146 +0,0 @@ -package com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting; - -import com.jaspersoft.jasperserver.jaxrs.client.core.Callback; -import com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest; -import com.jaspersoft.jasperserver.jaxrs.client.core.RequestExecution; -import com.jaspersoft.jasperserver.jaxrs.client.core.SessionStorage; -import com.jaspersoft.jasperserver.jaxrs.client.core.operationresult.OperationResult; -import com.jaspersoft.jasperserver.jaxrs.client.dto.reports.ReportExecutionListWrapper; -import org.mockito.InOrder; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.internal.util.reflection.Whitebox; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.testng.PowerMockTestCase; -import org.testng.Assert; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import javax.ws.rs.core.MultivaluedHashMap; -import java.util.concurrent.atomic.AtomicInteger; - -import static com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest.buildRequest; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.reset; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.MockitoAnnotations.initMocks; -import static org.powermock.api.mockito.PowerMockito.doReturn; -import static org.powermock.api.mockito.PowerMockito.mockStatic; -import static org.powermock.api.mockito.PowerMockito.spy; -import static org.powermock.api.mockito.PowerMockito.when; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNotSame; -import static org.testng.Assert.assertSame; - -@PrepareForTest(JerseyRequest.class) -public class ReportsAndJobsSearchAdapterTest extends PowerMockTestCase { - - @Mock - private SessionStorage sessionStorageMock; - - @Mock - private JerseyRequest requestMock; - - @Mock - private OperationResult resultMock; - - @BeforeMethod - public void before() { - initMocks(this); - } - - @Test - /** - * for {@link com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting.ReportsAndJobsSearchAdapter#asyncFind(com.jaspersoft.jasperserver.jaxrs.client.core.Callback)} - */ - public void should_return_RequestExecution_object_which_contains_a_Future_with_retrieved_ReportExecutionListWrapper_instance() throws InterruptedException { - - /* Given */ - final AtomicInteger newThreadId = new AtomicInteger(); - int currentThreadId = (int) Thread.currentThread().getId(); - - mockStatic(JerseyRequest.class); - when(buildRequest(eq(sessionStorageMock), eq(ReportExecutionListWrapper.class), eq(new String[]{"reportExecutions"}))).thenReturn(requestMock); - - ReportsAndJobsSearchAdapter adapterSpy = spy(new ReportsAndJobsSearchAdapter(sessionStorageMock)); - Callback, Void> callback = spy(new Callback, Void>() { - @Override - public Void execute(OperationResult data) { - newThreadId.set((int) Thread.currentThread().getId()); - synchronized (this) { - this.notify(); - } - return null; - } - }); - - InOrder inOrder = Mockito.inOrder(requestMock); - - doReturn(resultMock).when(requestMock).get(); - doReturn(null).when(callback).execute(resultMock); - - /* When */ - RequestExecution retrieved = adapterSpy.asyncFind(callback); - - /* Wait */ - synchronized (callback) { - callback.wait(1000); - } - - /* Then */ - assertNotNull(retrieved); - assertNotSame(currentThreadId, newThreadId.get()); - - verify(callback, times(1)).execute(resultMock); - - inOrder.verify(requestMock, times(1)).addParams(any(MultivaluedHashMap.class)); - inOrder.verify(requestMock, times(1)).get(); - } - - @Test - /** - * for {@link com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting.ReportsAndJobsSearchAdapter#parameter(com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting.ReportAndJobSearchParameter, String)} - */ - public void should_add_parameter_into_the_map_and_return_the_same_object() { - - /* Given */ - ReportsAndJobsSearchAdapter adapterSpy = spy(new ReportsAndJobsSearchAdapter(sessionStorageMock)); - - /* When */ - ReportsAndJobsSearchAdapter retrieved = adapterSpy.parameter(ReportAndJobSearchParameter.JOB_ID, "id"); - MultivaluedHashMap params = (MultivaluedHashMap) Whitebox.getInternalState(adapterSpy, "params"); - - /* Then */ - Assert.assertSame(retrieved, adapterSpy); - Assert.assertTrue(params.size() == 1); - Assert.assertEquals(params.getFirst(ReportAndJobSearchParameter.JOB_ID.getName()), "id"); - } - - @Test - /** - * for {@link com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting.ReportsAndJobsSearchAdapter#find()} - */ - public void should_return_proper_ReportExecutionListWrapper_with_result_of_find_operation() { - - mockStatic(JerseyRequest.class); - Mockito.when(buildRequest(eq(sessionStorageMock), eq(ReportExecutionListWrapper.class), eq(new String[]{"reportExecutions"}))).thenReturn(requestMock); - Mockito.doReturn(resultMock).when(requestMock).get(); - - ReportsAndJobsSearchAdapter adapter = new ReportsAndJobsSearchAdapter(sessionStorageMock); - - OperationResult retrieved = adapter.find(); - - assertSame(retrieved, resultMock); - Mockito.verify(requestMock).get(); - Mockito.verify(requestMock).addParams(any(MultivaluedHashMap.class)); - Mockito.verifyNoMoreInteractions(requestMock); - } - - @AfterMethod - public void after() { - reset(sessionStorageMock, requestMock, resultMock); - } -} \ No newline at end of file diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/RunReportAdapterTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/RunReportAdapterTest.java index c1f20a0c..5b093138 100644 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/RunReportAdapterTest.java +++ b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/RunReportAdapterTest.java @@ -1,5 +1,7 @@ package com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting; +import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting.util.ReportOutputFormat; +import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting.util.RunReportErrorHandler; import com.jaspersoft.jasperserver.jaxrs.client.core.Callback; import com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest; import com.jaspersoft.jasperserver.jaxrs.client.core.RequestExecution; @@ -21,9 +23,10 @@ import java.util.concurrent.atomic.AtomicInteger; import static com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest.buildRequest; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyString; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.never; import static org.mockito.Mockito.reset; import static org.mockito.Mockito.times; @@ -85,7 +88,7 @@ public Void execute(OperationResult data) { doReturn(requestMock).when(adapterSpy, "prepareRunRequest"); // private method mock doReturn(resultMock).when(requestMock).get(); - doReturn(null).when(callbackSpy).execute(resultMock); + doNothing().when(callbackSpy).execute(resultMock); // When RequestExecution retrieved = adapterSpy.asyncRun(callbackSpy); diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/RunReportErrorHandlerTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/RunReportErrorHandlerTest.java deleted file mode 100644 index f9e1cb32..00000000 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/RunReportErrorHandlerTest.java +++ /dev/null @@ -1,98 +0,0 @@ -package com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting; - -import com.jaspersoft.jasperserver.jaxrs.client.core.exceptions.ResourceNotFoundException; -import com.jaspersoft.jasperserver.jaxrs.client.core.exceptions.handling.DefaultErrorHandler; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.testng.PowerMockTestCase; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import javax.ws.rs.core.Response; - -import static org.hamcrest.core.IsInstanceOf.instanceOf; -import static org.mockito.Mockito.reset; -import static org.mockito.MockitoAnnotations.initMocks; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; - -/** - * Unit test for {@link com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting.RunReportErrorHandler} - */ -@PrepareForTest({DefaultErrorHandler.class, RunReportErrorHandler.class}) -public class RunReportErrorHandlerTest extends PowerMockTestCase { - - @Mock - private Response responseMock; - - @Mock - private Response.StatusType statusTypeMock; - - @BeforeMethod - public void before() { - initMocks(this); - } - - @Test(enabled = false) - public void should_handle_body_error_and_rethrow_exception() { - - Mockito.when(responseMock.getHeaderString("JasperServerError")).thenReturn("true"); - Mockito.when(responseMock.readEntity(String.class)).thenReturn("data"); - Mockito.when(responseMock.getStatus()).thenReturn(404); - Mockito.when(responseMock.getStatusInfo()).thenReturn(Response.Status.NOT_FOUND); - Mockito.when(responseMock.getHeaderString("Content-Type")).thenReturn("text/html"); - - RunReportErrorHandler handler = new RunReportErrorHandler(); - - try { - handler.handleBodyError(responseMock); - } catch (Exception e) { - assertTrue(instanceOf(ResourceNotFoundException.class).matches(e)); - } - } - - @Test - public void should_rethrow_exception() { - - Mockito.doReturn("_msg").when(responseMock).readEntity(String.class); - Mockito.doReturn("true").when(responseMock).getHeaderString("JasperServerError"); - Mockito.doReturn(statusTypeMock).when(responseMock).getStatusInfo(); - Mockito.doReturn("Phrase").when(statusTypeMock).getReasonPhrase(); - Mockito.doReturn(404).when(responseMock).getStatus(); - - RunReportErrorHandler handler = new RunReportErrorHandler(); - - try { - handler.handleBodyError(responseMock); - } catch (Exception e) { - //assertTrue(instanceOf(ResourceNotFoundException.class).matches(e)); - assertEquals(e.getMessage(), "_msg"); - } - } - - @Test - public void should_handle_body_error_and_rethrow_exception_if_HeaderString_is_not_JasperServerError() { - - Mockito.doReturn("_msg").when(responseMock).readEntity(String.class); - Mockito.doReturn("false").when(responseMock).getHeaderString("JasperServerError"); - Mockito.doReturn(statusTypeMock).when(responseMock).getStatusInfo(); - Mockito.doReturn("Phrase").when(statusTypeMock).getReasonPhrase(); - Mockito.doReturn(404).when(responseMock).getStatus(); - - RunReportErrorHandler handler = new RunReportErrorHandler(); - - try { - handler.handleBodyError(responseMock); - } catch (Exception e) { - //assertTrue(instanceOf(ResourceNotFoundException.class).matches(e)); - assertEquals(e.getMessage(), "_msg"); - } - } - - @AfterMethod - public void after() { - reset(responseMock, statusTypeMock); - } -} \ No newline at end of file diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/reportoptions/ReportOptionsAdapterTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/reportoptions/ReportOptionsAdapterTest.java index 73d6cbcb..05c013a6 100644 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/reportoptions/ReportOptionsAdapterTest.java +++ b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/reportoptions/ReportOptionsAdapterTest.java @@ -19,8 +19,8 @@ import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import static org.mockito.Matchers.anyMap; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.anyMap; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.reset; import static org.mockito.Mockito.times; import static org.mockito.MockitoAnnotations.initMocks; @@ -87,7 +87,7 @@ public void should_return_proper_operationResult_when_get() throws Exception { OperationResult result = adapter.get(); //then assertSame(result, resultMock); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); JerseyRequest.buildRequest(sessionStorageMock, ReportOptionsSummaryList.class, new String[]{REPORT_SERVICE_URI, REPORT_UNIT_URI, OPTIONS_SERVICE_URI}); @@ -107,7 +107,7 @@ public void should_return_proper_operationResult_when_create() throws Exception OperationResult result = adapter.create(); //then assertSame(result, resultMock); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); JerseyRequest.buildRequest(sessionStorageMock, ReportOptionsSummary.class, new String[]{REPORT_SERVICE_URI, REPORT_UNIT_URI, OPTIONS_SERVICE_URI}); @@ -129,7 +129,7 @@ public void should_return_proper_operationResult_when_create_with_params() throw OperationResult result = adapter.label("label").overwrite(Boolean.TRUE).create(); //then assertSame(result, resultMock); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); JerseyRequest.buildRequest(sessionStorageMock, ReportOptionsSummary.class, new String[]{REPORT_SERVICE_URI, REPORT_UNIT_URI, OPTIONS_SERVICE_URI}); @@ -152,7 +152,7 @@ public void should_return_proper_operationResult_when_update_map() throws Except OperationResult result = adapter.update(options); //then assertSame(result, resultMock); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); JerseyRequest.buildRequest(sessionStorageMock, ReportOptionsSummary.class, new String[]{REPORT_SERVICE_URI, REPORT_UNIT_URI, OPTIONS_SERVICE_URI, OPTIONS_ID}); @@ -172,7 +172,7 @@ public void should_return_proper_operationResult_when_update_list() throws Excep OperationResult result = adapter.update(parameterList); //then assertSame(result, resultMock); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); JerseyRequest.buildRequest(sessionStorageMock, ReportOptionsSummary.class, new String[]{REPORT_SERVICE_URI, REPORT_UNIT_URI, OPTIONS_SERVICE_URI, OPTIONS_ID}); @@ -191,7 +191,7 @@ public void should_return_proper_operationResult_when_delete() throws Exception OperationResult result = adapter.delete(); //then assertSame(result, resultMock); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); JerseyRequest.buildRequest(sessionStorageMock, Object.class, new String[]{REPORT_SERVICE_URI, REPORT_UNIT_URI, OPTIONS_SERVICE_URI, OPTIONS_ID}); diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/reportparameters/ReorderingReportParametersAdapterTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/reportparameters/ReorderingReportParametersAdapterTest.java deleted file mode 100644 index 62dc4e6d..00000000 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/reportparameters/ReorderingReportParametersAdapterTest.java +++ /dev/null @@ -1,154 +0,0 @@ -package com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting.reportparameters; - -import com.jaspersoft.jasperserver.dto.reports.inputcontrols.ReportInputControl; -import com.jaspersoft.jasperserver.dto.reports.inputcontrols.ReportInputControlsListWrapper; -import com.jaspersoft.jasperserver.jaxrs.client.core.Callback; -import com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest; -import com.jaspersoft.jasperserver.jaxrs.client.core.RequestExecution; -import com.jaspersoft.jasperserver.jaxrs.client.core.SessionStorage; -import com.jaspersoft.jasperserver.jaxrs.client.core.operationresult.OperationResult; -import org.mockito.Mock; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.testng.PowerMockTestCase; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import java.util.List; -import java.util.concurrent.atomic.AtomicInteger; - -import static com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest.buildRequest; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.reset; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.MockitoAnnotations.initMocks; -import static org.powermock.api.mockito.PowerMockito.doReturn; -import static org.powermock.api.mockito.PowerMockito.mockStatic; -import static org.powermock.api.mockito.PowerMockito.spy; -import static org.powermock.api.mockito.PowerMockito.verifyNew; -import static org.powermock.api.mockito.PowerMockito.verifyStatic; -import static org.powermock.api.mockito.PowerMockito.when; -import static org.powermock.api.mockito.PowerMockito.whenNew; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNotSame; -import static org.testng.Assert.assertSame; - -/** - * Unit tests for {@link com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting.reportparameters.ReorderingReportParametersAdapter} - * - * @author Alexander Krasnyanskiy - * - * - * @deprecated should be deleted after deleted deprecated {@link com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting.reportparameters.ReorderingReportParametersAdapter}. - */ -@PrepareForTest({JerseyRequest.class, ReorderingReportParametersAdapter.class, ReportInputControlsListWrapper.class}) -public class ReorderingReportParametersAdapterTest extends PowerMockTestCase { - - @Mock - private SessionStorage sessionStorageMock; - - @Mock - private JerseyRequest requestMock; - - @Mock - private List inputControlsMock; - - @Mock - private ReportInputControlsListWrapper wrapperMock; - - @Mock - private OperationResult resultMock; - - private String reportUnitUri = "some/abstract/thumbnail/unit/uri"; - - @BeforeMethod - public void before() { - initMocks(this); - } - - @Test - /** - * for {@link com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting.reportparameters.ReorderingReportParametersAdapter#asyncReorder(java.util.List, com.jaspersoft.jasperserver.jaxrs.client.core.Callback)} - */ - public void should_do_reorder_of_IC_asynchronously_and_return_holder_with_future() throws Exception { - - /* Given */ - final AtomicInteger newThreadId = new AtomicInteger(); - int currentThreadId = (int) Thread.currentThread().getId(); - - mockStatic(JerseyRequest.class); - when(buildRequest(eq(sessionStorageMock), - eq(ReportInputControlsListWrapper.class), - eq(new String[]{"reports", reportUnitUri, "inputControls"}))).thenReturn(requestMock); - - ReorderingReportParametersAdapter adapterSpy = spy(new ReorderingReportParametersAdapter(sessionStorageMock, reportUnitUri)); - Callback, Void> callback = spy(new Callback, Void>() { - @Override - public Void execute(OperationResult data) { - newThreadId.set((int) Thread.currentThread().getId()); - synchronized (this) { - this.notify(); - } - return null; - } - }); - - whenNew(ReportInputControlsListWrapper.class).withArguments(inputControlsMock).thenReturn(wrapperMock); - doReturn(resultMock).when(requestMock).put(wrapperMock); - doReturn(null).when(callback).execute(resultMock); - - /* When */ - RequestExecution retrieved = adapterSpy.asyncReorder(inputControlsMock, callback); - - /* Wait */ - synchronized (callback) { - callback.wait(1000); - } - - /* Then */ - assertNotNull(retrieved); - assertNotSame(currentThreadId, newThreadId.get()); - verify(requestMock, times(1)).put(wrapperMock); - verifyNew(ReportInputControlsListWrapper.class, times(1)).withArguments(inputControlsMock); - } - - @Test - /** - * for {@link com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting.reportparameters.ReorderingReportParametersAdapter#reorder(java.util.List)} - */ - public void should_do_reorder_of_IC() throws Exception { - - /* Given */ - mockStatic(JerseyRequest.class); - when(buildRequest(eq(sessionStorageMock), - eq(ReportInputControlsListWrapper.class), - eq(new String[]{"reports", reportUnitUri, "inputControls"}))).thenReturn(requestMock); - - whenNew(ReportInputControlsListWrapper.class).withArguments(inputControlsMock).thenReturn(wrapperMock); - doReturn(resultMock).when(requestMock).put(wrapperMock); - - ReorderingReportParametersAdapter adapterSpy = spy(new ReorderingReportParametersAdapter(sessionStorageMock, reportUnitUri)); - - /* When */ - OperationResult retrieved = adapterSpy.reorder(inputControlsMock); - - /* Then */ - assertNotNull(retrieved); - assertSame(retrieved, resultMock); - - verifyStatic(times(1)); - buildRequest(eq(sessionStorageMock), - eq(ReportInputControlsListWrapper.class), - eq(new String[]{"reports", reportUnitUri, "inputControls"})); - - verifyNew(ReportInputControlsListWrapper.class, times(1)).withArguments(inputControlsMock); - verify(requestMock, times(1)).put(wrapperMock); - } - - @AfterMethod - public void after() { - reset(sessionStorageMock, requestMock, inputControlsMock, wrapperMock, resultMock); - } - -} \ No newline at end of file diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/reportparameters/ReportParametersAdapterTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/reportparameters/ReportParametersAdapterTest.java deleted file mode 100644 index 298d9450..00000000 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/reportparameters/ReportParametersAdapterTest.java +++ /dev/null @@ -1,186 +0,0 @@ -package com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting.reportparameters; - -import com.jaspersoft.jasperserver.dto.reports.ReportParameters; -import com.jaspersoft.jasperserver.dto.reports.inputcontrols.ReportInputControlsListWrapper; -import com.jaspersoft.jasperserver.jaxrs.client.core.Callback; -import com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest; -import com.jaspersoft.jasperserver.jaxrs.client.core.RequestExecution; -import com.jaspersoft.jasperserver.jaxrs.client.core.SessionStorage; -import com.jaspersoft.jasperserver.jaxrs.client.core.exceptions.handling.DefaultErrorHandler; -import com.jaspersoft.jasperserver.jaxrs.client.core.operationresult.OperationResult; -import org.mockito.ArgumentCaptor; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.testng.PowerMockTestCase; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import javax.ws.rs.core.MediaType; -import java.util.List; -import java.util.concurrent.atomic.AtomicInteger; - -import static com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest.buildRequest; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyObject; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.reset; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.MockitoAnnotations.initMocks; -import static org.powermock.api.mockito.PowerMockito.doReturn; -import static org.powermock.api.mockito.PowerMockito.mockStatic; -import static org.powermock.api.mockito.PowerMockito.spy; -import static org.powermock.api.mockito.PowerMockito.when; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNotSame; -import static org.testng.Assert.assertSame; -import static org.testng.Assert.assertTrue; - -/** - * @deprecated should be deleted after deleted deprecated {@link com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting.reportparameters.ReportParametersAdapter}. - */ -@PrepareForTest({JerseyRequest.class}) -public class ReportParametersAdapterTest extends PowerMockTestCase { - - @Mock - private SessionStorage sessionStorageMock; - - @Mock - private JerseyRequest requestMock; - - @Mock - private OperationResult operationResultMock; - - private String reportUnitUri = "_uri"; - - @BeforeMethod - public void before() { - initMocks(this); - } - - @Test - public void should_return_report_input_controls_asynchronously_and_in_wrapping_holder() throws InterruptedException { - - /** Given **/ - - final AtomicInteger newThreadId = new AtomicInteger(); - final int currentThreadId = (int) Thread.currentThread().getId(); - - mockStatic(JerseyRequest.class); - when(buildRequest( - eq(sessionStorageMock), - eq(ReportInputControlsListWrapper.class), - eq(new String[]{"reports", reportUnitUri, "inputControls"}), - any(DefaultErrorHandler.class)) - ).thenReturn(requestMock); - - doReturn(operationResultMock) - .when(requestMock) - .post(anyObject()); - - ReportParametersAdapter adapterSpy = - spy(new ReportParametersAdapter(sessionStorageMock, reportUnitUri, "_segment")); - - adapterSpy.parameter("param1", "value1"); - adapterSpy.parameter("param2", "value2"); - - final Callback, Void> callbackSpy = - spy(new Callback, Void>() { - @Override - public Void execute(OperationResult data) { - newThreadId.set((int) Thread.currentThread().getId()); - synchronized (this) { - this.notify(); - } - return null; - } - }); - - - /** When **/ - RequestExecution retrieved = adapterSpy.asyncGet(callbackSpy); - - - /** Wait **/ - synchronized (callbackSpy) { - callbackSpy.wait(1000); - } - - - /** Then **/ - assertNotNull(retrieved); - assertNotSame(currentThreadId, newThreadId.get()); - - verify(requestMock).setContentType(MediaType.APPLICATION_XML); - verify(requestMock).setAccept(MediaType.APPLICATION_XML); - verify(callbackSpy, times(1)).execute(operationResultMock); - } - - @Test(enabled = false) - public void should_return_ReportInputControlsListWrapper() { - - /** Given **/ - - ArgumentCaptor parametersCaptor = ArgumentCaptor.forClass(ReportParameters.class); - mockStatic(JerseyRequest.class); - when(buildRequest( - eq(sessionStorageMock), - eq(ReportInputControlsListWrapper.class), - eq(new String[]{"/reports", reportUnitUri, "/inputControls"}), - any(DefaultErrorHandler.class)) - ).thenReturn(requestMock); - - doReturn(operationResultMock) - .when(requestMock) - .post(anyObject()); - - ReportParametersAdapter adapterSpy = spy(new ReportParametersAdapter(sessionStorageMock, reportUnitUri, "_segment")); - adapterSpy.parameter("p1", "v1"); - adapterSpy.parameter("p2", "v2"); - - - /** When **/ - OperationResult retrieved = adapterSpy.get(); - - - /** Then **/ - PowerMockito.verifyStatic(); - buildRequest( - eq(sessionStorageMock), - eq(ReportInputControlsListWrapper.class), - eq(new String[]{"/reports", reportUnitUri, "/inputControls"}), - any(DefaultErrorHandler.class)); - - Mockito.verify(requestMock).post(parametersCaptor.capture()); - assertEquals(parametersCaptor.getValue().getReportParameters().get(0).getName(), "p2"); - - assertNotNull(retrieved); - assertSame(retrieved, operationResultMock); - } - - @Test - public void should_return_proper_instance_of_ReportParametersValuesAdapter() { - - /* Given */ - ReportParametersAdapter adapterSpy = spy(new ReportParametersAdapter(sessionStorageMock, reportUnitUri, "_segment")); - adapterSpy.parameter("p1", "v1"); - adapterSpy.parameter("p2", "v2"); - - /* When */ - ReportParametersValuesAdapter retrieved = adapterSpy.values(); - - /* Then */ - assertNotNull(retrieved); - List paramValues = retrieved.params.get("p1"); - assertTrue(paramValues.contains("v1")); - } - - @AfterMethod - public void after() { - reset(sessionStorageMock, operationResultMock, requestMock); - } -} \ No newline at end of file diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/reportparameters/ReportParametersConverterTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/reportparameters/ReportParametersConverterTest.java deleted file mode 100644 index aabad815..00000000 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/reportparameters/ReportParametersConverterTest.java +++ /dev/null @@ -1,105 +0,0 @@ -package com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting.reportparameters; - -import com.jaspersoft.jasperserver.dto.reports.ReportParameters; -import com.jaspersoft.jasperserver.dto.reports.inputcontrols.InputControlOption; -import com.jaspersoft.jasperserver.dto.reports.inputcontrols.InputControlState; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.testng.PowerMockTestCase; -import org.testng.Assert; -import org.testng.annotations.Test; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; - -/** - * Unit tests for {@link com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting.reportparameters.ReportParametersConverter} - * - * @deprecated should be deleted after deleted deprecated {@link com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting.reportparameters.ReportParametersConverter - */ -@PrepareForTest({ReportParametersConverter.class}) -public class ReportParametersConverterTest extends PowerMockTestCase { - - @Test - public void should_convert_InputControlStates_into_map() { - - /* Given */ - List inputControlsIds = new ArrayList() {{ - add(new InputControlState().setId("id1")); - add(new InputControlState().setId("id2")); - }}; - - /* When */ - Map retrieved = ReportParametersConverter.getValueMapFromInputControlStates(inputControlsIds); - - /* Then */ - Assert.assertNotNull(retrieved); - assertTrue(retrieved.size() == 2); - } - - @Test - public void should_convert_InputControlStates_into_map_when_InputControlStates_has_values() { - - /* Given */ - List inputControlsIds = new ArrayList() {{ - add(new InputControlState().setId("id1").setValue("value1")); - add(new InputControlState().setId("id2").setValue("value2")); - }}; - - /* When */ - Map retrieved = ReportParametersConverter.getValueMapFromInputControlStates(inputControlsIds); - - /* Then */ - Assert.assertNotNull(retrieved); - assertTrue(retrieved.size() == 2); - } - - @Test - public void should_return_proper_ReportParameters() { - - /* Given */ - List inputControlsIds = new ArrayList() {{ - add(new InputControlState().setId("id1").setValue("value1")); - add(new InputControlState().setId("id2").setValue("value2")); - }}; - - /* When */ - ReportParameters retrieved = ReportParametersConverter.toReportParameters(inputControlsIds); - - /* Then */ - assertNotNull(retrieved); - assertTrue(retrieved.getReportParameters().size() == 2); - } - - @Test - public void should_create_not_null_instance() { - assertNotNull(new ReportParametersConverter()); - } - - @Test - public void should_return_converted_params() { - - InputControlOption option1 = new InputControlOption().setSelected(true); - option1.setValue("OptionValue"); - List inputControlOptions = new ArrayList(); - inputControlOptions.add(option1); - - - InputControlState inputControlState = new InputControlState(); - inputControlState.setId("1"); - inputControlState.setOptions(inputControlOptions); - - List states = new ArrayList(); - states.add(inputControlState); - - Map retrieved = ReportParametersConverter.getValueMapFromInputControlStates(states); - - assertNotNull(retrieved); - String[] options = (String[]) retrieved.get("1"); - assertEquals(options[0], "OptionValue"); - } -} \ No newline at end of file diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/reportparameters/ReportParametersUtilsTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/reportparameters/ReportParametersUtilsTest.java deleted file mode 100644 index e4be78b5..00000000 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/reportparameters/ReportParametersUtilsTest.java +++ /dev/null @@ -1,98 +0,0 @@ -package com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting.reportparameters; - -import com.jaspersoft.jasperserver.dto.reports.ReportParameter; -import com.jaspersoft.jasperserver.dto.reports.ReportParameters; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.testng.PowerMockTestCase; -import org.testng.annotations.Test; - -import javax.ws.rs.core.MultivaluedHashMap; -import javax.ws.rs.core.MultivaluedMap; -import java.util.ArrayList; -import java.util.List; - -import static com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting.reportparameters.ReportParametersUtils.toPathSegment; -import static org.mockito.Mockito.times; -import static org.powermock.api.mockito.PowerMockito.verifyStatic; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; - -/** - * Unit tests for {@link com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting.reportparameters.ReportParametersUtils} - * - ** - * @deprecated should be deleted after deleted deprecated {@link com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting.reportparameters.ReportParametersUtils - */ -@PrepareForTest(ReportParametersUtils.class) -public class ReportParametersUtilsTest extends PowerMockTestCase { - - @Test - public void should_return_new_instance_of_ReportParameters_constructed_with_proper_parameters() { - - /* Given */ - MultivaluedMap params = new MultivaluedHashMap() {{ - add("key1", "value1_1"); - add("key1", "value1_2"); - add("key2", "value2_1"); - add("key2", "value2_2"); - }}; - - /* When */ - ReportParameters retrieved = ReportParametersUtils.toReportParameters(params); - List parameters = retrieved.getReportParameters(); - - /* Then */ - assertNotNull(retrieved); - assertFalse(parameters.isEmpty()); - assertTrue(parameters.size() == 2); - } - - @Test - public void should_convert_list_of_IC_Ids_into_proper_path_segment() { - - /* Given */ - List inputControlsIds = new ArrayList() {{ - add("a"); - add("b"); - add("c"); - }}; - - /* When */ - String retrieved = toPathSegment(inputControlsIds); - - /* Then */ - assertNotNull(retrieved); - assertEquals(retrieved, "a;b;c;"); - } - - @Test(expectedExceptions = NullPointerException.class) - public void should_throw_an_exception_when_inputControlsIds_is_null() { - toPathSegment(null); - } - - @Test - public void should_invoke_static_method_of_ReportParametersUtils_class() { - - /* Given */ - PowerMockito.mockStatic(ReportParametersUtils.class); - - List inputControlsIds = new ArrayList() {{ - add("a"); - add("b"); - add("c"); - }}; - - ReportParametersUtils.toPathSegment(inputControlsIds); - - verifyStatic(times(1)); - ReportParametersUtils.toPathSegment(inputControlsIds); - } - - @Test - public void should_create_instance_of_class() { - assertNotNull(new ReportParametersUtils()); - } -} \ No newline at end of file diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/resources/BatchResourcesAdapterTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/resources/BatchResourcesAdapterTest.java index c1e2ff0c..4b1aa991 100644 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/resources/BatchResourcesAdapterTest.java +++ b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/resources/BatchResourcesAdapterTest.java @@ -10,7 +10,7 @@ import com.jaspersoft.jasperserver.jaxrs.client.core.operationresult.OperationResult; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.internal.util.reflection.Whitebox; +import org.powermock.reflect.Whitebox; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.testng.PowerMockTestCase; import org.testng.annotations.AfterMethod; @@ -23,8 +23,8 @@ import java.util.concurrent.atomic.AtomicInteger; import static com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest.buildRequest; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.reset; import static org.mockito.Mockito.times; @@ -115,7 +115,7 @@ public void should_invoke_all_private_logic_and_return_proper_operation_result() assertNotNull(retrievedResult); assertSame(retrievedResult, resultMock); - verifyStatic(); + verifyStatic(JerseyRequest.class); buildRequest(eq(sessionStorageMock), eq(ClientResourceListWrapper.class), eq(new String[]{"resources"}), diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/resources/SingleResourceAdapterTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/resources/SingleResourceAdapterTest.java index a31b7f09..a79bb22e 100644 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/resources/SingleResourceAdapterTest.java +++ b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/resources/SingleResourceAdapterTest.java @@ -15,16 +15,15 @@ import com.jaspersoft.jasperserver.jaxrs.client.core.enums.MimeType; import com.jaspersoft.jasperserver.jaxrs.client.core.exceptions.handling.DefaultErrorHandler; import com.jaspersoft.jasperserver.jaxrs.client.core.operationresult.OperationResult; -import org.glassfish.jersey.media.multipart.FormDataBodyPart; import org.glassfish.jersey.media.multipart.FormDataMultiPart; import org.mockito.ArgumentCaptor; import org.mockito.Captor; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.internal.util.reflection.Whitebox; import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.testng.PowerMockTestCase; +import org.powermock.reflect.Whitebox; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -33,15 +32,12 @@ import javax.ws.rs.core.MultivaluedMap; import java.io.File; import java.io.InputStream; -import java.util.List; -import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; -import static com.jaspersoft.jasperserver.dto.resources.ClientFile.FileType; import static com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest.buildRequest; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyObject; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.reset; import static org.mockito.Mockito.spy; @@ -145,7 +141,7 @@ public Void execute(OperationResult data) { return null; } }); - PowerMockito.doReturn(null).when(callback).execute(operationResultMock); + PowerMockito.doNothing().when(callback).execute(operationResultMock); /** When **/ RequestExecution retrieved = adapterSpy.asyncDetails(callback); @@ -195,7 +191,7 @@ public Void execute(OperationResult data) { return null; } }); - PowerMockito.doReturn(null).when(callback).execute(operationResultMock); + PowerMockito.doNothing().when(callback).execute(operationResultMock); /** When **/ RequestExecution retrieved = adapterSpy.asyncDetails(callback); @@ -262,7 +258,7 @@ public Void execute(OperationResult data) { return null; } }); - doReturn(null).when(callback).execute(objectOperationResultMock); + doNothing().when(callback).execute(objectOperationResultMock); /** When **/ RequestExecution retrieved = adapter.asyncDelete(callback); @@ -279,62 +275,6 @@ public Void execute(OperationResult data) { verify(callback).execute(objectOperationResultMock); } - @Test - /** - * for {@link com.jaspersoft.jasperserver.jaxrs.client.apiadapters.resources.SingleResourceAdapter#asyncUploadFile(java.io.File, com.jaspersoft.jasperserver.dto.resources.ClientFile.FileType, String, String, com.jaspersoft.jasperserver.jaxrs.client.core.Callback)} - */ - public void should_upload_file_asynchronously() throws InterruptedException { - - /** Given **/ - String resourceUri = "requestId"; - - final AtomicInteger newThreadId = new AtomicInteger(); - final int currentThreadId = (int) Thread.currentThread().getId(); - - SingleResourceAdapter adapter = new SingleResourceAdapter(sessionStorageMock, resourceUri); - - mockStatic(JerseyRequest.class); - when(buildRequest(eq(sessionStorageMock), eq(ClientFile.class), - eq(new String[]{"resources", resourceUri}), any(DefaultErrorHandler.class))).thenReturn(clientFileJerseyRequestMock); - doReturn(clientFileOperationResultMock).when(clientFileJerseyRequestMock).post(anyObject()); - - final Callback, Void> callback = - spy(new Callback, Void>() { - @Override - public Void execute(OperationResult data) { - newThreadId.set((int) Thread.currentThread().getId()); - synchronized (this) { - this.notify(); - } - return null; - } - }); - doReturn(null).when(callback).execute(clientFileOperationResultMock); - - - /** When **/ - RequestExecution retrieved = adapter.asyncUploadFile(fileMock, - FileType.txt, "label_", "description_", callback); - - - /** Wait **/ - synchronized (callback) { - callback.wait(1000); - } - - - /** Then **/ - assertNotNull(retrieved); - assertNotSame(currentThreadId, newThreadId.get()); - verify(clientFileJerseyRequestMock, times(1)).post(captor.capture()); - verify(callback).execute(clientFileOperationResultMock); - - FormDataMultiPart intercepted = captor.getValue(); - Map> recievedFields = intercepted.getFields(); - - assertSame(recievedFields.get("label").get(0).getValue(), "label_"); - assertSame(recievedFields.get("description").get(0).getValue(), "description_"); - } @Test /** @@ -436,7 +376,7 @@ public Void execute(OperationResult data) { } }); - doReturn(null).when(callback).execute(adhocDataViewOperationResultMock); + doNothing().when(callback).execute(adhocDataViewOperationResultMock); /** When **/ @@ -482,7 +422,7 @@ public void should_send_descriptor_into_server() { OperationResult retrieved = adapter.patchResource(ClientAdhocDataView.class, descriptorMock); /** Then **/ - verifyStatic(); + verifyStatic(JerseyRequest.class); buildRequest(eq(sessionStorageMock), eq(ClientAdhocDataView.class), eq(new String[]{"resources"}), @@ -568,7 +508,7 @@ public Void execute(OperationResult data) { } }); - doReturn(null).when(callback).execute(inputStreamOperationResultMock); + doNothing().when(callback).execute(inputStreamOperationResultMock); /** When **/ @@ -601,7 +541,8 @@ public void should_update_resource_asynchronously() throws InterruptedException mockStatic(JerseyRequest.class); when(buildRequest(eq(sessionStorageMock), eq(ClientVirtualDataSource.class), - eq(new String[]{"resources", resourceUri}), any(ResourceValidationErrorHandler.class))).thenReturn(virtualDataSourceJerseyRequestMock); + eq(new String[]{"resources", resourceUri}), + any(DefaultErrorHandler.class))).thenReturn(virtualDataSourceJerseyRequestMock); doReturn(operationResultMock).when(virtualDataSourceJerseyRequestMock).put(source); doReturn(configurationMock).when(sessionStorageMock).getConfiguration(); @@ -625,7 +566,7 @@ public Void execute(OperationResult data) { } }); - doReturn(null).when(callback).execute(operationResultMock); + doNothing().when(callback).execute(operationResultMock); /** When **/ @@ -673,7 +614,7 @@ public Void execute(OperationResult data) { return null; } }); - Mockito.doReturn(null).when(callback).execute(operationResultMock); + doNothing().when(callback).execute(operationResultMock); SingleResourceAdapter adapter = new SingleResourceAdapter(sessionStorageMock, resourceUri); @@ -724,7 +665,7 @@ public Void execute(OperationResult data) { return null; } }); - Mockito.doReturn(null).when(callback).execute(operationResultMock); + doNothing().when(callback).execute(operationResultMock); SingleResourceAdapter adapter = new SingleResourceAdapter(sessionStorageMock, resourceUri); @@ -748,99 +689,6 @@ public Void execute(OperationResult data) { Mockito.verify(callback).execute(operationResultMock); } - @Test - @SuppressWarnings("unchecked") - public void should_create_new_resource_asynchronously() throws InterruptedException { - - /** Given **/ - String resourceUri = "uri"; - ClientVirtualDataSource source = new ClientVirtualDataSource(); - - mockStatic(JerseyRequest.class); - when(buildRequest(eq(sessionStorageMock), - eq(ClientVirtualDataSource.class), - eq(new String[]{"resources", resourceUri}), - any(ResourceValidationErrorHandler.class))).thenReturn(virtualDataSourceJerseyRequestMock); - - doReturn(operationResultMock).when(virtualDataSourceJerseyRequestMock).post(source); - doReturn(configurationMock).when(sessionStorageMock).getConfiguration(); - - doReturn(MimeType.JSON).when(configurationMock).getContentMimeType(); - doReturn(MimeType.JSON).when(configurationMock).getAcceptMimeType(); - SingleResourceAdapter adapter = new SingleResourceAdapter(sessionStorageMock, resourceUri); - - final AtomicInteger newThreadId = new AtomicInteger(); - final int currentThreadId = (int) Thread.currentThread().getId(); - - final Callback, Void> callback = - spy(new Callback, Void>() { - @Override - public Void execute(OperationResult data) { - newThreadId.set((int) Thread.currentThread().getId()); - synchronized (this) { - this.notify(); - } - return null; - } - }); - - doReturn(null).when(callback).execute(operationResultMock); - - - /** When **/ - RequestExecution retrieved = adapter.asyncCreateNew(source, callback); - - /** Wait **/ - synchronized (callback) { - callback.wait(1000); - } - - /** Then **/ - assertNotNull(retrieved); - assertNotSame(currentThreadId, newThreadId.get()); - - Mockito.verify(virtualDataSourceJerseyRequestMock).post(source); - Mockito.verify(callback).execute(operationResultMock); - Mockito.verify(virtualDataSourceJerseyRequestMock).addParams(any(MultivaluedHashMap.class)); - Mockito.verify(virtualDataSourceJerseyRequestMock).setContentType("application/repository.virtualDataSource+json"); - Mockito.verify(virtualDataSourceJerseyRequestMock).setAccept("application/repository.virtualDataSource+json"); - } - - @Test - @SuppressWarnings("unchecked") - public void should_create_new_resource() { - - /** Given **/ - String resourceUri = "uri"; - ClientVirtualDataSource source = new ClientVirtualDataSource(); - - mockStatic(JerseyRequest.class); - when(buildRequest(eq(sessionStorageMock), - eq(ClientVirtualDataSource.class), - eq(new String[]{"resources", resourceUri}), - any(ResourceValidationErrorHandler.class))).thenReturn(virtualDataSourceJerseyRequestMock); - - doReturn(operationResultMock).when(virtualDataSourceJerseyRequestMock).post(source); - doReturn(configurationMock).when(sessionStorageMock).getConfiguration(); - - doReturn(MimeType.JSON).when(configurationMock).getContentMimeType(); - doReturn(MimeType.JSON).when(configurationMock).getAcceptMimeType(); - SingleResourceAdapter adapter = new SingleResourceAdapter(sessionStorageMock, resourceUri); - - - /** When **/ - OperationResult retrieved = adapter.createNew(source); - - - /** Then **/ - assertSame(retrieved, operationResultMock); - - Mockito.verify(virtualDataSourceJerseyRequestMock).post(source); - Mockito.verify(virtualDataSourceJerseyRequestMock).addParams(any(MultivaluedHashMap.class)); - Mockito.verify(virtualDataSourceJerseyRequestMock).setContentType("application/repository.virtualDataSource+json"); - Mockito.verify(virtualDataSourceJerseyRequestMock).setAccept("application/repository.virtualDataSource+json"); - } - @Test @SuppressWarnings("unchecked") public void should_update_resource() throws InterruptedException { @@ -853,7 +701,7 @@ public void should_update_resource() throws InterruptedException { when(buildRequest(eq(sessionStorageMock), eq(ClientVirtualDataSource.class), eq(new String[]{"resources", resourceUri}), - any(ResourceValidationErrorHandler.class))).thenReturn(virtualDataSourceJerseyRequestMock); + any(DefaultErrorHandler.class))).thenReturn(virtualDataSourceJerseyRequestMock); doReturn(operationResultMock).when(virtualDataSourceJerseyRequestMock).put(source); doReturn(configurationMock).when(sessionStorageMock).getConfiguration(); @@ -876,96 +724,4 @@ public void should_update_resource() throws InterruptedException { Mockito.verify(virtualDataSourceJerseyRequestMock).setAccept("application/repository.virtualDataSource+json"); } - - @Test - public void should_upload_file() throws InterruptedException { - - /** Given **/ - String resourceUri = "requestId"; - - SingleResourceAdapter adapter = new SingleResourceAdapter(sessionStorageMock, resourceUri); - - mockStatic(JerseyRequest.class); - when(buildRequest(eq(sessionStorageMock), - eq(ClientFile.class), - eq(new String[]{"resources", resourceUri}), - any(DefaultErrorHandler.class))).thenReturn(clientFileJerseyRequestMock); - doReturn(clientFileOperationResultMock).when(clientFileJerseyRequestMock).post(anyObject()); - - - /** When **/ - OperationResult retrieved = adapter.uploadFile(fileMock, FileType.txt, "label_", "description_"); - - - /** Then **/ - assertNotNull(retrieved); - assertSame(retrieved, clientFileOperationResultMock); - verify(clientFileJerseyRequestMock, times(1)).post(captor.capture()); - - FormDataMultiPart intercepted = captor.getValue(); - Map> recievedFields = intercepted.getFields(); - - assertSame(recievedFields.get("label").get(0).getValue(), "label_"); - assertSame(recievedFields.get("description").get(0).getValue(), "description_"); - } - - @Test - @SuppressWarnings("unchecked") - public void should_move_resource() throws InterruptedException { - - /** Given **/ - String resourceUri = "uri"; - - mockStatic(JerseyRequest.class); - when(buildRequest(eq(sessionStorageMock), - eq(ClientResource.class), - eq(new String[]{"resources", resourceUri}), - any(DefaultErrorHandler.class))).thenReturn(jerseyRequestMock); - doReturn(operationResultMock).when(jerseyRequestMock).put(""); - - SingleResourceAdapter adapter = new SingleResourceAdapter(sessionStorageMock, resourceUri); - - - /** When **/ - OperationResult retrieved = adapter.moveFrom("fromUri"); - - - /** Then **/ - assertNotNull(retrieved); - assertSame(retrieved, operationResultMock); - - Mockito.verify(jerseyRequestMock).put(""); - Mockito.verify(jerseyRequestMock).addParams(any(MultivaluedHashMap.class)); - Mockito.verify(jerseyRequestMock).addHeader("Content-Location", "fromUri"); - } - - @Test - @SuppressWarnings("unchecked") - public void should_copy_resource() throws InterruptedException { - - /** Given **/ - String resourceUri = "uri"; - - mockStatic(JerseyRequest.class); - when(buildRequest(eq(sessionStorageMock), eq(ClientResource.class), - eq(new String[]{"resources", resourceUri}), - any(DefaultErrorHandler.class))).thenReturn(jerseyRequestMock); - doReturn(operationResultMock).when(jerseyRequestMock).post(null); - - SingleResourceAdapter adapter = new SingleResourceAdapter(sessionStorageMock, resourceUri); - - - /** When **/ - OperationResult retrieved = adapter.copyFrom("fromUri"); - - - /** Then **/ - assertNotNull(retrieved); - assertSame(retrieved, operationResultMock); - - Mockito.verify(jerseyRequestMock).post(null); - Mockito.verify(jerseyRequestMock).addParams(any(MultivaluedHashMap.class)); - Mockito.verify(jerseyRequestMock).addHeader("Content-Location", "fromUri"); - } - } diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/serverInfo/ServerInfoServiceTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/serverInfo/ServerInfoServiceTest.java index 014ed839..fd1af5f8 100644 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/serverInfo/ServerInfoServiceTest.java +++ b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/serverInfo/ServerInfoServiceTest.java @@ -14,7 +14,7 @@ import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.reset; import static org.mockito.Mockito.times; import static org.mockito.MockitoAnnotations.initMocks; @@ -164,7 +164,7 @@ public void should_return_proper_server_details() { OperationResult details = service.details(); assertSame(details, serverInfoOperationResult); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); JerseyRequest.buildRequest(eq(sessionStorageMock), eq(ServerInfo.class), eq(new String[]{"serverInfo"})); } @@ -185,7 +185,7 @@ public void should_return_proper_edition() { OperationResult edition = service.edition(); // Then - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); JerseyRequest.buildRequest(eq(sessionStorageMock), eq(String.class), eq(new String[]{"serverInfo", path})); assertSame(edition, operationResultMock); diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/settings/SingleSettingsAdapterTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/settings/SingleSettingsAdapterTest.java index 3d2067e9..ed245aee 100644 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/settings/SingleSettingsAdapterTest.java +++ b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/settings/SingleSettingsAdapterTest.java @@ -24,8 +24,8 @@ import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.reset; import static org.mockito.Mockito.times; import static org.mockito.MockitoAnnotations.initMocks; @@ -133,7 +133,7 @@ public void should_return_map_of_aws_settings_operationResult() throws Exception OperationResult settings = service.settings().group("awsSettings", Map.class); //then assertSame(settings, mapOperationResult); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); JerseyRequest.buildRequest(eq(sessionStorageMock), eq(Map.class), eq(new String[]{"settings", "awsSettings"}), @@ -153,7 +153,7 @@ public void should_return_awsSettings_operationResult() throws Exception { //then assertSame(settings, awsSettingsOperationResult); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); JerseyRequest.buildRequest(eq(sessionStorageMock), eq(AwsSettings.class), eq(new String[]{"settings", "awsSettings"}), @@ -174,7 +174,7 @@ public void should_return_list_operationResult() throws Exception { //then assertSame(settings, listOperationResult); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); JerseyRequest.buildRequest(eq(sessionStorageMock), eq(List.class), eq(new String[]{"settings", "userTimeZones"}), @@ -198,7 +198,7 @@ public void should_return_list_of_user_time_zones__operationResult() throws Exce //then assertSame(settings, userTimeZonesListOperationResult); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); JerseyRequest.buildRequest(eq(sessionStorageMock), eq(new GenericType>() { }), @@ -220,7 +220,7 @@ public void should_return_request_settings_dto__operationResult_by_specified_met //then assertSame(settings, requestSettingsOperationResult); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); JerseyRequest.buildRequest(eq(sessionStorageMock), eq(RequestSettings.class), eq(new String[]{"settings", "request"}), @@ -242,7 +242,7 @@ public void should_return_dataSourcePatterns_settings_dto__operationResult_by_sp //then assertSame(settings, dataSourcePatternsSettingsOperationResult); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); JerseyRequest.buildRequest(eq(sessionStorageMock), eq(DataSourcePatternsSettings.class), eq(new String[]{"settings", "dataSourcePatterns"}), @@ -265,7 +265,7 @@ public void should_return_userTimeZones_settings_dto__operationResult_by_specifi //then assertSame(settings, userTimeZonesListOperationResult); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); JerseyRequest.buildRequest(eq(sessionStorageMock), eq(new GenericType>() { }), @@ -287,7 +287,7 @@ public void should_return_aws_settings_dto__operationResult_by_specified_method( //then assertSame(settings, awsSettingsOperationResult); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); JerseyRequest.buildRequest(eq(sessionStorageMock), eq(AwsSettings.class), eq(new String[]{"settings", "awsSettings"}), @@ -309,7 +309,7 @@ public void should_return_decimalFormatSymbol_settings_dto__operationResult_by_s //then assertSame(settings, decimalFormatSymbolsSettingsOperationResult); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); JerseyRequest.buildRequest(eq(sessionStorageMock), eq(DecimalFormatSymbolsSettings.class), eq(new String[]{"settings", "decimalFormatSymbols"}), @@ -330,7 +330,7 @@ public void should_return_dashboard_settings_dto__operationResult_by_specified_m //then assertSame(settings, dashboardSettingsOperationResult); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); JerseyRequest.buildRequest(eq(sessionStorageMock), eq(DashboardSettings.class), eq(new String[]{"settings", "dashboardSettings"}), @@ -351,7 +351,7 @@ public void should_return_globalConfiguration_settings_dto__operationResult_by_s //then assertSame(settings, globalConfigurationSettingsOperationResult); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); JerseyRequest.buildRequest(eq(sessionStorageMock), eq(GlobalConfigurationSettings.class), eq(new String[]{"settings", "globalConfiguration"}), @@ -372,7 +372,7 @@ public void should_return_dateTime_settings_dto__operationResult_by_specified_me //then assertSame(settings, dateTimeSettingsOperationResult); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); JerseyRequest.buildRequest(eq(sessionStorageMock), eq(DateTimeSettings.class), eq(new String[]{"settings", "dateTimeSettings"}), @@ -393,7 +393,7 @@ public void should_return_inputControls_settings_dto__operationResult_by_specifi //then assertSame(settings, inputControlsSettingsOperationResult); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); JerseyRequest.buildRequest(eq(sessionStorageMock), eq(InputControlsSettings.class), eq(new String[]{"settings", "inputControls"}), diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/thumbnails/BatchThumbnailAdapterTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/thumbnails/BatchThumbnailAdapterTest.java index 551e27ae..76e105a3 100644 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/thumbnails/BatchThumbnailAdapterTest.java +++ b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/thumbnails/BatchThumbnailAdapterTest.java @@ -11,7 +11,7 @@ import org.mockito.ArgumentCaptor; import org.mockito.Captor; import org.mockito.Mock; -import org.mockito.internal.util.reflection.Whitebox; +import org.powermock.reflect.Whitebox; import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.testng.PowerMockTestCase; @@ -21,8 +21,8 @@ import org.testng.annotations.Test; import static com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest.buildRequest; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.never; import static org.mockito.Mockito.reset; import static org.mockito.Mockito.times; @@ -126,7 +126,7 @@ public void should_return_proper_operation_result_with_default_request_method() // Then Assert.assertNotNull(retrieved); Assert.assertSame(retrieved, operationResultMock); - PowerMockito.verifyStatic(times(1)); + PowerMockito.verifyStatic(JerseyRequest.class, times(1)); buildRequest(eq(sessionStorageMock), eq(ResourceThumbnailsListWrapper.class), eq(new String[]{"thumbnails"}), any(DefaultErrorHandler.class)); @@ -167,7 +167,7 @@ public void should_return_proper_operation_result_with_get_request_method() { // Then Assert.assertNotNull(retrieved); Assert.assertSame(retrieved, operationResultMock); - PowerMockito.verifyStatic(times(1)); + PowerMockito.verifyStatic(JerseyRequest.class, times(1)); buildRequest(eq(sessionStorageMock), eq(ResourceThumbnailsListWrapper.class), eq(new String[]{"thumbnails"}), any(DefaultErrorHandler.class)); diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/thumbnails/SingleThumbnailAdapterTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/thumbnails/SingleThumbnailAdapterTest.java index 461f9fdd..7a870d0e 100644 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/thumbnails/SingleThumbnailAdapterTest.java +++ b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/thumbnails/SingleThumbnailAdapterTest.java @@ -8,7 +8,7 @@ import com.jaspersoft.jasperserver.jaxrs.client.core.operationresult.OperationResult; import java.io.InputStream; import org.mockito.Mock; -import org.mockito.internal.util.reflection.Whitebox; +import org.powermock.reflect.Whitebox; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.testng.PowerMockTestCase; import org.testng.annotations.AfterMethod; @@ -16,8 +16,8 @@ import org.testng.annotations.Test; import static com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest.buildRequest; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.reset; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -203,7 +203,7 @@ public void should_return_proper_operation_result() { assertSame(retrieved, operationResultMock); verify(jerseyRequestMock).setAccept(eq("image/jpeg")); verify(jerseyRequestMock).get(); - verifyStatic(times(1)); + verifyStatic(JerseyRequest.class, times(1)); buildRequest( eq(sessionStorageMock), eq(InputStream.class), diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/core/JasperserverRestClientTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/core/JasperserverRestClientTest.java index d8a482ee..7a84966f 100644 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/core/JasperserverRestClientTest.java +++ b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/core/JasperserverRestClientTest.java @@ -20,6 +20,8 @@ import javax.ws.rs.core.NewCookie; import javax.ws.rs.core.Response; import org.glassfish.jersey.client.ClientProperties; +import org.mockito.ArgumentCaptor; +import org.mockito.Captor; import org.mockito.Mock; import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PrepareForTest; @@ -28,11 +30,11 @@ import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyBoolean; -import static org.mockito.Matchers.anyString; -import static org.mockito.Matchers.eq; -import static org.mockito.Matchers.isA; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyBoolean; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.ArgumentMatchers.isA; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.never; @@ -45,6 +47,8 @@ import static org.powermock.api.support.membermodification.MemberMatcher.method; import static org.powermock.api.support.membermodification.MemberModifier.suppress; import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertSame; +import static org.testng.Assert.assertTrue; import static org.testng.AssertJUnit.assertNotNull; /** @@ -74,6 +78,8 @@ public class JasperserverRestClientTest extends PowerMockTestCase { private Response responseMock; @Mock private DefaultErrorHandler errorHandler; + @Captor + private ArgumentCaptor> entityArgumentCaptor; final String USER_NAME = "John"; @@ -490,7 +496,12 @@ public void should_invoke_login_method_and_return_proper_session_object() throws verify(rootTargetMock).path("/j_spring_security_check"); verify(webTargetMock).property(ClientProperties.FOLLOW_REDIRECTS, Boolean.FALSE); verify(webTargetMock).request(); - verify(invocationBuilderMock).post(Entity.entity(any(Form.class), MediaType.APPLICATION_FORM_URLENCODED_TYPE)); + + verify(invocationBuilderMock).post(entityArgumentCaptor.capture()); + Entity entity = entityArgumentCaptor.getValue(); + assertEquals(entity.getMediaType(), MediaType.APPLICATION_FORM_URLENCODED_TYPE); + assertSame(entity.getEntity().getClass(), Form.class); + verify(responseMock).getLocation(); verify(responseMock).getCookies(); verify(sessionStorageMock).setSessionId("AC0C233ED7E9BE5DD0D4A286E6C8BBAE"); diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/core/JerseyRequestTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/core/JerseyRequestTest.java index b9430fcb..eeb0e63d 100644 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/core/JerseyRequestTest.java +++ b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/core/JerseyRequestTest.java @@ -6,25 +6,25 @@ import com.jaspersoft.jasperserver.jaxrs.client.core.operationresult.OperationResult; import com.jaspersoft.jasperserver.jaxrs.client.core.operationresult.OperationResultFactoryImpl; import com.jaspersoft.jasperserver.jaxrs.client.providers.CustomRepresentationTypeProvider; -import javax.ws.rs.client.Entity; -import javax.ws.rs.client.Invocation; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.MultivaluedHashMap; -import javax.ws.rs.core.MultivaluedMap; -import javax.ws.rs.core.Response; import org.glassfish.jersey.client.JerseyWebTarget; import org.glassfish.jersey.jackson.JacksonFeature; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.internal.util.reflection.Whitebox; import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.testng.PowerMockTestCase; +import org.powermock.reflect.Whitebox; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import static org.mockito.Matchers.anyObject; +import javax.ws.rs.client.Invocation; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.MultivaluedHashMap; +import javax.ws.rs.core.MultivaluedMap; +import javax.ws.rs.core.Response; + +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.reset; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -97,7 +97,7 @@ public void should_invoke_overloaded_buildRequest_method() { JerseyRequest.buildRequest(sessionStorage, Class.class, fakeArrayPath); // invocation ot outer print // Then - PowerMockito.verifyStatic(times(1)); + PowerMockito.verifyStatic(JerseyRequest.class, times(1)); JerseyRequest.buildRequest(sessionStorage, Class.class, fakeArrayPath, null); } @@ -150,7 +150,7 @@ public void should_() throws Exception { doReturn(Boolean.TRUE).when(clientConfiguration).getRestrictedHttpMethods(); JerseyRequest jerseyRequestSpy = spy(new JerseyRequest(sessionStorage, Class.class)); doReturn(builder).when(jerseyRequestSpy, "buildRequest"); - Mockito.doReturn(responseMock).when(builder).post((Entity) anyObject()); + Mockito.doReturn(responseMock).when(builder).post(any()); // When OperationResult retrieved = jerseyRequestSpy.put(dummyEntity); @@ -158,7 +158,7 @@ public void should_() throws Exception { // Then // assertEquals(retrieved, operationResult); Mockito.verify(builder).header("X-HTTP-Method-Override", "PUT"); - Mockito.verify(builder).post((Entity) anyObject()); + Mockito.verify(builder).post(any()); verifyPrivate(jerseyRequestSpy).invoke("buildRequest"); verifyPrivate(jerseyRequestSpy).invoke("executeRequest", PUT, builder, dummyEntity); } diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/core/MimeTypeUtilTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/core/MimeTypeUtilTest.java index ab3bc1eb..6bbbba48 100644 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/core/MimeTypeUtilTest.java +++ b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/core/MimeTypeUtilTest.java @@ -41,7 +41,7 @@ public void before() throws IllegalAccessException { public void test_invoke_toCorrectContentMime_method_only_once (){ PowerMockito.mockStatic(MimeTypeUtil.class); MimeTypeUtil.toCorrectContentMime(configurationMock, "abc"); - PowerMockito.verifyStatic(Mockito.times(1)); + PowerMockito.verifyStatic(MimeTypeUtil.class, Mockito.times(1)); MimeTypeUtil.toCorrectContentMime(configurationMock, "abc"); } diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/core/RequestExecutionTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/core/RequestExecutionTest.java index 7fc01857..8d7d4a8c 100644 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/core/RequestExecutionTest.java +++ b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/core/RequestExecutionTest.java @@ -1,7 +1,7 @@ package com.jaspersoft.jasperserver.jaxrs.client.core; import org.mockito.Mockito; -import org.mockito.internal.util.reflection.Whitebox; +import org.powermock.reflect.Whitebox; import org.testng.annotations.Test; import java.util.concurrent.Callable; diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/core/RestClientConfigurationTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/core/RestClientConfigurationTest.java index 1b579d98..dda3b97c 100644 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/core/RestClientConfigurationTest.java +++ b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/core/RestClientConfigurationTest.java @@ -3,14 +3,6 @@ import com.jaspersoft.jasperserver.jaxrs.client.core.enums.AuthenticationType; import com.jaspersoft.jasperserver.jaxrs.client.core.enums.JRSVersion; import com.jaspersoft.jasperserver.jaxrs.client.core.enums.MimeType; -import java.io.InputStream; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.security.cert.CertificateException; -import java.security.cert.X509Certificate; -import java.util.Properties; -import javax.net.ssl.TrustManager; -import javax.net.ssl.X509TrustManager; import org.mockito.Mockito; import org.powermock.api.mockito.PowerMockito; import org.powermock.api.support.membermodification.MemberMatcher; @@ -19,7 +11,16 @@ import org.testng.Assert; import org.testng.annotations.Test; -import static org.mockito.Matchers.any; +import javax.net.ssl.TrustManager; +import javax.net.ssl.X509TrustManager; +import java.io.InputStream; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.security.cert.CertificateException; +import java.security.cert.X509Certificate; +import java.util.Properties; + +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.times; import static org.powermock.api.easymock.PowerMock.expectPrivate; import static org.powermock.api.easymock.PowerMock.mockStaticPartial; @@ -305,7 +306,7 @@ public X509Certificate[] getAcceptedIssuers() { assertEquals(expected, config.getTrustManagers()[0]); } - @Test(testName = "loadConfiguration") + @Test(testName = "loadConfiguration", enabled = false) public void should_invoke_private_method() throws Exception { // Given Properties propertiesSpy = spy(new Properties()); diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/core/SessionStorageTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/core/SessionStorageTest.java index 2b8fd370..b055ec95 100644 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/core/SessionStorageTest.java +++ b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/core/SessionStorageTest.java @@ -1,6 +1,8 @@ package com.jaspersoft.jasperserver.jaxrs.client.core; +import com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule; import com.jaspersoft.jasperserver.jaxrs.client.filters.SessionOutputFilter; + import java.security.SecureRandom; import java.security.cert.CertificateException; import java.security.cert.X509Certificate; @@ -14,22 +16,24 @@ import javax.ws.rs.client.Invocation; import javax.ws.rs.client.WebTarget; import javax.ws.rs.core.Response; -import org.codehaus.jackson.jaxrs.JacksonJsonProvider; -import org.glassfish.jersey.filter.LoggingFilter; + import org.glassfish.jersey.jackson.JacksonFeature; +import org.glassfish.jersey.jackson.internal.jackson.jaxrs.json.JacksonJsonProvider; +import org.glassfish.jersey.logging.LoggingFeature; import org.glassfish.jersey.media.multipart.MultiPartFeature; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.internal.util.reflection.Whitebox; +import org.powermock.reflect.Whitebox; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.testng.PowerMockTestCase; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyString; -import static org.mockito.Matchers.isA; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.isA; +import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.never; import static org.mockito.Mockito.reset; @@ -44,13 +48,13 @@ import static org.powermock.reflect.internal.WhiteboxImpl.setInternalState; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertNull; /** * Unit tests for {@link com.jaspersoft.jasperserver.jaxrs.client.core.SessionStorage} */ @PrepareForTest({SessionStorage.class, SSLContext.class, - EncryptionUtils.class, ClientBuilder.class, Client.class, WebTarget.class}) @@ -116,6 +120,7 @@ public void should_invoke_init_method_with_default_configuration() throws Except doReturn(null).when(configurationMock).getReadTimeout(); doReturn(targetMock).when(clientMock).target(anyString()); doReturn(targetMock).when(targetMock).register(JacksonFeature.class); + doReturn(targetMock).when(targetMock).register(JaxbAnnotationModule.class); doReturn(targetMock).when(targetMock).register(MultiPartFeature.class); doReturn(targetMock).when(targetMock).register(any(JacksonJsonProvider.class)); doReturn(false).when(configurationMock).getLogHttp(); @@ -132,9 +137,10 @@ public void should_invoke_init_method_with_default_configuration() throws Except verify(configurationMock).getReadTimeout(); verify(clientMock).target("http://54.83.98.156/jasperserver-pro"); verify(targetMock).register(JacksonFeature.class); + verify(targetMock).register(JaxbAnnotationModule.class); verify(targetMock, times(1)).register(isA(JacksonJsonProvider.class)); verify(configurationMock).getLogHttp(); - verify(targetMock, never()).register(LoggingFilter.class); + verify(targetMock, never()).register(LoggingFeature.class); } @Test @@ -151,10 +157,11 @@ public void should_invoke_init_method_with_custom_configuration() throws Excepti doReturn(clientMock).when(clientMock).property("jersey.config.client.readTimeout", 200); doReturn(targetMock).when(clientMock).target(anyString()); doReturn(targetMock).when(targetMock).register(JacksonFeature.class); + doReturn(targetMock).when(targetMock).register(JaxbAnnotationModule.class); doReturn(targetMock).when(targetMock).register(MultiPartFeature.class); doReturn(targetMock).when(targetMock).register(any(JacksonJsonProvider.class)); doReturn(true).when(configurationMock).getLogHttp(); - doReturn(targetMock).when(targetMock).register(any(LoggingFilter.class)); + doReturn(targetMock).when(targetMock).register(any(LoggingFeature.class)); // When SessionStorage sessionStorage = new SessionStorage(configurationMock, credentialsMock, null, null); @@ -170,9 +177,10 @@ public void should_invoke_init_method_with_custom_configuration() throws Excepti verify(clientMock).property("jersey.config.client.readTimeout", 200); verify(clientMock).target("http://54.83.98.156/jasperserver-pro"); verify(targetMock).register(JacksonFeature.class); + verify(targetMock).register(JaxbAnnotationModule.class); verify(targetMock, times(1)).register(isA(JacksonJsonProvider.class)); verify(configurationMock).getLogHttp(); - verify(targetMock).register(isA(LoggingFilter.class)); + verify(targetMock).register(isA(LoggingFeature.class)); } @Test @@ -204,11 +212,12 @@ public void should_return_client_with_configuration() throws Exception { Whitebox.setInternalState(sessionStorage, "sessionId", "sessionId"); doReturn(targetMock).when(clientMock).target(anyString()); doReturn(targetMock).when(targetMock).register(JacksonFeature.class); + doReturn(targetMock).when(targetMock).register(JaxbAnnotationModule.class); doReturn(targetMock).when(targetMock).register(MultiPartFeature.class); doReturn(targetMock).when(targetMock).register(any(JacksonJsonProvider.class)); doReturn(targetMock).when(targetMock).register(any(SessionOutputFilter.class)); doReturn(true).when(configurationMock).getLogHttp(); - doReturn(targetMock).when(targetMock).register(any(LoggingFilter.class)); + doReturn(targetMock).when(targetMock).register(any(LoggingFeature.class)); when(sessionStorage.getConfiguredClient()).thenReturn(targetMock); // When @@ -234,46 +243,7 @@ public void should_create_new_instance_session_storage() throws Exception { assertNotNull(sessionStorageSpy); assertNotNull(Whitebox.getInternalState(sessionStorageSpy, "configuration")); assertNotNull(Whitebox.getInternalState(sessionStorageSpy, "credentials")); - assertEquals(Whitebox.getInternalState(sessionStorageSpy, "sessionId"), null); - } - - /** - * @deprecated test for derprecared constructor*/ - @Test - public void should_create_new_instance_session_storage_by_user_name_password() throws Exception { - - // Given - suppress(method(SessionStorage.class, "init")); - doReturn("http").when(configurationMock).getJasperReportsServerUrl(); - - // When - SessionStorage sessionStorageSpy = new SessionStorage(configurationMock, credentialsMock); - - // Then - assertNotNull(sessionStorageSpy); - assertNotNull(Whitebox.getInternalState(sessionStorageSpy, "configuration")); - assertNotNull(Whitebox.getInternalState(sessionStorageSpy, "credentials")); - assertEquals(Whitebox.getInternalState(sessionStorageSpy, "sessionId"), null); - } - - /** - * @deprecated test for derprecared constructor*/ - @Test - public void should_create_new_instance_session_storage_by_user_name_password_time_zone() throws Exception { - - // Given - suppress(method(SessionStorage.class, "init")); - doReturn("http").when(configurationMock).getJasperReportsServerUrl(); - - // When - SessionStorage sessionStorageSpy = new SessionStorage(configurationMock, credentialsMock, TimeZone.getTimeZone("America/Los_Angeles")); - - // Then - assertNotNull(sessionStorageSpy); - assertNotNull(Whitebox.getInternalState(sessionStorageSpy, "configuration")); - assertNotNull(Whitebox.getInternalState(sessionStorageSpy, "credentials")); - assertEquals(Whitebox.getInternalState(sessionStorageSpy, "sessionId"), null); - assertEquals(Whitebox.getInternalState(sessionStorageSpy, "userTimeZone"), TimeZone.getTimeZone("America/Los_Angeles")); + assertNull(Whitebox.getInternalState(sessionStorageSpy, "sessionId")); } @Test diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/core/SessionTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/core/SessionTest.java index 42901658..189396c7 100644 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/core/SessionTest.java +++ b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/core/SessionTest.java @@ -7,32 +7,31 @@ import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.authority.roles.RolesService; import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.authority.users.UsersService; import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.datadiscovery.DataDiscoveryService; -import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.domain.DomainService; -import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.connections.ConnectionsService; import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.diagnostic.DiagnosticService; +import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.domain.DomainService; import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.importexport.exportservice.ExportService; import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.importexport.importservice.ImportService; import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.inputControls.InputControlsService; import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.jobs.JobsService; import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.permissions.PermissionsService; -import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.query.QueryExecutorService; import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.reporting.ReportingService; import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.resources.ResourcesService; import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.thumbnails.ThumbnailsService; import com.jaspersoft.jasperserver.jaxrs.client.core.enums.AuthenticationType; import com.jaspersoft.jasperserver.jaxrs.client.core.exceptions.RequestedRepresentationNotAvailableForResourceException; -import javax.ws.rs.client.Client; -import javax.ws.rs.client.Invocation.Builder; -import javax.ws.rs.client.WebTarget; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.Response.StatusType; import org.mockito.Mock; import org.mockito.Mockito; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import static org.mockito.Matchers.anyString; +import javax.ws.rs.client.Client; +import javax.ws.rs.client.Invocation.Builder; +import javax.ws.rs.client.WebTarget; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.StatusType; + +import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.never; import static org.mockito.Mockito.reset; @@ -227,7 +226,8 @@ public void should_return_not_null_ExportService_instance() { @Test public void should_return_not_null_ImportService_instance() { // When - Session sessionSpy = Mockito.spy(new Session(storageMock));; + Session sessionSpy = Mockito.spy(new Session(storageMock)); + ; ImportService retrieved = sessionSpy.importService(); // Then assertNotNull(retrieved); @@ -274,16 +274,6 @@ public void should_return_not_null_DomainMetadataService_instance() { verify(sessionSpy, times(1)).getService(DomainService.class); } - @Test - public void should_return_not_null_QueryExecutorService_instance() { - // When - Session sessionSpy = Mockito.spy(new Session(storageMock)); - QueryExecutorService retrieved = sessionSpy.queryExecutorService(); - // Then - assertNotNull(retrieved); - verify(sessionSpy, times(1)).getService(QueryExecutorService.class); - } - @Test public void should_return_not_null_ThumbnailsService_instance() { // When @@ -325,16 +315,6 @@ public void should_return_not_null_DiagnosticService_instance() { verify(sessionSpy, times(1)).getService(DiagnosticService.class); } - @Test - public void should_return_not_null_ConnectionsService_instance() { - // When - Session sessionSpy = Mockito.spy(new Session(storageMock)); - ConnectionsService service = sessionSpy.connectionsService(); - // Then - assertNotNull(service); - verify(sessionSpy, times(1)).getService(ConnectionsService.class); - } - @Test public void should_return_not_null_DataDiscoveryService_instance() { // When @@ -349,7 +329,7 @@ public void should_return_not_null_DataDiscoveryService_instance() { public void should_return_not_null_QueryExecutionService_instance() { // When Session sessionSpy = Mockito.spy(new Session(storageMock)); - QueryExecutionService service = sessionSpy.queryExecutionService(); + QueryExecutionService service = sessionSpy.queryExecutionService(); // Then assertNotNull(service); verify(sessionSpy, times(1)).getService(QueryExecutionService.class); diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/core/ThreadPoolUtilTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/core/ThreadPoolUtilTest.java index 7bf5bd27..85ccc8d7 100644 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/core/ThreadPoolUtilTest.java +++ b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/core/ThreadPoolUtilTest.java @@ -57,7 +57,7 @@ public void should_invoke_static_method_of_class() { ThreadPoolUtil.runAsynchronously(executionTaskMock); /* Then */ - PowerMockito.verifyStatic(Mockito.times(1)); + PowerMockito.verifyStatic(Executors.class, Mockito.times(1)); Executors.newCachedThreadPool(); inOrder.verify(executionTaskMock).getTask(); diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/core/operationresult/NullEntityOperationResultTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/core/operationresult/NullEntityOperationResultTest.java index 8fb44c6d..3e22b899 100644 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/core/operationresult/NullEntityOperationResultTest.java +++ b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/core/operationresult/NullEntityOperationResultTest.java @@ -5,7 +5,7 @@ import javax.ws.rs.core.Response; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.internal.util.reflection.Whitebox; +import org.powermock.reflect.Whitebox; import org.powermock.modules.testng.PowerMockTestCase; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/core/operationresult/OperationResultFactoryImplTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/core/operationresult/OperationResultFactoryImplTest.java index 35e20669..363c9a24 100644 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/core/operationresult/OperationResultFactoryImplTest.java +++ b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/core/operationresult/OperationResultFactoryImplTest.java @@ -18,7 +18,7 @@ import static java.util.Arrays.asList; import static org.hamcrest.core.IsInstanceOf.instanceOf; -import static org.mockito.Matchers.anyString; +import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.times; import static org.testng.Assert.assertNotNull; @@ -112,7 +112,7 @@ public void should_invoke_private_method_getSpecificResourceType() throws Except /* Then */ assertNotNull(retrievedResult); - PowerMockito.verifyStatic(times(1)); + PowerMockito.verifyStatic(ResourcesTypeResolverUtil.class, times(1)); ResourcesTypeResolverUtil.getClassForMime(anyString()); } diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/CalendarTriggerTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/CalendarTriggerTest.java deleted file mode 100644 index 74cd4c34..00000000 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/CalendarTriggerTest.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.jaspersoft.jasperserver.jaxrs.client.dto.jobs; - -import java.util.Date; -import java.util.TreeSet; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import static java.util.Arrays.asList; -import static org.testng.Assert.assertEquals; - -/** - *

- *

- * - * @author tetiana.iefimenko - * @version $Id$ - * @see - */ -public class CalendarTriggerTest { - - private CalendarTrigger calendarTrigger = new CalendarTrigger(); - - @BeforeMethod - public void before() { - - calendarTrigger. - setMinutes("1-10"). - setHours("8-16"). - setDaysType(CalendarDaysType.ALL). - setWeekDays(new TreeSet(asList((byte) 10, (byte) 21, (byte) 12))). - setMonthDays("1,3,5-22"). - setMonths(new TreeSet(asList((byte)1, (byte)11, (byte)12))). - setCalendarName("Calendar name"). - setEndDate(new Date()). - setId(Long.valueOf(1000)). - setMisfireInstruction(0). - setStartDate(new Date()). - setStartType(1). - setTimezone("Some time zone"). - setVersion(1); - } - - @Test - public void should_clone_object() { - CalendarTrigger cloned = (CalendarTrigger) calendarTrigger.deepClone(); - assertEquals(cloned, calendarTrigger); - } -} \ No newline at end of file diff --git a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/SimpleTriggerTest.java b/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/SimpleTriggerTest.java deleted file mode 100644 index 05964541..00000000 --- a/src/test/java/com/jaspersoft/jasperserver/jaxrs/client/dto/jobs/SimpleTriggerTest.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.jaspersoft.jasperserver.jaxrs.client.dto.jobs; - -import java.util.Date; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import static org.testng.Assert.assertEquals; - - -/** - *

- *

- * - * @author tetiana.iefimenko - * @version $Id$ - * @see - */ -public class SimpleTriggerTest { - - private SimpleTrigger simpleTrigger = new SimpleTrigger(); - - @BeforeMethod - public void before() { - - simpleTrigger. - setOccurrenceCount(10). - setRecurrenceInterval(20). - setRecurrenceIntervalUnit(IntervalUnitType.DAY). - setCalendarName("Calendar name"). - setEndDate(new Date()). - setId(Long.valueOf(1000)). - setMisfireInstruction(10). - setStartDate(new Date()). - setStartType(1). - setTimezone("Some time zone"). - setVersion(1); - } - - @Test - public void should_clone_object() { - SimpleTrigger cloned = (SimpleTrigger) simpleTrigger.deepClone(); - - assertEquals(cloned, simpleTrigger); - } - -} \ No newline at end of file