Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
241 changes: 120 additions & 121 deletions integration-tests/pom.xml
Original file line number Diff line number Diff line change
@@ -1,135 +1,134 @@
<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>
<?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>

<parent>
<groupId>my</groupId>
<artifactId>bookshop-parent</artifactId>
<version>${revision}</version>
</parent>
<parent>
<groupId>my</groupId>
<artifactId>bookshop-parent</artifactId>
<version>${revision}</version>
</parent>

<artifactId>bookshop-integration-tests</artifactId>
<artifactId>bookshop-integration-tests</artifactId>

<name>bookshop-integration-tests</name>
<name>bookshop-integration-tests</name>

<properties>
<sidecar.dir>../mtx/sidecar</sidecar.dir>
</properties>
<properties>
<sidecar.dir>../mtx/sidecar</sidecar.dir>
</properties>

<dependencies>
<dependency>
<groupId>my</groupId>
<artifactId>bookshop</artifactId>
<version>${revision}</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependencies>
<dependency>
<groupId>my</groupId>
<artifactId>bookshop</artifactId>
<version>${revision}</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.4</version>
<configuration>
<failIfNoTests>false</failIfNoTests>
</configuration>
</plugin>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.4</version>
<configuration>
<failIfNoTests>false</failIfNoTests>
</configuration>
</plugin>

<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<configuration>
<skipNativeTests>true</skipNativeTests>
</configuration>
</plugin>
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<configuration>
<skipNativeTests>true</skipNativeTests>
</configuration>
</plugin>

<plugin>
<!-- Tests ending with *IT.java will be executed here -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.5.4</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<!-- Tests ending with *IT.java will be executed here -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.5.4</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>com.sap.cds</groupId>
<artifactId>cds-maven-plugin</artifactId>
<version>${cds.services.version}</version>
<executions>
<execution>
<id>cds.install-node</id>
<goals>
<goal>install-node</goal>
</goals>
</execution>
<plugin>
<groupId>com.sap.cds</groupId>
<artifactId>cds-maven-plugin</artifactId>
<version>${cds.services.version}</version>
<executions>
<execution>
<id>cds.install-node</id>
<goals>
<goal>install-node</goal>
</goals>
</execution>

<execution>
<id>install-sidecar</id>
<goals>
<goal>npm</goal>
</goals>
<phase>pre-integration-test</phase>
<configuration>
<arguments>ci</arguments>
<skip>${skipTests}</skip>
<workingDirectory>${sidecar.dir}</workingDirectory>
</configuration>
</execution>
</executions>
</plugin>
<execution>
<id>install-sidecar</id>
<goals>
<goal>npm</goal>
</goals>
<phase>pre-integration-test</phase>
<configuration>
<arguments>ci</arguments>
<skip>${skipTests}</skip>
<workingDirectory>${sidecar.dir}</workingDirectory>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.6.3</version>
<executions>
<execution>
<phase>pre-integration-test</phase>
<id>start-sidecar</id>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>${cds.npm.executable}</executable>
<environmentVariables>
<PATH>${cds.node.directory}${path.separator}${env.PATH}</PATH>
</environmentVariables>
<skip>${skipTests}</skip>
<workingDirectory>${sidecar.dir}</workingDirectory>
<async>true</async>
<useMavenLogger>true</useMavenLogger>
<commandlineArgs>run start</commandlineArgs>
</configuration>
</plugin>
</plugins>
</build>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.6.3</version>
<configuration>
<executable>${cds.npm.executable}</executable>
<environmentVariables>
<PATH>${cds.node.directory}${path.separator}${env.PATH}</PATH>
</environmentVariables>
<skip>${skipTests}</skip>
<workingDirectory>${sidecar.dir}</workingDirectory>
<async>true</async>
<useMavenLogger>true</useMavenLogger>
<commandlineArgs>run start</commandlineArgs>
</configuration>
<executions>
<execution>
<id>start-sidecar</id>
<goals>
<goal>exec</goal>
</goals>
<phase>pre-integration-test</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -19,40 +19,40 @@
@SpringBootTest
class FeatureTogglesIT {

private static final String ENDPOINT = "/api/browse/Books(aebdfc8a-0dfa-4468-bd36-48aabd65e663)";

@Autowired
private MockMvc client;

@Test
@WithMockUser("authenticated") // This user has all feature toggles disabled
void withoutToggles_basicModelVisible() throws Exception {
// Elements are not visible and not changed by the event handler
client.perform(get(ENDPOINT))
.andExpect(status().isOk())
.andExpect(jsonPath("$.isbn").doesNotExist())
.andExpect(jsonPath("$.title").value(containsString("11%")));
}

@Test
@WithMockUser("admin") // This user has all feature toggles enabled
void togglesOn_extensionsAndChangesAreVisible() throws Exception {
// Elements are visible and changed by the event handler
client.perform(get(ENDPOINT))
.andExpect(status().isOk())
.andExpect(jsonPath("$.isbn").value("979-8669820985"))
.andExpect(jsonPath("$.title").value(containsString("14%")));
}

@Test
@WithMockUser("user") // This user has only 'isbn' toggle enabled
void toggleIsbnOn_extensionsAndChangesAreVisible() throws Exception {
// Elements are visible
client.perform(get(ENDPOINT))
.andExpect(status().isOk())
.andExpect(jsonPath("$.isbn").value("979-8669820985"))
.andExpect(jsonPath("$.title").value(containsString("11%")));
}

private static final String ENDPOINT = "/api/browse/Books(aebdfc8a-0dfa-4468-bd36-48aabd65e663)";

@Autowired private MockMvc client;

@Test
@WithMockUser("authenticated") // This user has all feature toggles disabled
void withoutToggles_basicModelVisible() throws Exception {
// Elements are not visible and not changed by the event handler
client
.perform(get(ENDPOINT))
.andExpect(status().isOk())
.andExpect(jsonPath("$.isbn").doesNotExist())
.andExpect(jsonPath("$.title").value(containsString("11%")));
}

@Test
@WithMockUser("admin") // This user has all feature toggles enabled
void togglesOn_extensionsAndChangesAreVisible() throws Exception {
// Elements are visible and changed by the event handler
client
.perform(get(ENDPOINT))
.andExpect(status().isOk())
.andExpect(jsonPath("$.isbn").value("979-8669820985"))
.andExpect(jsonPath("$.title").value(containsString("14%")));
}

@Test
@WithMockUser("user") // This user has only 'isbn' toggle enabled
void toggleIsbnOn_extensionsAndChangesAreVisible() throws Exception {
// Elements are visible
client
.perform(get(ENDPOINT))
.andExpect(status().isOk())
.andExpect(jsonPath("$.isbn").value("979-8669820985"))
.andExpect(jsonPath("$.title").value(containsString("11%")));
}
}

Loading