RM-4488 (Refactor REST API Automation test code according to the latest changes)

This commit is contained in:
Tuna Aksoy
2016-12-27 23:50:48 +00:00
parent 8876f48c1e
commit 8dcd78653a
12 changed files with 254 additions and 273 deletions

View File

@@ -0,0 +1,87 @@
/*
* #%L
* Alfresco Records Management Module
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* -
* Alfresco 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 Lesser General Public License for more details.
* -
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.rest.core;
import org.alfresco.rest.rm.community.requests.igCoreAPI.FilePlanComponentAPI;
import org.alfresco.rest.rm.community.requests.igCoreAPI.RMSiteAPI;
import org.alfresco.rest.rm.community.requests.igCoreAPI.RestIGCoreAPI;
import org.alfresco.utility.data.DataUser;
import org.alfresco.utility.model.UserModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
/**
* REST API Factory Implementation
*
* @author Tuna Aksoy
* @since 2.6
*/
@Service
@Scope(value = "prototype")
public class RestAPIFactory
{
@Autowired
private DataUser dataUser;
@Autowired
private RMRestWrapper rmRestWrapper;
/**
* @return the rmRestWrapper
*/
public RMRestWrapper getRmRestWrapper()
{
return this.rmRestWrapper;
}
private RestIGCoreAPI getRestIGCoreAPI(UserModel userModel)
{
getRmRestWrapper().authenticateUser(userModel != null ? userModel : dataUser.getAdminUser());
return getRmRestWrapper().withIGCoreAPI();
}
public RMSiteAPI getRMSiteAPI()
{
return getRestIGCoreAPI(null).usingRMSite();
}
public RMSiteAPI getRMSiteAPI(UserModel userModel)
{
return getRestIGCoreAPI(userModel).usingRMSite();
}
public FilePlanComponentAPI getFilePlanComponentsAPI()
{
return getRestIGCoreAPI(null).usingFilePlanComponents();
}
public FilePlanComponentAPI getFilePlanComponentsAPI(UserModel userModel)
{
return getRestIGCoreAPI(userModel).usingFilePlanComponents();
}
}

View File

@@ -44,9 +44,6 @@ import org.alfresco.rest.rm.community.requests.RMModelRequest;
*/
public class RestIGCoreAPI extends RMModelRequest
{
@SuppressWarnings("unused")
private RMRestProperties rmRestProperties;
/**
* Constructor
*
@@ -56,7 +53,6 @@ public class RestIGCoreAPI extends RMModelRequest
public RestIGCoreAPI(RMRestWrapper rmRestWrapper, RMRestProperties rmRestProperties)
{
super(rmRestWrapper);
this.rmRestProperties = rmRestProperties;
RestAssured.baseURI = format("%s://%s", rmRestProperties.getScheme(), rmRestProperties.getServer());
RestAssured.port = parseInt(rmRestProperties.getPort());
RestAssured.basePath = rmRestProperties.getRestRmPath();