diff --git a/pom.xml b/pom.xml
index 60afc118..d06b3979 100644
--- a/pom.xml
+++ b/pom.xml
@@ -162,6 +162,9 @@
java.util.logging.*
edu.tamu.app.config.AppEmailConfig
+
+ **/ProjectInitialization.class
+
html
@@ -173,6 +176,11 @@
org.jacoco
jacoco-maven-plugin
+
+
+ **/ProjectInitialization.class
+
+
prepare-agent
diff --git a/src/main/java/edu/tamu/app/ProjectInitialization.java b/src/main/java/edu/tamu/app/ProjectInitialization.java
index 41e92f7c..0247aab6 100644
--- a/src/main/java/edu/tamu/app/ProjectInitialization.java
+++ b/src/main/java/edu/tamu/app/ProjectInitialization.java
@@ -2,6 +2,7 @@
import java.util.Arrays;
import java.util.HashSet;
+import java.util.Optional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
@@ -29,6 +30,14 @@ public class ProjectInitialization implements CommandLineRunner {
@Override
public void run(String... args) throws Exception {
remoteProjectManagerRepo.findAll().forEach(versionManagementSoftware -> {
+ if (Optional.ofNullable( versionManagementSoftware.getUrl()).isPresent()) {
+ return;
+ }
+
+ if (Optional.ofNullable( versionManagementSoftware.getToken()).isPresent()) {
+ return;
+ }
+
managementBeanRegistry.register(versionManagementSoftware);
});
CardType type = cardTypeRepo.findByIdentifier("Feature");
diff --git a/src/main/java/edu/tamu/app/mapping/StatusMappingService.java b/src/main/java/edu/tamu/app/mapping/StatusMappingService.java
index d1420184..6f5414f7 100644
--- a/src/main/java/edu/tamu/app/mapping/StatusMappingService.java
+++ b/src/main/java/edu/tamu/app/mapping/StatusMappingService.java
@@ -10,7 +10,7 @@ public class StatusMappingService extends AbstractRepoMappingService settings;
+ @Column
+ @JsonView(ApiView.Partial.class)
+ protected String url;
+
+ @Column
+ @JsonView(ApiView.Partial.class)
+ @Convert(converter = CryptoConverter.class)
+ protected String token;
public ManagementService() {
super();
modelValidator = new ManagementServiceValidator();
- settings = new HashMap();
}
- public ManagementService(String name, ServiceType type) {
+ public ManagementService(String name, ServiceType type, String url, String token) {
this();
this.name = name;
this.type = type;
- }
-
- public ManagementService(String name, ServiceType type, Map settings) {
- this(name, type);
- this.settings = settings;
+ this.url = url;
+ this.token = token;
}
public String getName() {
@@ -71,23 +65,20 @@ public void setType(ServiceType type) {
this.type = type;
}
- public Map getSettings() {
- return settings;
+ public String getUrl() {
+ return url;
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
}
- public void setSettings(HashMap settings) {
- this.settings = settings;
+ public String getToken() {
+ return token;
}
- public Optional getSettingValue(String key) {
- Optional targetSetting = Optional.empty();
- for (Map.Entry setting : settings.entrySet()) {
- if (setting.getKey().equals(key)) {
- targetSetting = Optional.of(setting.getValue());
- break;
- }
- }
- return targetSetting;
+ public void setToken(String token) {
+ this.token = token;
}
}
diff --git a/src/main/java/edu/tamu/app/model/Product.java b/src/main/java/edu/tamu/app/model/Product.java
index 9fe189b0..058f202d 100644
--- a/src/main/java/edu/tamu/app/model/Product.java
+++ b/src/main/java/edu/tamu/app/model/Product.java
@@ -7,9 +7,12 @@
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.FetchType;
-
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
+
+import org.hibernate.annotations.LazyCollection;
+import org.hibernate.annotations.LazyCollectionOption;
+
import com.fasterxml.jackson.annotation.JsonView;
import edu.tamu.app.model.validation.ProductValidator;
@@ -48,6 +51,12 @@ public class Product extends ValidatingBaseEntity {
@JsonView(ApiView.Partial.class)
private String wikiUrl;
+ @LazyCollection(LazyCollectionOption.FALSE)
+ @ElementCollection
+ @JsonInclude(Include.NON_NULL)
+ @JsonView(ApiView.Partial.class)
+ private List otherUrls;
+
@ElementCollection(fetch = FetchType.EAGER)
@JsonView(ApiView.Partial.class)
private List remoteProjectInfo;
@@ -68,7 +77,7 @@ public Product(String name, List remoteProjectInfo) {
this.remoteProjectInfo = remoteProjectInfo;
}
- public Product(String name, List remoteProjectInfo, String scopeId, String devUrl, String preUrl, String productionUrl, String wikiUrl) {
+ public Product(String name, List remoteProjectInfo, String scopeId, String devUrl, String preUrl, String productionUrl, String wikiUrl, List otherUrls) {
this();
this.name = name;
this.remoteProjectInfo = remoteProjectInfo;
@@ -77,6 +86,7 @@ public Product(String name, List remoteProjectInfo, String sc
this.preUrl = preUrl;
this.productionUrl = productionUrl;
this.wikiUrl = wikiUrl;
+ this.otherUrls = otherUrls;
}
public String getName() {
@@ -127,6 +137,24 @@ public void setWikiUrl(String wikiUrl) {
this.wikiUrl = wikiUrl;
}
+ public List getOtherUrls() {
+ return otherUrls;
+ }
+
+ public void setOtherUrls(List otherUrls) {
+ this.otherUrls = otherUrls;
+ }
+
+ public void addOtherUrl(String otherUrl) {
+ this.otherUrls.add(otherUrl);
+ }
+
+ public void removeOtherUrl(String otherUrl) {
+ this.otherUrls = this.otherUrls.stream()
+ .filter(o -> !o.equals(otherUrl))
+ .collect(Collectors.toList());
+ }
+
public List getRemoteProjectInfo() {
return remoteProjectInfo;
}
diff --git a/src/main/java/edu/tamu/app/model/RemoteProjectManager.java b/src/main/java/edu/tamu/app/model/RemoteProjectManager.java
index 92d68f71..03c64505 100644
--- a/src/main/java/edu/tamu/app/model/RemoteProjectManager.java
+++ b/src/main/java/edu/tamu/app/model/RemoteProjectManager.java
@@ -1,7 +1,5 @@
package edu.tamu.app.model;
-import java.util.Map;
-
import javax.persistence.Entity;
@Entity
@@ -11,12 +9,8 @@ public RemoteProjectManager() {
super();
}
- public RemoteProjectManager(String name, ServiceType type) {
- super(name, type);
- }
-
- public RemoteProjectManager(String name, ServiceType type, Map settings) {
- super(name, type, settings);
+ public RemoteProjectManager(String name, ServiceType type, String url, String token) {
+ super(name, type, url, token);
}
}
diff --git a/src/main/java/edu/tamu/app/model/ServiceType.java b/src/main/java/edu/tamu/app/model/ServiceType.java
index c9a3f199..a0130dac 100644
--- a/src/main/java/edu/tamu/app/model/ServiceType.java
+++ b/src/main/java/edu/tamu/app/model/ServiceType.java
@@ -40,6 +40,9 @@ public List getScaffold() {
List scaffold = new ArrayList();
switch (this) {
case GITHUB:
+ scaffold.add(new Setting("text", "url", "URL", true));
+ scaffold.add(new Setting("password", "token", "Token", false));
+ break;
case VERSION_ONE:
scaffold.add(new Setting("text", "url", "URL", true));
scaffold.add(new Setting("text", "username", "Username", false));
diff --git a/src/main/java/edu/tamu/app/model/validation/ManagementServiceValidator.java b/src/main/java/edu/tamu/app/model/validation/ManagementServiceValidator.java
index 14be48fe..134c161f 100644
--- a/src/main/java/edu/tamu/app/model/validation/ManagementServiceValidator.java
+++ b/src/main/java/edu/tamu/app/model/validation/ManagementServiceValidator.java
@@ -12,5 +12,11 @@ public ManagementServiceValidator() {
String typeProperty = "type";
this.addInputValidator(new InputValidator(InputValidationType.required, "A Management service requires a type", typeProperty, true));
+
+ String urlProperty = "url";
+ this.addInputValidator(new InputValidator(InputValidationType.required, "A Remote Project Manager requires a URL", urlProperty, true));
+
+ String tokenProperty = "token";
+ this.addInputValidator(new InputValidator(InputValidationType.required, "A Remote Project Manager requires a token", tokenProperty, true));
}
}
diff --git a/src/main/java/edu/tamu/app/rest/BasicAuthInterceptor.java b/src/main/java/edu/tamu/app/rest/BasicAuthInterceptor.java
deleted file mode 100644
index 5d42276a..00000000
--- a/src/main/java/edu/tamu/app/rest/BasicAuthInterceptor.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package edu.tamu.app.rest;
-
-import java.io.IOException;
-import java.util.Base64;
-
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.HttpRequest;
-import org.springframework.http.client.ClientHttpRequestExecution;
-import org.springframework.http.client.ClientHttpRequestInterceptor;
-import org.springframework.http.client.ClientHttpResponse;
-
-public class BasicAuthInterceptor implements ClientHttpRequestInterceptor {
-
- private String username;
- private String password;
-
- public BasicAuthInterceptor(String username, String password) {
- this.username = username;
- this.password = password;
- }
-
- @Override
- public ClientHttpResponse intercept(HttpRequest httpRequest, byte[] bytes, ClientHttpRequestExecution clientHttpRequestExecution) throws IOException {
- HttpHeaders headers = httpRequest.getHeaders();
- headers.add(HttpHeaders.AUTHORIZATION, encodeCredentialsForBasicAuth(username, password));
- return clientHttpRequestExecution.execute(httpRequest, bytes);
- }
-
- public static String encodeCredentialsForBasicAuth(String username, String password) {
- return "Basic " + Base64.getEncoder().encodeToString((username + ":" + password).getBytes());
- }
-
-}
\ No newline at end of file
diff --git a/src/main/java/edu/tamu/app/rest/BasicAuthRestTemplate.java b/src/main/java/edu/tamu/app/rest/BasicAuthRestTemplate.java
deleted file mode 100644
index effcdada..00000000
--- a/src/main/java/edu/tamu/app/rest/BasicAuthRestTemplate.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package edu.tamu.app.rest;
-
-import java.util.Collections;
-
-import org.springframework.http.client.InterceptingClientHttpRequestFactory;
-import org.springframework.util.StringUtils;
-import org.springframework.web.client.RestTemplate;
-
-public class BasicAuthRestTemplate extends RestTemplate {
-
- private final String username;
-
- private final String password;
-
- public BasicAuthRestTemplate(String username, String password) {
- super();
- this.username = username;
- this.password = password;
-
- if (StringUtils.isEmpty(username)) {
- throw new RuntimeException("Username is mandatory for Basic Auth");
- }
-
- setRequestFactory(new InterceptingClientHttpRequestFactory(getRequestFactory(), Collections.singletonList(new BasicAuthInterceptor(username, password))));
- }
-
- public String getUsername() {
- return username;
- }
-
- public String getPassword() {
- return password;
- }
-
-}
diff --git a/src/main/java/edu/tamu/app/service/manager/GitHubService.java b/src/main/java/edu/tamu/app/service/manager/GitHubService.java
index 025228fc..8825e7fd 100644
--- a/src/main/java/edu/tamu/app/service/manager/GitHubService.java
+++ b/src/main/java/edu/tamu/app/service/manager/GitHubService.java
@@ -12,7 +12,6 @@
import java.util.Map;
import java.util.Optional;
-import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.kohsuke.github.GHIssue;
import org.kohsuke.github.GHIssueState;
@@ -40,7 +39,6 @@
import edu.tamu.app.cache.model.Sprint;
import edu.tamu.app.model.ManagementService;
import edu.tamu.app.model.request.FeatureRequest;
-import edu.tamu.app.rest.BasicAuthRestTemplate;
import edu.tamu.app.rest.TokenAuthRestTemplate;
public class GitHubService extends MappingRemoteProjectManagerBean {
@@ -124,48 +122,37 @@ public List getAdditionalActiveSprints() throws Exception {
}
@Override
- public Object push(final FeatureRequest request) throws Exception {
+ public String push(final FeatureRequest request) throws Exception {
logger.info("Submitting feature request " + request.getTitle() + " to product with scope id " + request.getScopeId());
- String repoId = String.valueOf(request.getProductId());
+
+ String scopeId = String.valueOf(request.getScopeId());
String title = request.getTitle();
String body = request.getDescription();
- GHRepository repo = github.getRepositoryById(repoId);
- return repo.createIssue(title).body(body).create();
+ GHRepository repo = github.getRepositoryById(scopeId);
+
+ return Long.toString(repo.createIssue(title).body(body).create().getId());
}
protected GitHub getGitHubInstance() throws IOException {
- GitHub githubInstance;
- final Optional endpoint = managementService.getSettingValue("url");
- final Optional token = managementService.getSettingValue("token");
+ final Optional endpoint = Optional.of(managementService.getUrl());
+ final Optional token = Optional.of(managementService.getToken());
+
if (!endpoint.isPresent()) {
- throw new RuntimeException("GitHub service enpoint was not defined");
+ throw new RuntimeException("GitHub service endpoint was not defined");
}
- if (token.isPresent()) {
- githubInstance = ghBuilder
- .withEndpoint(endpoint.get())
- .withOAuthToken(token.get())
- .build();
- } else {
- githubInstance = ghBuilder
- .withEndpoint(endpoint.get())
- .withPassword(getSettingValue("username"), getSettingValue("password"))
- .build();
- }
- return githubInstance;
- }
- private String getSettingValue(final String key) {
- final Optional setting = managementService.getSettingValue(key);
- if (setting.isPresent()) {
- return setting.get();
- } else {
- return null;
+ if (!token.isPresent()) {
+ throw new RuntimeException("GitHub token was not defined");
}
+
+ return ghBuilder
+ .withEndpoint(endpoint.get())
+ .withOAuthToken(token.get())
+ .build();
}
private RestTemplate getRestTemplate() {
- String token = getSettingValue("token");
- return StringUtils.isNotBlank(token) ? new TokenAuthRestTemplate(token) : new BasicAuthRestTemplate(getSettingValue("username"), getSettingValue("password"));
+ return new TokenAuthRestTemplate(managementService.getToken());
}
private RemoteProject buildRemoteProject(GHRepository repo, List labels) throws IOException {
diff --git a/src/main/java/edu/tamu/app/service/manager/RemoteProjectManagerBean.java b/src/main/java/edu/tamu/app/service/manager/RemoteProjectManagerBean.java
index 03e2e248..5fab8a4c 100644
--- a/src/main/java/edu/tamu/app/service/manager/RemoteProjectManagerBean.java
+++ b/src/main/java/edu/tamu/app/service/manager/RemoteProjectManagerBean.java
@@ -17,6 +17,6 @@ public interface RemoteProjectManagerBean extends ManagementBean {
public List getAdditionalActiveSprints() throws Exception;
- public Object push(final FeatureRequest request) throws Exception;
+ public String push(final FeatureRequest request) throws Exception;
}
diff --git a/src/main/java/edu/tamu/app/service/manager/VersionOneService.java b/src/main/java/edu/tamu/app/service/manager/VersionOneService.java
index d8914068..a89634aa 100644
--- a/src/main/java/edu/tamu/app/service/manager/VersionOneService.java
+++ b/src/main/java/edu/tamu/app/service/manager/VersionOneService.java
@@ -27,6 +27,7 @@
import com.versionone.apiclient.Query;
import com.versionone.apiclient.Services;
import com.versionone.apiclient.V1Connector;
+import com.versionone.apiclient.V1Connector.ISetUserAgentMakeRequest;
import com.versionone.apiclient.exceptions.APIException;
import com.versionone.apiclient.exceptions.ConnectionException;
import com.versionone.apiclient.exceptions.OidException;
@@ -45,7 +46,6 @@
import edu.tamu.app.cache.model.Sprint;
import edu.tamu.app.model.ManagementService;
import edu.tamu.app.model.request.FeatureRequest;
-import edu.tamu.app.rest.BasicAuthRestTemplate;
import edu.tamu.app.rest.TokenAuthRestTemplate;
public class VersionOneService extends MappingRemoteProjectManagerBean {
@@ -269,7 +269,7 @@ public Member getMember(final String id) throws ConnectionException, APIExceptio
}
@Override
- public Object push(FeatureRequest featureRequest) throws V1Exception {
+ public String push(FeatureRequest featureRequest) throws V1Exception {
logger.info("Submitting feature request " + featureRequest.getTitle() + " to product with scope id " + featureRequest.getScopeId());
IAssetType requestType = services.getMeta().getAssetType("Request");
IAttributeDefinition nameAttributeDefinition = requestType.getAttributeDefinition("Name");
@@ -286,7 +286,7 @@ public Object push(FeatureRequest featureRequest) throws V1Exception {
services.save(request);
- return request;
+ return request.getOid().getToken();
}
private void clearMembers() {
@@ -330,55 +330,19 @@ private void storeAvatar(String avatarPath) throws IOException {
}
private String getUrl() {
- String url = getSettingValue("url");
+ String url = managementService.getUrl();
return url.endsWith("/") ? url.substring(0, url.length() - 1) : url;
}
private V1Connector buildConnector() throws MalformedURLException, V1Exception {
- Optional token = getToken();
- V1Connector connector;
- if (token.isPresent()) {
- // @formatter:off
- connector = V1Connector.withInstanceUrl(getUrl())
- .withUserAgentHeader("Product Management Service",
- "1.0")
- .withAccessToken(getToken().get())
- .build();
- // @formatter:on
- } else {
- // @formatter:off
- connector = V1Connector.withInstanceUrl(getUrl())
- .withUserAgentHeader("Product Management Service", "1.0")
- .withUsernameAndPassword(getUsername(), getPassword())
- .build();
- // @formatter:on
- }
- return connector;
- }
-
- private RestTemplate getRestTemplate() {
- Optional token = getToken();
- return token.isPresent() ? new TokenAuthRestTemplate(token.get()) : new BasicAuthRestTemplate(getUsername(), getPassword());
- }
+ ISetUserAgentMakeRequest request = V1Connector.withInstanceUrl(getUrl());
- private String getUsername() {
- return getSettingValue("username");
+ return request.withUserAgentHeader("Product Management Service", "1.0")
+ .withAccessToken(managementService.getToken()).build();
}
- private String getPassword() {
- return getSettingValue("password");
- }
-
- private Optional getToken() {
- return managementService.getSettingValue("token");
- }
-
- private String getSettingValue(String key) {
- Optional setting = managementService.getSettingValue(key);
- if (setting.isPresent()) {
- return setting.get();
- }
- throw new RuntimeException("No setting " + key + " found in settings for service " + managementService.getName());
+ private RestTemplate getRestTemplate() {
+ return new TokenAuthRestTemplate(managementService.getToken());
}
}
\ No newline at end of file
diff --git a/src/test/java/edu/tamu/app/cache/service/ActiveSprintsScheduledCacheServiceTest.java b/src/test/java/edu/tamu/app/cache/service/ActiveSprintsScheduledCacheServiceTest.java
index e702b090..0c7b36ca 100644
--- a/src/test/java/edu/tamu/app/cache/service/ActiveSprintsScheduledCacheServiceTest.java
+++ b/src/test/java/edu/tamu/app/cache/service/ActiveSprintsScheduledCacheServiceTest.java
@@ -10,7 +10,6 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.HashMap;
import java.util.List;
import org.junit.Before;
@@ -42,8 +41,14 @@ public class ActiveSprintsScheduledCacheServiceTest {
private static final String TEST_PROJECT_SCOPE1 = "0010";
private static final String TEST_PROJECT_SCOPE2 = "0020";
- private static final RemoteProjectManager TEST_REMOTE_PROJECT_MANAGER1 = new RemoteProjectManager("Test Remote Project Manager 1", ServiceType.VERSION_ONE, new HashMap());
- private static final RemoteProjectManager TEST_REMOTE_PROJECT_MANAGER2 = new RemoteProjectManager("Test Remote Project Manager 2", ServiceType.GITHUB, new HashMap());
+ private static final String TEST_PROJECT_URL1 = "http://localhost/1";
+ private static final String TEST_PROJECT_URL2 = "http://localhost/2";
+
+ private static final String TEST_PROJECT_TOKEN1 = "0123456789";
+ private static final String TEST_PROJECT_TOKEN2 = "9876543210";
+
+ private static final RemoteProjectManager TEST_REMOTE_PROJECT_MANAGER1 = new RemoteProjectManager("Test Remote Project Manager 1", ServiceType.VERSION_ONE, TEST_PROJECT_URL1, TEST_PROJECT_TOKEN1);
+ private static final RemoteProjectManager TEST_REMOTE_PROJECT_MANAGER2 = new RemoteProjectManager("Test Remote Project Manager 2", ServiceType.GITHUB, TEST_PROJECT_URL2, TEST_PROJECT_TOKEN2);
private static final RemoteProjectInfo TEST_REMOTE_PROJECT_INFO1 = new RemoteProjectInfo(TEST_PROJECT_SCOPE1, TEST_REMOTE_PROJECT_MANAGER1);
private static final RemoteProjectInfo TEST_REMOTE_PROJECT_INFO2 = new RemoteProjectInfo(TEST_PROJECT_SCOPE2, TEST_REMOTE_PROJECT_MANAGER2);
diff --git a/src/test/java/edu/tamu/app/cache/service/ProductsStatsScheduledCacheServiceTest.java b/src/test/java/edu/tamu/app/cache/service/ProductsStatsScheduledCacheServiceTest.java
index 11f02b24..59fe8198 100644
--- a/src/test/java/edu/tamu/app/cache/service/ProductsStatsScheduledCacheServiceTest.java
+++ b/src/test/java/edu/tamu/app/cache/service/ProductsStatsScheduledCacheServiceTest.java
@@ -9,7 +9,6 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.HashMap;
import java.util.List;
import java.util.Optional;
@@ -41,7 +40,11 @@ public class ProductsStatsScheduledCacheServiceTest {
private static final String TEST_PROJECT_SCOPE = "0010";
- private static final RemoteProjectManager TEST_REMOTE_PROJECT_MANAGER = new RemoteProjectManager("Test Remote Project Manager", ServiceType.VERSION_ONE, new HashMap());
+ private static final String TEST_PROJECT_URL1 = "http://localhost/1";
+
+ private static final String TEST_PROJECT_TOKEN1 = "0123456789";
+
+ private static final RemoteProjectManager TEST_REMOTE_PROJECT_MANAGER = new RemoteProjectManager("Test Remote Project Manager", ServiceType.VERSION_ONE, TEST_PROJECT_URL1, TEST_PROJECT_TOKEN1);
private static final RemoteProjectInfo TEST_REMOTE_PROJECT_INFO = new RemoteProjectInfo(TEST_PROJECT_SCOPE, TEST_REMOTE_PROJECT_MANAGER);
diff --git a/src/test/java/edu/tamu/app/cache/service/RemoteProjectsScheduledCacheServiceTest.java b/src/test/java/edu/tamu/app/cache/service/RemoteProjectsScheduledCacheServiceTest.java
index a62ce9aa..bea61f2f 100644
--- a/src/test/java/edu/tamu/app/cache/service/RemoteProjectsScheduledCacheServiceTest.java
+++ b/src/test/java/edu/tamu/app/cache/service/RemoteProjectsScheduledCacheServiceTest.java
@@ -39,6 +39,10 @@
@RunWith(SpringRunner.class)
public class RemoteProjectsScheduledCacheServiceTest {
+ private static final String TEST_PROJECT_URL1 = "http://localhost/1";
+
+ private static final String TEST_PROJECT_TOKEN1 = "0123456789";
+
@Mock
private RemoteProjectManagerRepo remoteProjectManagerRepo;
@@ -103,7 +107,7 @@ public void testGetRemoteProduct() {
}
private RemoteProjectManager getMockRemoteProductManager() {
- RemoteProjectManager remoteProjectManager = new RemoteProjectManager("Test Remote Project Manager", ServiceType.VERSION_ONE);
+ RemoteProjectManager remoteProjectManager = new RemoteProjectManager("Test Remote Project Manager", ServiceType.VERSION_ONE, TEST_PROJECT_URL1, TEST_PROJECT_TOKEN1);
remoteProjectManager.setId(1L);
return remoteProjectManager;
}
diff --git a/src/test/java/edu/tamu/app/controller/InternalRequestControllerTest.java b/src/test/java/edu/tamu/app/controller/InternalRequestControllerTest.java
index 102dbd6b..28780cb1 100644
--- a/src/test/java/edu/tamu/app/controller/InternalRequestControllerTest.java
+++ b/src/test/java/edu/tamu/app/controller/InternalRequestControllerTest.java
@@ -12,7 +12,6 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
-import java.util.HashMap;
import java.util.List;
import org.junit.Before;
@@ -56,7 +55,11 @@ public class InternalRequestControllerTest {
private static final String TEST_PROJECT1_SCOPE1 = "0010";
private static final String TEST_PROJECT1_SCOPE2 = "0011";
- private static final RemoteProjectManager TEST_REMOTE_PROJECT_MANAGER = new RemoteProjectManager("Test Remote Project Manager", ServiceType.VERSION_ONE, new HashMap());
+ private static final String TEST_PROJECT_URL1 = "http://localhost/1";
+
+ private static final String TEST_PROJECT_TOKEN1 = "0123456789";
+
+ private static final RemoteProjectManager TEST_REMOTE_PROJECT_MANAGER = new RemoteProjectManager("Test Remote Project Manager", ServiceType.VERSION_ONE, TEST_PROJECT_URL1, TEST_PROJECT_TOKEN1);
private static final RemoteProjectInfo TEST_REMOTE_PROJECT_INFO1 = new RemoteProjectInfo(TEST_PROJECT1_SCOPE1, TEST_REMOTE_PROJECT_MANAGER);
private static final RemoteProjectInfo TEST_REMOTE_PROJECT_INFO2 = new RemoteProjectInfo(TEST_PROJECT1_SCOPE2, TEST_REMOTE_PROJECT_MANAGER);
@@ -123,7 +126,7 @@ public void setup() throws Exception {
when(internalRequestRepo.countByProductIsNull()).thenReturn(1L);
when(internalRequestRepo.create(any(InternalRequest.class))).thenReturn(TEST_REQUEST_BELLS);
when(internalRequestRepo.update(any(InternalRequest.class))).thenReturn(TEST_REQUEST_BELLS);
- when(remoteProjectManagementBean.push(any(FeatureRequest.class))).thenReturn(TEST_FEATURE_REQUEST);
+ when(remoteProjectManagementBean.push(any(FeatureRequest.class))).thenReturn("1");
when(managementBeanRegistry.getService(any(String.class))).thenReturn(remoteProjectManagementBean);
doAnswer(new Answer() {
diff --git a/src/test/java/edu/tamu/app/controller/ProductControllerIntegrationTest.java b/src/test/java/edu/tamu/app/controller/ProductControllerIntegrationTest.java
index 7d1a7910..ee6b256c 100644
--- a/src/test/java/edu/tamu/app/controller/ProductControllerIntegrationTest.java
+++ b/src/test/java/edu/tamu/app/controller/ProductControllerIntegrationTest.java
@@ -6,7 +6,6 @@
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
import org.junit.After;
@@ -33,6 +32,10 @@
public class ProductControllerIntegrationTest {
private static final String TEST_PRODUCT_SCOPE1 = "0010";
+ private static final String TEST_PROJECT_URL1 = "http://localhost/1";
+
+ private static final String TEST_PROJECT_TOKEN1 = "0123456789";
+
@Autowired
private MockMvc mockMvc;
@@ -45,15 +48,8 @@ public class ProductControllerIntegrationTest {
@Before
public void setup() {
RemoteProjectManager remoteProjectManager = remoteProjectManagerRepo.create(
- new RemoteProjectManager("VersionTwo", ServiceType.VERSION_ONE, new HashMap() {
- private static final long serialVersionUID = 2020874481642498006L;
- {
- put("url", "https://localhost:9101/TexasAMLibrary");
- put("username", "username");
- put("password", "password");
- }
- }
- ));
+ new RemoteProjectManager("VersionTwo", ServiceType.VERSION_ONE, TEST_PROJECT_URL1, TEST_PROJECT_TOKEN1)
+ );
RemoteProjectInfo remoteProjectInfo = new RemoteProjectInfo(TEST_PRODUCT_SCOPE1, remoteProjectManager);
diff --git a/src/test/java/edu/tamu/app/controller/ProductControllerTest.java b/src/test/java/edu/tamu/app/controller/ProductControllerTest.java
index cd55b910..96e67a56 100644
--- a/src/test/java/edu/tamu/app/controller/ProductControllerTest.java
+++ b/src/test/java/edu/tamu/app/controller/ProductControllerTest.java
@@ -12,7 +12,6 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
-import java.util.HashMap;
import java.util.List;
import org.junit.Before;
@@ -57,6 +56,10 @@ public class ProductControllerTest {
private static final String TEST_PROJECT1_SCOPE2 = "0011";
private static final String TEST_INVALID_SCOPE = "XXXX";
+ private static final String TEST_PROJECT_URL1 = "http://localhost/1";
+
+ private static final String TEST_PROJECT_TOKEN1 = "0123456789";
+
private static final String TEST_FEATURE_REQUEST_TITLE = "Test Feature Request Title";
private static final String TEST_FEATURE_REQUEST_DESCRIPTION = "Test Feature Request Description";
private static final String TEST_RMP_ONE_NAME = "Test Remote Project Manager 1";
@@ -66,7 +69,7 @@ public class ProductControllerTest {
private static final String INVALID_RPM_ID_ERROR_MESSAGE = "Error fetching remote projects from " + TEST_RMP_ONE_NAME + "!";
private static final String MISSING_RPM_ERROR_MESSAGE = "Remote Project Manager with id null not found!";
- private static final RemoteProjectManager TEST_REMOTE_PROJECT_MANAGER = new RemoteProjectManager("Test Remote Project Manager", ServiceType.VERSION_ONE, new HashMap());
+ private static final RemoteProjectManager TEST_REMOTE_PROJECT_MANAGER = new RemoteProjectManager("Test Remote Project Manager", ServiceType.VERSION_ONE, TEST_PROJECT_URL1, TEST_PROJECT_TOKEN1);
private static final RemoteProjectInfo TEST_REMOTE_PROJECT_INFO1 = new RemoteProjectInfo(TEST_PROJECT1_SCOPE1, TEST_REMOTE_PROJECT_MANAGER);
private static final RemoteProjectInfo TEST_REMOTE_PROJECT_INFO2 = new RemoteProjectInfo(TEST_PROJECT1_SCOPE2, TEST_REMOTE_PROJECT_MANAGER);
@@ -80,7 +83,7 @@ public class ProductControllerTest {
private static Product TEST_PRODUCT2 = new Product(TEST_PRODUCT2_NAME);
private static Product TEST_MODIFIED_PRODUCT = new Product(TEST_MODIFIED_PRODUCT_NAME);
- private static RemoteProjectManager testRemoteProjectManagerOne = new RemoteProjectManager(TEST_RMP_ONE_NAME, ServiceType.VERSION_ONE);
+ private static RemoteProjectManager testRemoteProjectManagerOne = new RemoteProjectManager(TEST_RMP_ONE_NAME, ServiceType.VERSION_ONE, TEST_PROJECT_URL1, TEST_PROJECT_TOKEN1);
private static final InternalRequest TEST_REQUEST1 = new InternalRequest(TEST_FEATURE_REQUEST_TITLE, TEST_FEATURE_REQUEST_DESCRIPTION, TEST_PRODUCT1, TEST_CREATED_ON1);
@@ -203,7 +206,7 @@ public void testSubmitIssueRequest() {
@Test
public void testPushRequest() throws Exception {
- when(remoteProjectManagementBean.push(TEST_FEATURE_REQUEST)).thenReturn(TEST_FEATURE_REQUEST);
+ when(remoteProjectManagementBean.push(TEST_FEATURE_REQUEST)).thenReturn(TEST_FEATURE_REQUEST.getScopeId());
when(managementBeanRegistry.getService(any(String.class))).thenReturn(remoteProjectManagementBean);
when(productRepo.findOne(any(Long.class))).thenReturn(TEST_PRODUCT1);
apiResponse = productController.pushRequest(TEST_FEATURE_REQUEST);
@@ -212,7 +215,7 @@ public void testPushRequest() throws Exception {
@Test
public void testGetAllRemoteProductsForProduct() throws Exception {
- when(remoteProjectManagementBean.push(TEST_FEATURE_REQUEST)).thenReturn(TEST_FEATURE_REQUEST);
+ when(remoteProjectManagementBean.push(TEST_FEATURE_REQUEST)).thenReturn(TEST_FEATURE_REQUEST.getScopeId());
when(managementBeanRegistry.getService(any(String.class))).thenReturn(remoteProjectManagementBean);
when(productRepo.findOne(any(Long.class))).thenReturn(TEST_PRODUCT1);
apiResponse = productController.getAllRemoteProjectsForProduct(TEST_PRODUCT1.getId());
@@ -221,7 +224,7 @@ public void testGetAllRemoteProductsForProduct() throws Exception {
@Test
public void testGetAllRemoteProductsForProductWithInvalidId() throws Exception {
- when(remoteProjectManagementBean.push(TEST_FEATURE_REQUEST)).thenReturn(TEST_FEATURE_REQUEST);
+ when(remoteProjectManagementBean.push(TEST_FEATURE_REQUEST)).thenReturn(TEST_FEATURE_REQUEST.getScopeId());
when(managementBeanRegistry.getService(any(String.class))).thenReturn(remoteProjectManagementBean);
apiResponse = productController.getAllRemoteProjectsForProduct(null);
assertEquals("Request with invalid Product id did not result in an error", ERROR, apiResponse.getMeta().getStatus());
@@ -240,7 +243,7 @@ public void testGetAllRemoteProductsForProductWithNoRemoteProductManager() {
@Test
public void testGetAllRemoteProjects() throws Exception {
when(remoteProjectManagerRepo.findOne(any(Long.class))).thenReturn(testRemoteProjectManagerOne);
- when(remoteProjectManagementBean.push(TEST_FEATURE_REQUEST)).thenReturn(TEST_FEATURE_REQUEST);
+ when(remoteProjectManagementBean.push(TEST_FEATURE_REQUEST)).thenReturn("1");
when(managementBeanRegistry.getService(any(String.class))).thenReturn(remoteProjectManagementBean);
apiResponse = productController.getAllRemoteProjects(testRemoteProjectManagerOne.getId());
assertEquals("Remote Project Manager controller unable to get all remote projects", SUCCESS, apiResponse.getMeta().getStatus());
diff --git a/src/test/java/edu/tamu/app/controller/RemoteProjectManagerControllerTest.java b/src/test/java/edu/tamu/app/controller/RemoteProjectManagerControllerTest.java
index f65ae049..509a774d 100644
--- a/src/test/java/edu/tamu/app/controller/RemoteProjectManagerControllerTest.java
+++ b/src/test/java/edu/tamu/app/controller/RemoteProjectManagerControllerTest.java
@@ -37,14 +37,20 @@ public class RemoteProjectManagerControllerTest {
private static final String TEST_PROJECT1_SCOPE1 = "0010";
private static final String TEST_PROJECT1_SCOPE2 = "0011";
+ private static final String TEST_PROJECT_URL1 = "http://localhost/1";
+ private static final String TEST_PROJECT_URL2 = "http://localhost/2";
+
+ private static final String TEST_PROJECT_TOKEN1 = "0123456789";
+ private static final String TEST_PROJECT_TOKEN2 = "9876543210";
+
private static final String TEST_RMP_ONE_NAME = "Test Remote Project Manager 1";
private static final String TEST_RMP_TWO_NAME = "Test Remote Project Manager 2";
private static final String TEST_MODIFIED_RMP_NAME = "Modified Remote Project Manager";
- private static RemoteProjectManager testRemoteProjectManagerOne = new RemoteProjectManager(TEST_RMP_ONE_NAME, ServiceType.VERSION_ONE);
- private static RemoteProjectManager testRemoteProjectManagerTwo = new RemoteProjectManager(TEST_RMP_TWO_NAME, ServiceType.VERSION_ONE);
- private static RemoteProjectManager testModifiedProjectManager = new RemoteProjectManager(TEST_MODIFIED_RMP_NAME, ServiceType.VERSION_ONE);
+ private static RemoteProjectManager testRemoteProjectManagerOne = new RemoteProjectManager(TEST_RMP_ONE_NAME, ServiceType.VERSION_ONE, TEST_PROJECT_URL1, TEST_PROJECT_TOKEN1);
+ private static RemoteProjectManager testRemoteProjectManagerTwo = new RemoteProjectManager(TEST_RMP_TWO_NAME, ServiceType.VERSION_ONE, TEST_PROJECT_URL2, TEST_PROJECT_TOKEN2);
+ private static RemoteProjectManager testModifiedProjectManager = new RemoteProjectManager(TEST_MODIFIED_RMP_NAME, ServiceType.VERSION_ONE, TEST_PROJECT_URL1, TEST_PROJECT_TOKEN1);
private static List mockRemoteProjectManagers = new ArrayList(Arrays.asList(new RemoteProjectManager[] { testRemoteProjectManagerOne, testRemoteProjectManagerTwo }));
private static final RemoteProjectInfo TEST_REMOTE_PROJECT_INFO1 = new RemoteProjectInfo(TEST_PROJECT1_SCOPE1, testRemoteProjectManagerOne);
diff --git a/src/test/java/edu/tamu/app/model/ModelTest.java b/src/test/java/edu/tamu/app/model/ModelTest.java
index 093d0dfe..503d4814 100644
--- a/src/test/java/edu/tamu/app/model/ModelTest.java
+++ b/src/test/java/edu/tamu/app/model/ModelTest.java
@@ -3,9 +3,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import org.junit.After;
import org.springframework.beans.factory.annotation.Autowired;
@@ -32,17 +30,26 @@ public abstract class ModelTest {
protected static final String TEST_PROJECT_SCOPE2 = "0011";
protected static final String TEST_PROJECT_SCOPE3 = "0020";
+ protected static final String TEST_PROJECT_URL1 = "http://localhost/1";
+ protected static final String TEST_PROJECT_URL2 = "http://localhost/2";
+
+ protected static final String TEST_PROJECT_TOKEN1 = "0123456789";
+ protected static final String TEST_PROJECT_TOKEN2 = "9876543210";
+
protected static final String TEST_INTERNAL_REQUEST_TITLE1 = "Test Internal Request Title 1";
protected static final String TEST_INTERNAL_REQUEST_TITLE2 = "Test Internal Request Title 2";
protected static final String TEST_INTERNAL_REQUEST_DESCRIPTION1 = "Test Internal Request Description 1";
protected static final String TEST_INTERNAL_REQUEST_DESCRIPTION2 = "Test Internal Request Description 2";
+ protected static final String TEST_OTHER_URL_1 = "Test Other URL 1";
+ protected static final String TEST_OTHER_URL_2 = "Test Other URL 2";
+
protected static final Date TEST_INTERNAL_REQUEST_CREATED_ON1 = new Date();
protected static final Date TEST_INTERNAL_REQUEST_CREATED_ON2 = new Date(System.currentTimeMillis() + 100);
- protected static final RemoteProjectManager TEST_REMOTE_PROJECT_MANAGER1 = new RemoteProjectManager(TEST_REMOTE_PROJECT_MANAGER1_NAME, ServiceType.VERSION_ONE, getMockSettings());
- protected static final RemoteProjectManager TEST_REMOTE_PROJECT_MANAGER2 = new RemoteProjectManager(TEST_REMOTE_PROJECT_MANAGER2_NAME, ServiceType.GITHUB, getMockSettings());
+ protected static final RemoteProjectManager TEST_REMOTE_PROJECT_MANAGER1 = new RemoteProjectManager(TEST_REMOTE_PROJECT_MANAGER1_NAME, ServiceType.VERSION_ONE, TEST_PROJECT_URL1, TEST_PROJECT_TOKEN1);
+ protected static final RemoteProjectManager TEST_REMOTE_PROJECT_MANAGER2 = new RemoteProjectManager(TEST_REMOTE_PROJECT_MANAGER2_NAME, ServiceType.GITHUB, TEST_PROJECT_URL2, TEST_PROJECT_TOKEN2);
protected static final RemoteProjectInfo TEST_REMOTE_PROJECT_INFO1 = new RemoteProjectInfo(TEST_PROJECT_SCOPE1, TEST_REMOTE_PROJECT_MANAGER1);
protected static final RemoteProjectInfo TEST_REMOTE_PROJECT_INFO2 = new RemoteProjectInfo(TEST_PROJECT_SCOPE2, TEST_REMOTE_PROJECT_MANAGER1);
@@ -51,7 +58,9 @@ public abstract class ModelTest {
protected static final List TEST_PRODUCT_REMOTE_PROJECT_INFO_LIST1 = new ArrayList(Arrays.asList(TEST_REMOTE_PROJECT_INFO1, TEST_REMOTE_PROJECT_INFO2));
protected static final List TEST_PRODUCT_REMOTE_PROJECT_INFO_LIST2 = new ArrayList(Arrays.asList(TEST_REMOTE_PROJECT_INFO3));
- protected static final Product TEST_PRODUCT = new Product(TEST_PRODUCT_NAME, TEST_PRODUCT_REMOTE_PROJECT_INFO_LIST1);
+ protected static final List TEST_OTHER_URLS = new ArrayList(Arrays.asList(TEST_OTHER_URL_1, TEST_OTHER_URL_2));
+
+ protected static final Product TEST_PRODUCT = new Product(TEST_PRODUCT_NAME, TEST_PRODUCT_REMOTE_PROJECT_INFO_LIST1, TEST_PROJECT_SCOPE1, "", "", "", "", TEST_OTHER_URLS);
protected static final InternalRequest TEST_INTERNAL_REQUEST1 = new InternalRequest(TEST_INTERNAL_REQUEST_TITLE1, TEST_INTERNAL_REQUEST_DESCRIPTION1, TEST_PRODUCT, TEST_INTERNAL_REQUEST_CREATED_ON1);
protected static final InternalRequest TEST_INTERNAL_REQUEST2 = new InternalRequest(TEST_INTERNAL_REQUEST_TITLE2, TEST_INTERNAL_REQUEST_DESCRIPTION2, null, TEST_INTERNAL_REQUEST_CREATED_ON2);
@@ -74,17 +83,6 @@ public abstract class ModelTest {
@Autowired
protected InternalRequestRepo internalRequestRepo;
- protected static Map getMockSettings() {
- return new HashMap() {
- private static final long serialVersionUID = 2020874481642498006L;
- {
- put("url", "https://localhost:9101/TexasAMLibrary");
- put("username", "username");
- put("password", "password");
- }
- };
- }
-
@After
public void cleanup() {
statusRepo.deleteAll();
diff --git a/src/test/java/edu/tamu/app/model/ProductModelTest.java b/src/test/java/edu/tamu/app/model/ProductModelTest.java
index 050b7f21..432170e1 100644
--- a/src/test/java/edu/tamu/app/model/ProductModelTest.java
+++ b/src/test/java/edu/tamu/app/model/ProductModelTest.java
@@ -2,6 +2,8 @@
import static org.junit.Assert.assertEquals;
+import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import org.junit.Test;
@@ -26,31 +28,31 @@ public void testGetName() {
@Test
public void testGetScopeId() {
- Product product = new Product(TEST_PRODUCT_NAME, TEST_PRODUCT_REMOTE_PROJECT_INFO_LIST1, TEST_PROJECT_SCOPE1, "", "", "", "");
+ Product product = new Product(TEST_PRODUCT_NAME, TEST_PRODUCT_REMOTE_PROJECT_INFO_LIST1, TEST_PROJECT_SCOPE1, "", "", "", "", null);
assertEquals("Product did not return the correct scope id!", TEST_PROJECT_SCOPE1, product.getScopeId());
}
@Test
public void testGetDevUri() {
- Product product = new Product(TEST_PRODUCT_NAME, TEST_PRODUCT_REMOTE_PROJECT_INFO_LIST1, TEST_PROJECT_SCOPE1, TEST_URL_1, "", "", "");
+ Product product = new Product(TEST_PRODUCT_NAME, TEST_PRODUCT_REMOTE_PROJECT_INFO_LIST1, TEST_PROJECT_SCOPE1, TEST_URL_1, "", "", "", null);
assertEquals("Product did not return the correct dev URL!", TEST_URL_1, product.getDevUrl());
}
@Test
public void testGetPreUri() {
- Product product = new Product(TEST_PRODUCT_NAME, TEST_PRODUCT_REMOTE_PROJECT_INFO_LIST1, TEST_PROJECT_SCOPE1, "", TEST_URL_1, "", "");
+ Product product = new Product(TEST_PRODUCT_NAME, TEST_PRODUCT_REMOTE_PROJECT_INFO_LIST1, TEST_PROJECT_SCOPE1, "", TEST_URL_1, "", "", null);
assertEquals("Product did not return the correct pre URL!", TEST_URL_1, product.getPreUrl());
}
@Test
public void testGetProductionUrl() {
- Product product = new Product(TEST_PRODUCT_NAME, TEST_PRODUCT_REMOTE_PROJECT_INFO_LIST1, TEST_PROJECT_SCOPE1, "", "", TEST_URL_1, "");
+ Product product = new Product(TEST_PRODUCT_NAME, TEST_PRODUCT_REMOTE_PROJECT_INFO_LIST1, TEST_PROJECT_SCOPE1, "", "", TEST_URL_1, "", null);
assertEquals("Product did not return the correct production URL!", TEST_URL_1, product.getProductionUrl());
}
@Test
public void testGetWikiUrl() {
- Product product = new Product(TEST_PRODUCT_NAME, TEST_PRODUCT_REMOTE_PROJECT_INFO_LIST1, TEST_PROJECT_SCOPE1, "", "", "", TEST_URL_1);
+ Product product = new Product(TEST_PRODUCT_NAME, TEST_PRODUCT_REMOTE_PROJECT_INFO_LIST1, TEST_PROJECT_SCOPE1, "", "", "", TEST_URL_1, null);
assertEquals("Product did not return the correct wiki URL!", TEST_URL_1, product.getWikiUrl());
}
@@ -69,35 +71,35 @@ public void testSetName() {
@Test
public void testSetDevUrl() {
- Product product = new Product(TEST_PRODUCT_NAME, TEST_PRODUCT_REMOTE_PROJECT_INFO_LIST1, TEST_PROJECT_SCOPE1, TEST_URL_1, "", "", "");
+ Product product = new Product(TEST_PRODUCT_NAME, TEST_PRODUCT_REMOTE_PROJECT_INFO_LIST1, TEST_PROJECT_SCOPE1, TEST_URL_1, "", "", "", null);
product.setDevUrl(TEST_URL_2);
assertEquals("Product did not correctly update the dev URL!", TEST_URL_2, product.getDevUrl());
}
@Test
public void testSetPreUrl() {
- Product product = new Product(TEST_PRODUCT_NAME, TEST_PRODUCT_REMOTE_PROJECT_INFO_LIST1, TEST_PROJECT_SCOPE1, "", TEST_URL_1, "", "");
+ Product product = new Product(TEST_PRODUCT_NAME, TEST_PRODUCT_REMOTE_PROJECT_INFO_LIST1, TEST_PROJECT_SCOPE1, "", TEST_URL_1, "", "", null);
product.setPreUrl(TEST_URL_2);
assertEquals("Product did not correctly update the pre URL!", TEST_URL_2, product.getPreUrl());
}
@Test
public void testSetProductionUrl() {
- Product product = new Product(TEST_PRODUCT_NAME, TEST_PRODUCT_REMOTE_PROJECT_INFO_LIST1, TEST_PROJECT_SCOPE1, "", "", TEST_URL_1, "");
+ Product product = new Product(TEST_PRODUCT_NAME, TEST_PRODUCT_REMOTE_PROJECT_INFO_LIST1, TEST_PROJECT_SCOPE1, "", "", TEST_URL_1, "", null);
product.setProductionUrl(TEST_URL_2);
assertEquals("Product did not correctly update the production URL!", TEST_URL_2, product.getProductionUrl());
}
@Test
public void testSetWikiUrl() {
- Product product = new Product(TEST_PRODUCT_NAME, TEST_PRODUCT_REMOTE_PROJECT_INFO_LIST1, TEST_PROJECT_SCOPE1, "", "", "", TEST_URL_1);
+ Product product = new Product(TEST_PRODUCT_NAME, TEST_PRODUCT_REMOTE_PROJECT_INFO_LIST1, TEST_PROJECT_SCOPE1, "", "", "", TEST_URL_1, null);
product.setWikiUrl(TEST_URL_2);
assertEquals("Product did not correctly update the Wiki URL!", TEST_URL_2, product.getWikiUrl());
}
@Test
public void testSetScopeId() {
- Product product = new Product(TEST_PRODUCT_NAME, TEST_PRODUCT_REMOTE_PROJECT_INFO_LIST1, TEST_PROJECT_SCOPE1, "", "", "", "");
+ Product product = new Product(TEST_PRODUCT_NAME, TEST_PRODUCT_REMOTE_PROJECT_INFO_LIST1, TEST_PROJECT_SCOPE1, "", "", "", "", null);
product.setScopeId(TEST_PROJECT_SCOPE2);
assertEquals("Product did not correctly update the scope id!", TEST_PROJECT_SCOPE2, product.getScopeId());
}
@@ -125,4 +127,26 @@ public void testRemoveRemoteProduct() {
assertEquals("Product did not correctly add the remote project!", false, remoteProjectInfo.contains(TEST_REMOTE_PROJECT_INFO1));
}
+ @Test
+ public void testSetOtherUrls() {
+ Product product = new Product(TEST_PRODUCT_NAME, TEST_PRODUCT_REMOTE_PROJECT_INFO_LIST1);
+ product.setOtherUrls(TEST_OTHER_URLS);
+ assertEquals("Product did not correctly set the other URLs", 2, product.getOtherUrls().size());
+ }
+
+ @Test
+ public void testAddOtherUrl() {
+ Product product = new Product(TEST_PRODUCT_NAME, TEST_PRODUCT_REMOTE_PROJECT_INFO_LIST1, TEST_PROJECT_SCOPE1, "", "", "", "", new ArrayList(Arrays.asList(TEST_OTHER_URL_1)));
+ product.addOtherUrl(TEST_OTHER_URL_2);
+ assertEquals("Product did not correctly add the second URL", 2, product.getOtherUrls().size());
+ }
+
+ @Test
+ public void testRemoveOtherUrl() {
+ Product product = new Product(TEST_PRODUCT_NAME, TEST_PRODUCT_REMOTE_PROJECT_INFO_LIST1, TEST_PROJECT_SCOPE1, "", "", "", "", TEST_OTHER_URLS);
+ product.removeOtherUrl(TEST_OTHER_URL_1);
+ assertEquals("Product did not remove other URL", 1, product.getOtherUrls().size());
+ assertEquals("Product did not remove correct other URL", TEST_OTHER_URL_2, product.getOtherUrls().get(0));
+ }
+
}
diff --git a/src/test/java/edu/tamu/app/model/ProductTest.java b/src/test/java/edu/tamu/app/model/ProductTest.java
index 4832697d..50c7ca17 100644
--- a/src/test/java/edu/tamu/app/model/ProductTest.java
+++ b/src/test/java/edu/tamu/app/model/ProductTest.java
@@ -112,4 +112,15 @@ public void testSetRemoteProductInfo() {
assertEquals("Product repo had incorrect number of products!", 0, productRepo.count());
}
+ @Test
+ public void testOtherUrlsCanBeSet() {
+ productRepo.create(TEST_PRODUCT);
+ Optional product = productRepo.findByName(TEST_PRODUCT_NAME);
+ assertTrue("Could not read product!", product.isPresent());
+ assertEquals("Product read did not have the correct name!", TEST_PRODUCT_NAME, product.get().getName());
+ assertEquals("Product did not have the expected other URLs", 2, product.get().getOtherUrls().size());
+ assertEquals("First other URL does not match", TEST_OTHER_URL_1, product.get().getOtherUrls().get(0));
+ assertEquals("Second other URL does not match", TEST_OTHER_URL_2, product.get().getOtherUrls().get(1));
+ }
+
}
diff --git a/src/test/java/edu/tamu/app/model/RemoteProjectManagerTest.java b/src/test/java/edu/tamu/app/model/RemoteProjectManagerTest.java
index 333d245a..aa6c6988 100644
--- a/src/test/java/edu/tamu/app/model/RemoteProjectManagerTest.java
+++ b/src/test/java/edu/tamu/app/model/RemoteProjectManagerTest.java
@@ -5,7 +5,6 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import java.util.Map;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -22,27 +21,28 @@ public class RemoteProjectManagerTest extends ModelTest {
@Test
public void testCreate() {
- Map settings = getMockSettings();
- RemoteProjectManager remoteProjectManager1 = remoteProjectManagerRepo.create(new RemoteProjectManager(TEST_REMOTE_PROJECT_MANAGER1_NAME, ServiceType.VERSION_ONE, settings));
- RemoteProjectManager remoteProjectManager2 = remoteProjectManagerRepo.create(new RemoteProjectManager(TEST_REMOTE_PROJECT_MANAGER2_NAME, ServiceType.GITHUB, settings));
+ RemoteProjectManager remoteProjectManager1 = remoteProjectManagerRepo.create(new RemoteProjectManager(TEST_REMOTE_PROJECT_MANAGER1_NAME, ServiceType.VERSION_ONE, TEST_PROJECT_URL1, TEST_PROJECT_TOKEN1));
+ RemoteProjectManager remoteProjectManager2 = remoteProjectManagerRepo.create(new RemoteProjectManager(TEST_REMOTE_PROJECT_MANAGER2_NAME, ServiceType.GITHUB, TEST_PROJECT_URL2, TEST_PROJECT_TOKEN2));
assertEquals("Remote project manager repo had incorrect number of remote project managers!", 2, remoteProjectManagerRepo.count());
assertEquals("Remote project manager had incorrect name!", TEST_REMOTE_PROJECT_MANAGER1_NAME, remoteProjectManager1.getName());
assertEquals("Remote project manager had incorrect service type!", ServiceType.VERSION_ONE, remoteProjectManager1.getType());
- assertEquals("Remote project manager had incorrect settings!", settings, remoteProjectManager1.getSettings());
+ assertEquals("Remote project manager had incorrect url!", TEST_PROJECT_URL1, remoteProjectManager1.getUrl());
+ assertEquals("Remote project manager had incorrect token!", TEST_PROJECT_TOKEN1, remoteProjectManager1.getToken());
assertEquals("Remote project manager had incorrect name!", TEST_REMOTE_PROJECT_MANAGER2_NAME, remoteProjectManager2.getName());
assertEquals("Remote project manager had incorrect service type!", ServiceType.GITHUB, remoteProjectManager2.getType());
- assertEquals("Remote project manager had incorrect settings!", settings, remoteProjectManager2.getSettings());
+ assertEquals("Remote project manager had incorrect url!", TEST_PROJECT_URL2, remoteProjectManager2.getUrl());
+ assertEquals("Remote project manager had incorrect token!", TEST_PROJECT_TOKEN2, remoteProjectManager2.getToken());
}
@Test
public void testRead() {
- remoteProjectManagerRepo.create(new RemoteProjectManager(TEST_REMOTE_PROJECT_MANAGER1_NAME, ServiceType.VERSION_ONE, getMockSettings()));
+ remoteProjectManagerRepo.create(new RemoteProjectManager(TEST_REMOTE_PROJECT_MANAGER1_NAME, ServiceType.VERSION_ONE, TEST_PROJECT_URL1, TEST_PROJECT_TOKEN1));
assertEquals("Could not read all remote project managers!", 1, remoteProjectManagerRepo.findAll().size());
}
@Test
public void testUpdate() {
- RemoteProjectManager remoteProjectManager = remoteProjectManagerRepo.create(new RemoteProjectManager(TEST_REMOTE_PROJECT_MANAGER1_NAME, ServiceType.VERSION_ONE, getMockSettings()));
+ RemoteProjectManager remoteProjectManager = remoteProjectManagerRepo.create(new RemoteProjectManager(TEST_REMOTE_PROJECT_MANAGER1_NAME, ServiceType.VERSION_ONE, TEST_PROJECT_URL1, TEST_PROJECT_TOKEN1));
remoteProjectManager.setName(TEST_ALTERNATE_REMOTE_PROJECT_MANAGER_NAME);
remoteProjectManager = remoteProjectManagerRepo.update(remoteProjectManager);
assertEquals("Remote project manager did not update name!", TEST_ALTERNATE_REMOTE_PROJECT_MANAGER_NAME, remoteProjectManager.getName());
@@ -50,14 +50,14 @@ public void testUpdate() {
@Test
public void testDelete() {
- RemoteProjectManager remoteProjectManager = remoteProjectManagerRepo.create(new RemoteProjectManager(TEST_REMOTE_PROJECT_MANAGER1_NAME, ServiceType.VERSION_ONE, getMockSettings()));
+ RemoteProjectManager remoteProjectManager = remoteProjectManagerRepo.create(new RemoteProjectManager(TEST_REMOTE_PROJECT_MANAGER1_NAME, ServiceType.VERSION_ONE, TEST_PROJECT_URL1, TEST_PROJECT_TOKEN1));
remoteProjectManagerRepo.delete(remoteProjectManager);
assertEquals("Remote project manager was not deleted!", 0, remoteProjectManagerRepo.count());
}
@Test(expected = DataIntegrityViolationException.class)
public void testDeleteWhenAssociatedToProduct() {
- RemoteProjectManager remoteProjectManager = remoteProjectManagerRepo.create(new RemoteProjectManager(TEST_REMOTE_PROJECT_MANAGER1_NAME, ServiceType.VERSION_ONE, getMockSettings()));
+ RemoteProjectManager remoteProjectManager = remoteProjectManagerRepo.create(new RemoteProjectManager(TEST_REMOTE_PROJECT_MANAGER1_NAME, ServiceType.VERSION_ONE, TEST_PROJECT_URL1, TEST_PROJECT_TOKEN1));
RemoteProjectInfo remoteProjectInfo = new RemoteProjectInfo("3000", remoteProjectManager);
List remoteProductInfoList = new ArrayList(Arrays.asList(remoteProjectInfo));
diff --git a/src/test/java/edu/tamu/app/rest/BasicAuthRestTemplateTest.java b/src/test/java/edu/tamu/app/rest/BasicAuthRestTemplateTest.java
deleted file mode 100644
index 8e3fa1b1..00000000
--- a/src/test/java/edu/tamu/app/rest/BasicAuthRestTemplateTest.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package edu.tamu.app.rest;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.test.context.junit4.SpringRunner;
-
-@RunWith(SpringRunner.class)
-public class BasicAuthRestTemplateTest {
-
- @Test
- public void testNewBasicAuthRestTemplate() {
- BasicAuthRestTemplate basicAuthRestTemplate = new BasicAuthRestTemplate("username", "password");
- assertNotNull("Unable to create new basic auth rest template!", basicAuthRestTemplate);
- assertEquals("Basic auth rest template did not have expected username!", "username", basicAuthRestTemplate.getUsername());
- assertEquals("Basic auth rest template did not have expected password!", "password", basicAuthRestTemplate.getPassword());
- }
-
- @Test(expected = RuntimeException.class)
- public void testNewBasicAuthRestTemplateException() {
- new BasicAuthRestTemplate("", "");
- }
-
-}
diff --git a/src/test/java/edu/tamu/app/service/ManagementServiceTest.java b/src/test/java/edu/tamu/app/service/ManagementServiceTest.java
index 6e33bd86..21dab76a 100644
--- a/src/test/java/edu/tamu/app/service/ManagementServiceTest.java
+++ b/src/test/java/edu/tamu/app/service/ManagementServiceTest.java
@@ -4,8 +4,6 @@
import static org.junit.Assert.assertNull;
import static org.mockito.Mockito.mock;
-import java.util.HashMap;
-
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -22,13 +20,9 @@ public class ManagementServiceTest {
private static ServiceType TEST_TYPE = ServiceType.VERSION_ONE;
- private static final HashMap TEST_SETTINGS;
- static {
- TEST_SETTINGS = new HashMap();
- TEST_SETTINGS.put("Test 1", "Test 1");
- TEST_SETTINGS.put("Test 2", "Test 2");
- TEST_SETTINGS.put("Test 3", "Test 3");
- }
+ private static final String TEST_URL1 = "http://localhost/1";
+
+ private static final String TEST_TOKEN1 = "0123456789";
private ManagementService managementService;
@@ -52,10 +46,17 @@ public void testSetType() {
}
@Test
- public void testSetSettings() {
- assertNull("Settings were not empty", managementService.getSettings());
- managementService.setSettings(TEST_SETTINGS);
- assertEquals("Settings where not set correctly", TEST_SETTINGS, managementService.getSettings());
+ public void testSetUrl() {
+ assertNull("URL was already set", managementService.getUrl());
+ managementService.setUrl(TEST_URL1);
+ assertEquals("URL was not set correctly", TEST_URL1, managementService.getUrl());
+ }
+
+ @Test
+ public void testSetToken() {
+ assertNull("Token was already set", managementService.getToken());
+ managementService.setToken(TEST_TOKEN1);
+ assertEquals("Token was not set correctly", TEST_TOKEN1, managementService.getToken());
}
}
diff --git a/src/test/java/edu/tamu/app/service/manager/GitHubServiceTest.java b/src/test/java/edu/tamu/app/service/manager/GitHubServiceTest.java
index defdad4f..50fd1981 100644
--- a/src/test/java/edu/tamu/app/service/manager/GitHubServiceTest.java
+++ b/src/test/java/edu/tamu/app/service/manager/GitHubServiceTest.java
@@ -81,6 +81,10 @@ public class GitHubServiceTest extends CacheMockTests {
private static final Long TEST_REPOSITORY1_ID = 1L;
private static final Long TEST_USER1_ID = 3L;
+ private static final String TEST_PROJECT_URL1 = "http://localhost/1";
+
+ private static final String TEST_PROJECT_TOKEN1 = "0123456789";
+
private static final GHLabel TEST_LABEL1 = mock(GHLabel.class);
private static final GHLabel TEST_LABEL2 = mock(GHLabel.class);
private static final GHLabel TEST_LABEL3 = mock(GHLabel.class);
@@ -172,15 +176,8 @@ public class GitHubServiceTest extends CacheMockTests {
@Before
public void setUp() throws Exception {
- ManagementService managementService = new RemoteProjectManager("GitHub", ServiceType.GITHUB,
- new HashMap() {
- private static final long serialVersionUID = 2020874481642498006L;
- {
- put("url", "https://localhost:9101/TexasAMLibrary");
- put("username", "username");
- put("password", "password");
- }
- });
+ ManagementService managementService = new RemoteProjectManager("GitHub", ServiceType.GITHUB, TEST_PROJECT_URL1, TEST_PROJECT_TOKEN1);
+
CardTypeRepo cardTypeRepo = mock(CardTypeRepo.class);
StatusRepo statusRepo = mock(StatusRepo.class);
@@ -199,7 +196,6 @@ public void setUp() throws Exception {
github = mock(GitHub.class);
when(ghBuilder.withEndpoint(any(String.class))).thenReturn(ghBuilder);
- when(ghBuilder.withPassword(any(String.class), any(String.class))).thenReturn(ghBuilder);
when(ghBuilder.withOAuthToken(any(String.class))).thenReturn(ghBuilder);
when(ghBuilder.build()).thenReturn(github);
@@ -384,8 +380,8 @@ public void testGetAdditionalActiveSprints() throws Exception {
@Test
public void testPush() throws Exception {
- GHIssue issue = (GHIssue) gitHubService.push(TEST_FEATURE_REQUEST);
- assertEquals("Didn't get expected issue", TEST_ISSUE1, issue);
+ String id = gitHubService.push(TEST_FEATURE_REQUEST);
+ assertNotNull(id);
}
@Test
@@ -397,24 +393,33 @@ public void testGetMember() throws IOException {
}
@Test
- public void testGetGitHubInstanceByPassword() throws IOException {
- GitHub githubInstance = gitHubService.getGitHubInstance();
- assertNotNull("GitHub object was not created", githubInstance);
+ public void testGetGitHubInstanceWithInvalidServiceEndpoint() throws IOException {
+ ManagementService invalidManagementService = new RemoteProjectManager("GitHub", ServiceType.GITHUB, TEST_PROJECT_URL1, TEST_PROJECT_TOKEN1);
+
+ setField(gitHubService, "managementService", invalidManagementService);
+
+ try {
+ gitHubService.getGitHubInstance();
+ } catch (RuntimeException e) {
+ assertEquals(e.getMessage(), "GitHub service endpoint was not defined");
+ }
}
@Test
- public void testGetGitHubInstanceByToken() throws IOException {
- ManagementService tokenManagementService = new RemoteProjectManager("GitHub", ServiceType.GITHUB,
- new HashMap() {
- private static final long serialVersionUID = 2020874481642498006L;
- {
- put("url", "https://localhost:9101/TexasAMLibrary");
- put("token", "token");
- }
- });
+ public void testGetGitHubInstanceWithInvalidToken() throws IOException {
+ ManagementService invalidManagementService = new RemoteProjectManager("GitHub", ServiceType.GITHUB, TEST_PROJECT_URL1, TEST_PROJECT_TOKEN1);
+
+ setField(gitHubService, "managementService", invalidManagementService);
- setField(gitHubService, "managementService", tokenManagementService);
+ try {
+ gitHubService.getGitHubInstance();
+ } catch (RuntimeException e) {
+ assertEquals(e.getMessage(), "GitHub token was not defined");
+ }
+ }
+ @Test
+ public void testGetGitHubInstanceByToken() throws IOException {
GitHub gitHubInstance = gitHubService.getGitHubInstance();
assertNotNull("GitHub object was not created", gitHubInstance);
}
diff --git a/src/test/java/edu/tamu/app/service/manager/VersionOneServiceTest.java b/src/test/java/edu/tamu/app/service/manager/VersionOneServiceTest.java
index 9822c016..aeb7002c 100644
--- a/src/test/java/edu/tamu/app/service/manager/VersionOneServiceTest.java
+++ b/src/test/java/edu/tamu/app/service/manager/VersionOneServiceTest.java
@@ -67,11 +67,15 @@
import edu.tamu.app.model.repo.EstimateRepo;
import edu.tamu.app.model.repo.StatusRepo;
import edu.tamu.app.model.request.FeatureRequest;
-import edu.tamu.app.rest.BasicAuthRestTemplate;
+import edu.tamu.app.rest.TokenAuthRestTemplate;
@RunWith(SpringRunner.class)
public class VersionOneServiceTest extends CacheMockTests {
+ private static final String TEST_PROJECT_URL1 = "http://localhost/1";
+
+ private static final String TEST_PROJECT_TOKEN1 = "0123456789";
+
@Value("classpath:images/no_avatar.png")
private Resource mockImage;
@@ -79,7 +83,7 @@ public class VersionOneServiceTest extends CacheMockTests {
private IServices services;
- private BasicAuthRestTemplate restTemplate;
+ private TokenAuthRestTemplate restTemplate;
private List mockRemoteProjects;
@@ -88,14 +92,7 @@ public class VersionOneServiceTest extends CacheMockTests {
@Before
@SuppressWarnings("unchecked")
public void setup() throws JsonParseException, JsonMappingException, IOException, V1Exception {
- ManagementService managementService = new RemoteProjectManager("Version One", ServiceType.VERSION_ONE, new HashMap() {
- private static final long serialVersionUID = 2020874481642498006L;
- {
- put("url", "https://localhost:9101/TexasAMLibrary");
- put("username", "username");
- put("password", "password");
- }
- });
+ ManagementService managementService = new RemoteProjectManager("Version One", ServiceType.VERSION_ONE, TEST_PROJECT_URL1, TEST_PROJECT_TOKEN1);
CardTypeRepo cardTypeRepo = mock(CardTypeRepo.class);
StatusRepo statusRepo = mock(StatusRepo.class);
@@ -111,7 +108,7 @@ public void setup() throws JsonParseException, JsonMappingException, IOException
services = mock(IServices.class);
- restTemplate = mock(BasicAuthRestTemplate.class);
+ restTemplate = mock(TokenAuthRestTemplate.class);
when(restTemplate.exchange(any(String.class), any(HttpMethod.class), any(HttpEntity.class), any(Class.class), any(Object[].class))).thenAnswer(new Answer>() {
@Override
@@ -192,13 +189,7 @@ public Optional answer(InvocationOnMock invocation) {
@Test
public void testVersionOneTokenAuthConnector() {
- ManagementService managementService = new RemoteProjectManager("Version One", ServiceType.VERSION_ONE, new HashMap() {
- private static final long serialVersionUID = 2020874481642498006L;
- {
- put("url", "https://localhost:9101/TexasAMLibrary");
- put("token", "token");
- }
- });
+ ManagementService managementService = new RemoteProjectManager("Version One", ServiceType.VERSION_ONE, TEST_PROJECT_URL1, TEST_PROJECT_TOKEN1);
setField(versionOneService, "managementService", managementService);
}
@@ -240,6 +231,7 @@ public void testGetRemoteProducts() throws ConnectionException, APIException, Oi
@Test
public void testGetRemoteProductByScopeId() throws ConnectionException, APIException, OidException, JsonParseException, JsonMappingException, IOException {
Oid oid = mock(Oid.class);
+
QueryResult result = mock(QueryResult.class);
IMetaModel metaModel = mock(IMetaModel.class);
IAssetType scopeType = mock(IAssetType.class);
@@ -499,6 +491,7 @@ public Member answer(InvocationOnMock invocation) {
@Test
public void testGetMember() throws JsonParseException, JsonMappingException, APIException, IOException, OidException, ConnectionException {
Oid oid = mock(Oid.class);
+
QueryResult result = mock(QueryResult.class);
IMetaModel metaModel = mock(IMetaModel.class);
IAssetType memberType = mock(IAssetType.class);
@@ -545,6 +538,7 @@ public void testGetMember() throws JsonParseException, JsonMappingException, API
@Test
public void testGetMemberWithAvatarImage() throws JsonParseException, JsonMappingException, APIException, IOException, OidException, ConnectionException {
Oid oid = mock(Oid.class);
+
QueryResult result = mock(QueryResult.class);
IMetaModel metaModel = mock(IMetaModel.class);
IAssetType memberType = mock(IAssetType.class);
@@ -591,6 +585,8 @@ public void testGetMemberWithAvatarImage() throws JsonParseException, JsonMappin
@Test
public void testPush() throws V1Exception {
Oid oid = mock(Oid.class);
+ Oid assetOid = mock(Oid.class);
+
IMetaModel metaModel = mock(IMetaModel.class);
IAssetType assetType = mock(IAssetType.class);
IAttributeDefinition attributeDefinition = mock(IAttributeDefinition.class);
@@ -599,11 +595,14 @@ public void testPush() throws V1Exception {
when(assetType.getAttributeDefinition(any(String.class))).thenReturn(attributeDefinition);
when(metaModel.getAssetType(any(String.class))).thenReturn(assetType);
+
when(services.getOid(any(String.class))).thenReturn(oid);
when(services.getMeta()).thenReturn(metaModel);
-
when(services.createNew(any(IAssetType.class), any(Oid.class))).thenReturn(mockAsset);
+ when(mockAsset.getOid()).thenReturn(assetOid);
+ when(assetOid.getToken()).thenReturn("token:assetOid");
+
doNothing().when(mockAsset).setAttributeValue(any(IAttributeDefinition.class), any(Object.class));
Object request = versionOneService.push(new FeatureRequest("New Feature", "I would like to turn off service through API.", 1L, "0001"));
@@ -912,9 +911,14 @@ private Asset[] getMockMemberAsset(Member member, boolean withImage) throws APIE
when(mockAvatarAttribute.getDefinition()).thenReturn(avatarAttributeDefinition);
Oid oid = mock(Oid.class);
+ Oid assetOid = mock(Oid.class);
+
when(oid.toString()).thenReturn(withImage ? "Image:" + member.getId() : "NULL");
when(mockAvatarAttribute.getValue()).thenReturn(oid);
+ when(mockAsset.getOid()).thenReturn(assetOid);
+ when(assetOid.getToken()).thenReturn("token:assetOid");
+
when(mockAsset.getAttribute(any(IAttributeDefinition.class))).thenAnswer(new Answer() {
@Override
public Attribute answer(InvocationOnMock invocation) {