Skip to content
This repository has been archived by the owner on May 19, 2020. It is now read-only.

Commit

Permalink
fix issue with HAL links (SB problem), and found issue with duplicate…
Browse files Browse the repository at this point in the history
…d app names in tests
  • Loading branch information
salaboy committed Dec 10, 2018
1 parent af2d70b commit 4536445
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 13 deletions.
Expand Up @@ -26,6 +26,7 @@
import org.activiti.cloud.organization.api.Application;
import org.activiti.cloud.organization.api.Model;
import org.activiti.cloud.organization.api.ModelType;
import org.activiti.cloud.qa.config.ModelingTestsConfigurationProperties;
import org.activiti.cloud.qa.model.modeling.EnableModelingContext;
import org.activiti.cloud.qa.model.modeling.ModelingIdentifier;
import org.activiti.cloud.qa.service.ModelingApplicationsService;
Expand All @@ -51,6 +52,9 @@ public class ModelingApplicationsSteps extends ModelingContextSteps<Application>
@Autowired
private ModelingApplicationsService modelingApplicationsService;

@Autowired
private ModelingTestsConfigurationProperties config;

@Step
public Resource<Application> create(String applicationName) {
String id = UUID.randomUUID().toString();
Expand All @@ -67,7 +71,8 @@ public void updateApplicationName(String newApplicationName) {
Application application = currentContext.getContent();
application.setName(newApplicationName);

modelingApplicationsService.updateByUri(currentContext.getLink(REL_SELF).getHref(),
modelingApplicationsService.updateByUri(currentContext.getLink(REL_SELF).getHref()
.replace("http://activiti-cloud-modeling-backend", config.getModelingUrl()),
application);
}

Expand All @@ -94,7 +99,7 @@ public Resource<Model> importModelInCurrentApplication(File file) {
Link importModelLink = currentApplication.getLink("import");
assertThat(importModelLink).isNotNull();

return modelingApplicationsService.importApplicationModelByUri(importModelLink.getHref(),
return modelingApplicationsService.importApplicationModelByUri(importModelLink.getHref().replace("http://activiti-cloud-modeling-backend", config.getModelingUrl()),
file);
}

Expand All @@ -103,7 +108,7 @@ public void exportCurrentApplication() throws IOException {
Resource<Application> currentApplication = checkAndGetCurrentContext(Application.class);
Link exportLink = currentApplication.getLink("export");
assertThat(exportLink).isNotNull();
Response response = modelingApplicationsService.exportApplicationByUri(exportLink.getHref());
Response response = modelingApplicationsService.exportApplicationByUri(exportLink.getHref().replace("http://activiti-cloud-modeling-backend", config.getModelingUrl()));

if (response.status() == SC_OK) {
modelingContextHandler.setCurrentModelingFile(toFileContent(response));
Expand Down
Expand Up @@ -24,6 +24,7 @@

import feign.Response;
import net.thucydides.core.annotations.Step;
import org.activiti.cloud.qa.config.ModelingTestsConfigurationProperties;
import org.activiti.cloud.qa.model.modeling.ModelingContextHandler;
import org.activiti.cloud.qa.model.modeling.ModelingIdentifier;
import org.activiti.cloud.acc.shared.rest.DirtyContextHandler;
Expand Down Expand Up @@ -52,13 +53,16 @@ public abstract class ModelingContextSteps<M> {
@Autowired
protected ModelingContextHandler modelingContextHandler;

@Autowired
private ModelingTestsConfigurationProperties config;

protected Resource<M> create(String id,
M m) {
Optional<String> uri = modelingContextHandler
.getCurrentModelingContext()
.flatMap(this::getRelUri);
if (uri.isPresent()) {
service().createByUri(uri.get(),
service().createByUri(uri.get().replace("http://activiti-cloud-modeling-backend", config.getModelingUrl()),
m);
} else {
service().create(m);
Expand All @@ -83,7 +87,7 @@ public void deleteAll(ModelingIdentifier<M> identifier) {
.stream()
.filter(resource -> identifier.test(resource.getContent()))
.map(resource -> resource.getLink(REL_SELF))
.map(Link::getHref)
.map(link -> link.getHref().replace("http://activiti-cloud-modeling-backend", config.getModelingUrl()))
.collect(Collectors.toList())
.forEach(service()::deleteByUri);
}
Expand Down Expand Up @@ -114,7 +118,7 @@ protected void updateCurrentModelingObject() {
modelingContextHandler
.getCurrentModelingContext()
.map(resource -> resource.getLink(REL_SELF))
.map(Link::getHref)
.map(link -> link.getHref().replace("http://activiti-cloud-modeling-backend", config.getModelingUrl()))
.map(this::findByUri)
.ifPresent(modelingContextHandler::setCurrentModelingObject);
}
Expand Down Expand Up @@ -172,15 +176,19 @@ protected boolean existsInCollection(ModelingIdentifier<M> identifier,
}

protected Resource<M> dirty(Resource<M> resource) {
return dirtyContextHandler.dirty(resource);
dirtyContextHandler.dirty(resource.getLink("self").getHref()
.replace("http://activiti-cloud-modeling-backend",
config.getModelingUrl()));
return resource;
}

protected Resource<M> findByUri(String uri) {
return service().findByUri(uri);
}

protected PagedResources<Resource<M>> findAllByUri(String uri) {
return service().findAllByUri(uri);
String replacedURI = uri.replace("http://activiti-cloud-modeling-backend", config.getModelingUrl());
return service().findAllByUri(replacedURI);
}

protected PagedResources<Resource<M>> findAll() {
Expand Down
Expand Up @@ -24,6 +24,7 @@
import net.thucydides.core.annotations.Step;
import org.activiti.cloud.organization.api.Application;
import org.activiti.cloud.organization.api.Model;
import org.activiti.cloud.qa.config.ModelingTestsConfigurationProperties;
import org.activiti.cloud.qa.model.modeling.EnableModelingContext;
import org.activiti.cloud.qa.service.ModelingModelsService;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -45,6 +46,9 @@ public class ModelingModelsSteps extends ModelingContextSteps<Model> {
@Autowired
private ModelingModelsService modelingModelsService;

@Autowired
private ModelingTestsConfigurationProperties config;

@Step
public Resource<Model> create(String modelName,
String modelType) {
Expand All @@ -65,7 +69,7 @@ public void editAndSaveCurrentModel() {
Model model = currentContext.getContent();
model.setContent("updated content");

modelingModelsService.updateByUri(currentContext.getLink(REL_SELF).getHref(),
modelingModelsService.updateByUri(currentContext.getLink(REL_SELF).getHref().replace("http://activiti-cloud-modeling-backend", config.getModelingUrl()),
model);
updateCurrentModelingObject();
}
Expand Down
Expand Up @@ -38,7 +38,7 @@ public void resetCurrentModelingObject() {
}

@AfterScenario
public void creanup() {
public void cleanup() {
dirtyContextHandler.cleanup();
}
}
@@ -1,4 +1,4 @@
realm=springboot
realm=activiti
auth.url=http://${SSO_HOST}/auth/realms/${realm}/protocol/openid-connect/token
modeling.path=activiti-cloud-modeling-backend
modeling.url=http://${GATEWAY_HOST}/${modeling.path}
modeling.url=http://${GATEWAY_HOST}/${modeling.path}
Expand Up @@ -24,7 +24,7 @@ Then the application 'Mars Team' is deleted

Scenario: export an application
Given the user is authenticated as modeler
And an application 'Mission Europa' with process model 'landing-rover'
And an application 'Mission Europa First' with process model 'landing-rover'
When the user export the application
Then the exported application contains the process model landing-rover

Expand Down

0 comments on commit 4536445

Please sign in to comment.