Skip to content

Commit ae813c2

Browse files
committed
test in hybrid mode
1 parent 7e2153e commit ae813c2

File tree

2 files changed

+18
-15
lines changed

2 files changed

+18
-15
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ User Interface related Features:
9090
- [Model Localization](https://cap.cloud.sap/docs/guides/i18n) for [English](app/_i18n/i18n.properties) and [German](app/_i18n/i18n_de.properties) language for static texts
9191
- [Custom File Upload extension](app/admin/webapp/extension/Upload.js) which provides a button for uploading `CSV` files
9292
- A simple Swagger UI for the CatalogService API at <http://localhost:8080/swagger/index.html>
93+
- UI5 Tree Table
9394

9495
CDS Maven Plugin Features:
9596

@@ -138,6 +139,14 @@ are defined for local development:
138139
- User: `user`, password: `user` to browse books
139140
- User: `admin`, password: `admin` to manage books and orders
140141

142+
### Testing in hybrid mode
143+
144+
You can test the `GenreHierarchyTest` on H2 using the profile `default` as well as on HANA using the profile `hybrid`
145+
146+
```
147+
cds bind --exec -- mvn clean install -Dspring.profiles.active=hybrid
148+
```
149+
141150
## Using VS Code
142151

143152
VS Code supports the project out-of-the-box, when using the [Extension Pack for Java](https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-java-pack).

srv/src/test/java/my/bookshop/GenreHierarchyTest.java

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,11 @@
1010
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
1111
import org.springframework.boot.test.context.SpringBootTest;
1212
import org.springframework.security.test.context.support.WithMockUser;
13-
import org.springframework.test.context.ActiveProfiles;
1413
import org.springframework.test.web.servlet.MockMvc;
1514

1615
@SpringBootTest
1716
@AutoConfigureMockMvc
18-
@ActiveProfiles({"hybrid","default"})
17+
//@ActiveProfiles({"hybrid"})
1918
public class GenreHierarchyTest {
2019

2120
@Autowired
@@ -41,20 +40,19 @@ void testCountAll() throws Exception {
4140
@WithMockUser(username = "admin")
4241
void testStartOneLevel() throws Exception {
4342
client.perform(get(genresURI
44-
+ "?$select=DrillState,ID,name"
45-
+ "&$apply=com.sap.vocabularies.Hierarchy.v1.TopLevels(HierarchyNodes=$root/GenreHierarchy,HierarchyQualifier='GenreHierarchy',NodeProperty='ID',Levels=1)"
46-
+ "&$count=true&$skip=218&$top=20"))
43+
+ "?$select=DrillState,ID,name,DistanceFromRoot"
44+
+ "&$apply=orderby(name)/"
45+
+ "com.sap.vocabularies.Hierarchy.v1.TopLevels(HierarchyNodes=$root/GenreHierarchy,HierarchyQualifier='GenreHierarchy',NodeProperty='ID',Levels=1)"
46+
+ "&$count=true"))
4747
.andExpect(status().isOk())
4848
.andExpect(jsonPath("$.value[0].ID").value(10))
4949
.andExpect(jsonPath("$.value[0].name").value("Fiction"))
5050
.andExpect(jsonPath("$.value[0].DistanceFromRoot").value(0))
5151
.andExpect(jsonPath("$.value[0].DrillState").value("collapsed"))
52-
.andExpect(jsonPath("$.value[0].parnt_ID").isEmpty())
5352
.andExpect(jsonPath("$.value[1].ID").value(20))
5453
.andExpect(jsonPath("$.value[1].name").value("Non-Fiction"))
5554
.andExpect(jsonPath("$.value[1].DistanceFromRoot").value(0))
5655
.andExpect(jsonPath("$.value[1].DrillState").value("collapsed"))
57-
.andExpect(jsonPath("$.value[1].parnt_ID").isEmpty())
5856
.andExpect(jsonPath("$.value[2]").doesNotExist());
5957

6058
}
@@ -65,24 +63,17 @@ void testExpandNonFiction() throws Exception {
6563
client.perform(get(genresURI
6664
+ "?$select=DrillState,ID,name"
6765
+ "&$apply=descendants($root/GenreHierarchy,GenreHierarchy,ID,filter(ID eq 20),1)"
68-
+ "&$count=true&$skip=0&$top=218"))
66+
+ "/orderby(ID)"))
6967
.andExpect(status().isOk())
7068
.andExpect(jsonPath("$.value[0].ID").value(21))
7169
.andExpect(jsonPath("$.value[0].name").value("Biography"))
72-
// DistanceFromRoot: fix me?
73-
.andExpect(jsonPath("$.value[0].DistanceFromRoot").value(0))
7470
.andExpect(jsonPath("$.value[0].DrillState").value("collapsed"))
75-
.andExpect(jsonPath("$.value[0].parnt_ID").value(20))
7671
.andExpect(jsonPath("$.value[1].ID").value(23))
7772
.andExpect(jsonPath("$.value[1].name").value("Essay"))
78-
.andExpect(jsonPath("$.value[1].DistanceFromRoot").value(0))
7973
.andExpect(jsonPath("$.value[1].DrillState").value("leaf"))
80-
.andExpect(jsonPath("$.value[1].parnt_ID").value(20))
8174
.andExpect(jsonPath("$.value[2].ID").value(24))
8275
.andExpect(jsonPath("$.value[2].name").value("Speech"))
83-
.andExpect(jsonPath("$.value[2].DistanceFromRoot").value(0))
8476
.andExpect(jsonPath("$.value[2].DrillState").value("leaf"))
85-
.andExpect(jsonPath("$.value[2].parnt_ID").value(20))
8677
.andExpect(jsonPath("$.value[3]").doesNotExist());
8778
}
8879

@@ -109,8 +100,11 @@ void testExpandAll() throws Exception {
109100
+ "&$apply=com.sap.vocabularies.Hierarchy.v1.TopLevels(HierarchyNodes=$root/GenreHierarchy,HierarchyQualifier='GenreHierarchy',NodeProperty='ID')"
110101
+ "&$count=true&$skip=0&$top=238"))
111102
.andExpect(status().isOk())
103+
.andExpect(jsonPath("$.value[0].ID").value(10))
112104
.andExpect(jsonPath("$.value[0].name").value("Fiction"))
113105
.andExpect(jsonPath("$.value[0].DrillState").value("expanded"))
106+
.andExpect(jsonPath("$.value[0].DistanceFromRoot").value(0))
107+
.andExpect(jsonPath("$.value[0].LimitedDescendantCount").value(9))
114108
.andExpect(jsonPath("$.value[14].name").value("Speech"))
115109
.andExpect(jsonPath("$.value[14].DrillState").value("leaf"))
116110
.andExpect(jsonPath("$.value[15]").doesNotExist());

0 commit comments

Comments
 (0)