This repository has been archived by the owner on Jan 3, 2024. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ekaterina Gavrilova
committed
Sep 14, 2017
1 parent
3c2d43a
commit 2e7a336
Showing
48 changed files
with
1,928 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
**/target/ | ||
**/.settings/ | ||
**/.project | ||
**/.classpath | ||
**/.DS_Store | ||
**/*.pyc | ||
**/*.pmd | ||
**/*.fpr | ||
**/sdkdist.zip | ||
**/*.ipr | ||
**/*.iws | ||
**/bin/ | ||
**/*.iml | ||
**/*.idea | ||
**/.cache | ||
**/.cache-main | ||
**/WebContent | ||
**/META-INF/application.xml | ||
**/*.sublime-project | ||
**/*.sublime-workspace | ||
**/pom.xml.versionsBackup | ||
*.sh | ||
**/sdkdist* | ||
**/example* | ||
**/tmprepo | ||
**/scp/ | ||
**/node_modules | ||
**/credentials.json | ||
**/reports | ||
/e2e-tests/*.log | ||
.org.chromium.Chromium.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const report = require('cucumber-html-report'); | ||
report.create({ | ||
source: 'reports/e2e/cucumber.json', // source json | ||
dest: 'reports/e2e/prod', // target directory (will create if not exists) | ||
name: 'report.html', // report file name (will be index.html if not exists) | ||
title: 'Cucumber Report', // Title for default template. (default is Cucumber Report) | ||
component: 'My Component', // Subtitle for default template. (default is empty) | ||
screenshots: 'reports/e2e/screenshots', // Path to the directory of screenshots. Optional. | ||
maxScreenshots: 10 // Max number of screenshots to save (default is 1000) | ||
}) | ||
.then(console.log) | ||
.catch(console.error); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/usr/bin/env groovy | ||
|
||
node { | ||
deleteDir() | ||
sh "git clone --depth 1 https://github.com/SAP/cloud-s4-sdk-pipeline.git pipelines" | ||
load './pipelines/s4sdk-pipeline.groovy' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# CostCenter Controller CF | ||
[![Build Status](http://mo-878278750.mo.sap.corp:8080/buildStatus/icon?job=partner/Costcenter-Controller-CF/master)](http://mo-878278750.mo.sap.corp:8080/job/partner/job/Costcenter-Controller-CF/job/master/) | ||
|
||
## Build | ||
```shell | ||
mvn clean compile | ||
``` | ||
|
||
## Test | ||
```shell | ||
mvn test | ||
``` | ||
|
||
### Start Local Server | ||
```shell | ||
mvn spring-boot:run | ||
``` | ||
|
||
## Run E2E Tests against Local Server | ||
```shell | ||
npm install | ||
ENV_LAUNCH_URL=http://localhost:8080 npm run ci-e2e | ||
``` | ||
|
||
## Shutdown local Server | ||
```shell | ||
curl -X POST localhost:8080/shutdown | ||
``` | ||
|
||
## Deploy to CF | ||
```shell | ||
cf api https://api.cf.eu10.hana.ondemand.com | ||
cf login | ||
mvn clean package && cf push | ||
``` | ||
|
||
## E2E Tests | ||
Configuration reads hosts from environment, so set URL like this: | ||
```shell | ||
export ENV_LAUNCH_URL=https://costcenter-cf-spring-test.cfapps.eu10.hana.ondemand.com | ||
``` | ||
|
||
- Run Tests | ||
```shell | ||
npm install | ||
npm run ci-e2e | ||
``` | ||
|
||
## Edit manifest.yml | ||
|
||
- Host | ||
- Endpoints | ||
|
||
``` | ||
https://costcenter-cf-spring-<space>.cfapps.sap.hana.ondemand.com/index.html | ||
``` | ||
|
||
## Useful CF Commands | ||
```shell | ||
cf logs costcenter-cf-spring --recent | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#No auth protected | ||
endpoints.shutdown.sensitive=false | ||
|
||
#Enable shutdown endpoint | ||
endpoints.shutdown.enabled=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<name>Cost Center Controller - Application</name> | ||
<description>costcenter-cf-spring - Application</description> | ||
|
||
<artifactId>costcenter-cf-spring-application</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
|
||
<parent> | ||
<groupId>com.sap.cloud.sdk.showcase</groupId> | ||
<artifactId>costcenter-cf-spring</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<dependencies> | ||
<!-- SDK dependencies --> | ||
<dependency> | ||
<groupId>com.sap.cloud.s4hana.cloudplatform</groupId> | ||
<artifactId>scp-cf</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.sap.cloud.s4hana</groupId> | ||
<artifactId>s4hana-all</artifactId> | ||
</dependency> | ||
|
||
<!-- Spring dependencies --> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-tomcat</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-webmvc</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-actuator</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.projectlombok</groupId> | ||
<artifactId>lombok</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<!-- logging --> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-api</artifactId> | ||
<scope>compile</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<finalName>${project.artifactId}</finalName> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
<version>1.5.2.RELEASE</version> | ||
<configuration> | ||
<attach>false</attach> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>repackage</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
23 changes: 23 additions & 0 deletions
23
...enter-Controller-CF/application/src/main/java/com/sap/cloud/sdk/tutorial/Application.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.sap.cloud.sdk.tutorial; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.boot.builder.SpringApplicationBuilder; | ||
import org.springframework.boot.web.servlet.ServletComponentScan; | ||
import org.springframework.boot.web.support.SpringBootServletInitializer; | ||
|
||
@SpringBootApplication | ||
@ServletComponentScan( "com.sap.cloud.sdk" ) | ||
public class Application extends SpringBootServletInitializer | ||
{ | ||
@Override | ||
protected SpringApplicationBuilder configure( final SpringApplicationBuilder application ) | ||
{ | ||
return application.sources(Application.class); | ||
} | ||
|
||
public static void main( final String[] args ) | ||
{ | ||
SpringApplication.run(Application.class, args); | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
...application/src/main/java/com/sap/cloud/sdk/tutorial/command/CreateCostCenterCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package com.sap.cloud.sdk.tutorial.command; | ||
|
||
import com.netflix.config.ConfigurationManager; | ||
|
||
import java.util.List; | ||
|
||
import com.sap.cloud.sdk.s4hana.config.S4HanaConfig; | ||
import com.sap.cloud.sdk.s4hana.connectivity.ErpCommand; | ||
import com.sap.cloud.sdk.s4hana.connectivity.ErpConfigContext; | ||
import com.sap.cloud.sdk.s4hana.datamodel.bapi.services.CostCenterService; | ||
import com.sap.cloud.sdk.s4hana.datamodel.bapi.structures.CostCenterCreateInput; | ||
import com.sap.cloud.sdk.s4hana.datamodel.bapi.structures.ReturnParameter; | ||
import com.sap.cloud.sdk.s4hana.datamodel.bapi.types.CostCenter; | ||
import com.sap.cloud.sdk.s4hana.datamodel.bapi.types.CostCenterManager; | ||
import com.sap.cloud.sdk.s4hana.datamodel.bapi.types.CurrencyKey; | ||
import com.sap.cloud.sdk.s4hana.datamodel.bapi.types.IndicatorForCostCenterType; | ||
import com.sap.cloud.sdk.s4hana.datamodel.bapi.types.SetId; | ||
import com.sap.cloud.sdk.s4hana.serialization.ErpBoolean; | ||
import com.sap.cloud.sdk.tutorial.models.CostCenterDetails; | ||
|
||
import static com.sap.cloud.sdk.s4hana.config.S4HanaConfig.BAPI_SERIALIZATION_STRATEGY; | ||
|
||
public class CreateCostCenterCommand extends ErpCommand<List<ReturnParameter>> | ||
{ | ||
private final CostCenterDetails details; | ||
private final boolean testRun; | ||
|
||
public CreateCostCenterCommand( final ErpConfigContext configContext, final CostCenterDetails costCenterDetails, final boolean isTestRun) | ||
{ | ||
super(CreateCostCenterCommand.class, configContext); | ||
this.details = costCenterDetails; | ||
this.testRun = isTestRun; | ||
|
||
// for now use JSON | ||
ConfigurationManager.getConfigInstance().setProperty( | ||
BAPI_SERIALIZATION_STRATEGY, | ||
S4HanaConfig.RemoteFunctionSerializationStrategy.JSON); | ||
} | ||
|
||
@Override | ||
protected List<ReturnParameter> run() | ||
throws Exception | ||
{ | ||
final List<ReturnParameter> returnValues = | ||
CostCenterService | ||
.createMultiple( | ||
// Required parameter: ControllingArea | ||
details.getControllingArea(), | ||
// Required parameter: CostCenter Input | ||
CostCenterCreateInput | ||
.builder() | ||
.validFrom(CostCenterDetails.asLocalDate(details.getValidFrom())) | ||
.validTo(CostCenterDetails.asLocalDate(details.getValidTo())) | ||
.costcenter(new CostCenter(details.getId().getValue())) | ||
.name("SAP dummy") | ||
.currency(CurrencyKey.of("EUR")) | ||
.descript(details.getDescription()) | ||
.costcenterType(IndicatorForCostCenterType.of(details.getCategory())) | ||
.personInCharge(CostCenterManager.of(details.getPersonResponsible())) | ||
.costctrHierGrp(SetId.of(details.getCostCenterGroup())) | ||
.compCode(details.getCompanyCode()) | ||
.profitCtr(details.getProfitCenter()) | ||
.build()) | ||
.testRun(new ErpBoolean(testRun)) | ||
.execute(getConfigContext()) | ||
.getMessages(); | ||
|
||
return returnValues; | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
...CF/application/src/main/java/com/sap/cloud/sdk/tutorial/command/GetCostCenterCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package com.sap.cloud.sdk.tutorial.command; | ||
|
||
import com.google.common.cache.Cache; | ||
import com.google.common.cache.CacheBuilder; | ||
import org.slf4j.Logger; | ||
|
||
import java.util.List; | ||
|
||
import com.sap.cloud.sdk.cloudplatform.cache.CacheKey; | ||
import com.sap.cloud.sdk.cloudplatform.logging.CloudLoggerFactory; | ||
import com.sap.cloud.sdk.odatav2.connectivity.ODataQuery; | ||
import com.sap.cloud.sdk.odatav2.connectivity.ODataQueryBuilder; | ||
import com.sap.cloud.sdk.odatav2.connectivity.ODataQueryResult; | ||
import com.sap.cloud.sdk.s4hana.connectivity.CachingErpCommand; | ||
import com.sap.cloud.sdk.s4hana.connectivity.ErpConfigContext; | ||
import com.sap.cloud.sdk.s4hana.connectivity.exception.QueryExecutionException; | ||
import com.sap.cloud.sdk.tutorial.models.CostCenterDetails; | ||
|
||
|
||
public class GetCostCenterCommand extends CachingErpCommand<List<CostCenterDetails>> { | ||
private static final Logger logger = CloudLoggerFactory.getLogger(GetCostCenterCommand.class); | ||
|
||
public GetCostCenterCommand(final ErpConfigContext configContext) { | ||
super(GetCostCenterCommand.class, configContext); | ||
} | ||
|
||
private static final Cache<CacheKey, List<CostCenterDetails>> cache = | ||
CacheBuilder.newBuilder().concurrencyLevel(10).build(); | ||
|
||
@Override | ||
protected Cache<CacheKey, List<CostCenterDetails>> getCache() { | ||
return cache; | ||
} | ||
|
||
@Override | ||
protected CacheKey getCommandCacheKey() { | ||
return super.getCommandCacheKey().append(getConfigContext()); | ||
} | ||
|
||
@Override | ||
protected List<CostCenterDetails> runCacheable() throws QueryExecutionException { | ||
try { | ||
final ODataQuery query = ODataQueryBuilder | ||
.withEntity("/sap/opu/odata/sap/FCO_PI_COST_CENTER", "CostCenterCollection") | ||
.select("CostCenterID", | ||
"CostCenterDescription", | ||
"Status", | ||
"CompanyCode", | ||
"Category", | ||
"ValidityStartDate", | ||
"ValidityEndDate") | ||
.build(); | ||
|
||
final ODataQueryResult result = query.execute(getErpEndpoint()); | ||
return result.asList(CostCenterDetails.class); | ||
} catch (final Exception e) { | ||
throw new QueryExecutionException("Failed to get CostCenters from OData by using cached command.", e); | ||
} | ||
} | ||
|
||
public void resetCache() { | ||
cache.invalidate(getCommandCacheKey()); | ||
} | ||
} |
Oops, something went wrong.