Skip to content

Commit 333d2da

Browse files
more genres (#412)
1 parent a9db367 commit 333d2da

File tree

3 files changed

+73
-66
lines changed

3 files changed

+73
-66
lines changed

db/data/my.bookshop-Books.csv

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
ID;TITLE;DESCR;AUTHOR_ID;STOCK;PRICE;CURRENCY_CODE;GENRE_ID;RATING;ISBN
2-
f846b0b9-01d4-4f6d-82a4-d79204f62278;Wuthering Heights;"Wuthering Heights, Emily Brontë's only novel, was published in 1847 under the pseudonym ""Ellis Bell"". It was written between October 1845 and June 1846. Wuthering Heights and Anne Brontë's Agnes Grey were accepted by publisher Thomas Newby before the success of their sister Charlotte's novel Jane Eyre. After Emily's death, Charlotte edited the manuscript of Wuthering Heights and arranged for the edited version to be published as a posthumous second edition in 1850.";335c7bcd-b826-4f14-a788-e0bf6738617a;12;11.11;GBP;11;4.5;979-8698267973
3-
9b084139-0b1e-43b6-b12a-7b3669d75f02;Jane Eyre;"Jane Eyre /ɛər/ (originally published as Jane Eyre: An Autobiography) is a novel by English writer Charlotte Brontë, published under the pen name ""Currer Bell"", on 16 October 1847, by Smith, Elder & Co. of London. The first American edition was published the following year by Harper & Brothers of New York. Primarily a bildungsroman, Jane Eyre follows the experiences of its eponymous heroine, including her growth to adulthood and her love for Mr. Rochester, the brooding master of Thornfield Hall. The novel revolutionised prose fiction in that the focus on Jane's moral and spiritual development is told through an intimate, first-person narrative, where actions and events are coloured by a psychological intensity. The book contains elements of social criticism, with a strong sense of Christian morality at its core and is considered by many to be ahead of its time because of Jane's individualistic character and how the novel approaches the topics of class, sexuality, religion and feminism.";e3da2c2e-72ee-45d5-8def-52964c7b252a;11;12.34;GBP;11;3.0;979-8598716472
4-
51061ce3-ddde-4d70-a2dc-6314afbcc73e;The Raven;"“The Raven"" is a narrative poem by American writer Edgar Allan Poe. First published in January 1845, the poem is often noted for its musicality, stylized language, and supernatural atmosphere. It tells of a talking raven's mysterious visit to a distraught lover, tracing the man's slow fall into madness. The lover, often identified as being a student, is lamenting the loss of his love, Lenore. Sitting on a bust of Pallas, the raven seems to further distress the protagonist with its constant repetition of the word ""Nevermore"". The poem makes use of folk, mythological, religious, and classical references.";e7643aae-2d2f-4656-bb2d-1328ad3c8045;333;13.13;USD;16;2.5;978-1092909747
5-
aebdfc8a-0dfa-4468-bd36-48aabd65e663;Eleonora;"""Eleonora"" is a short story by Edgar Allan Poe, first published in 1842 in Philadelphia in the literary annual The Gift. It is often regarded as somewhat autobiographical and has a relatively ""happy"" ending.";e7643aae-2d2f-4656-bb2d-1328ad3c8045;555;14;USD;16;1.0;979-8669820985
6-
4a519e61-3c3a-4bd9-ab12-d7e0c5329933;Catweazle;Catweazle is a British fantasy television series, starring Geoffrey Bayldon in the title role, and created by Richard Carpenter for London Weekend Television. The first series, produced and directed by Quentin Lawrence, was screened in the UK on ITV in 1970. The second series, directed by David Reid and David Lane, was shown in 1971. Each series had thirteen episodes, most but not all written by Carpenter, who also published two books based on the scripts.;3c081d9d-abda-4da9-8b6a-4f4555bb26bc;22;15;EUR;13;4.0;978-3473523023
2+
f846b0b9-01d4-4f6d-82a4-d79204f62278;Wuthering Heights;"Wuthering Heights, Emily Brontë's only novel, was published in 1847 under the pseudonym ""Ellis Bell"". It was written between October 1845 and June 1846. Wuthering Heights and Anne Brontë's Agnes Grey were accepted by publisher Thomas Newby before the success of their sister Charlotte's novel Jane Eyre. After Emily's death, Charlotte edited the manuscript of Wuthering Heights and arranged for the edited version to be published as a posthumous second edition in 1850.";335c7bcd-b826-4f14-a788-e0bf6738617a;12;11.11;GBP;103;4.5;979-8698267973
3+
9b084139-0b1e-43b6-b12a-7b3669d75f02;Jane Eyre;"Jane Eyre /ɛər/ (originally published as Jane Eyre: An Autobiography) is a novel by English writer Charlotte Brontë, published under the pen name ""Currer Bell"", on 16 October 1847, by Smith, Elder & Co. of London. The first American edition was published the following year by Harper & Brothers of New York. Primarily a bildungsroman, Jane Eyre follows the experiences of its eponymous heroine, including her growth to adulthood and her love for Mr. Rochester, the brooding master of Thornfield Hall. The novel revolutionised prose fiction in that the focus on Jane's moral and spiritual development is told through an intimate, first-person narrative, where actions and events are coloured by a psychological intensity. The book contains elements of social criticism, with a strong sense of Christian morality at its core and is considered by many to be ahead of its time because of Jane's individualistic character and how the novel approaches the topics of class, sexuality, religion and feminism.";e3da2c2e-72ee-45d5-8def-52964c7b252a;11;12.34;GBP;103;3.0;979-8598716472
4+
51061ce3-ddde-4d70-a2dc-6314afbcc73e;The Raven;"“The Raven"" is a narrative poem by American writer Edgar Allan Poe. First published in January 1845, the poem is often noted for its musicality, stylized language, and supernatural atmosphere. It tells of a talking raven's mysterious visit to a distraught lover, tracing the man's slow fall into madness. The lover, often identified as being a student, is lamenting the loss of his love, Lenore. Sitting on a bust of Pallas, the raven seems to further distress the protagonist with its constant repetition of the word ""Nevermore"". The poem makes use of folk, mythological, religious, and classical references.";e7643aae-2d2f-4656-bb2d-1328ad3c8045;333;13.13;USD;117;2.5;978-1092909747
5+
aebdfc8a-0dfa-4468-bd36-48aabd65e663;Eleonora;"""Eleonora"" is a short story by Edgar Allan Poe, first published in 1842 in Philadelphia in the literary annual The Gift. It is often regarded as somewhat autobiographical and has a relatively ""happy"" ending.";e7643aae-2d2f-4656-bb2d-1328ad3c8045;555;14;USD;117;1.0;979-8669820985
6+
4a519e61-3c3a-4bd9-ab12-d7e0c5329933;Catweazle;Catweazle is a British fantasy television series, starring Geoffrey Bayldon in the title role, and created by Richard Carpenter for London Weekend Television. The first series, produced and directed by Quentin Lawrence, was screened in the UK on ITV in 1970. The second series, directed by David Reid and David Lane, was shown in 1971. Each series had thirteen episodes, most but not all written by Carpenter, who also published two books based on the scripts.;3c081d9d-abda-4da9-8b6a-4f4555bb26bc;22;15;EUR;110;4.0;978-3473523023

db/data/my.bookshop-Genres.csv

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,31 @@
11
ID;parent_ID;name
2-
10;;Fiction
3-
11;10;Drama
4-
12;10;Poetry
5-
13;10;Fantasy
6-
14;10;Science Fiction
7-
15;10;Romance
8-
16;10;Mystery
9-
17;10;Thriller
10-
18;10;Dystopia
11-
19;10;Fairy Tale
12-
20;;Non-Fiction
13-
21;20;Biography
14-
22;21;Autobiography
15-
23;20;Essay
16-
24;20;Speech
2+
100;;Fiction
3+
101;100;Action
4+
102;100;Adventure
5+
103;100;Drama
6+
105;100;Poetry
7+
106;100;Science Fiction
8+
107;106;Utopian and Dystopian
9+
108;107;Dystopia
10+
109;108;Cyberpunk
11+
110;109;Steampunk
12+
104;100;Fantasy
13+
111;104;Epic fantasy
14+
112;104;High fantasy
15+
113;100;Graphic Novel
16+
115;100;Short Story
17+
116;100;Romance
18+
117;100;Mystery
19+
123;117;Thriller
20+
124;117;Suspense
21+
118;100;Horror
22+
119;100;Historical Fiction
23+
120;100;Contemporary Fiction
24+
121;100;Magical Realism
25+
122;100;Literary Fiction
26+
128;100;Fairy Tale
27+
200;;Non-Fiction
28+
201;200;Biography
29+
202;201;Autobiography
30+
203;200;Essay
31+
204;200;Speech

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

Lines changed: 38 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ void testGetAll() throws Exception {
4242
void testCountAll() throws Exception {
4343
client.perform(get(genresURI + "/$count"))
4444
.andExpect(status().isOk())
45-
.andExpect(jsonPath("$").value(15));
45+
.andExpect(jsonPath("$").value(30));
4646
}
4747

4848
@Test
@@ -54,11 +54,11 @@ void testStartOneLevel() throws Exception {
5454
+ "com.sap.vocabularies.Hierarchy.v1.TopLevels(HierarchyNodes=$root/GenreHierarchy,HierarchyQualifier='GenreHierarchy',NodeProperty='ID',Levels=1)"
5555
+ "&$count=true"))
5656
.andExpect(status().isOk())
57-
.andExpect(jsonPath("$.value[0].ID").value(10))
57+
.andExpect(jsonPath("$.value[0].ID").value(100))
5858
.andExpect(jsonPath("$.value[0].name").value("Fiction"))
5959
.andExpect(jsonPath("$.value[0].DistanceFromRoot").value(0))
6060
.andExpect(jsonPath("$.value[0].DrillState").value("collapsed"))
61-
.andExpect(jsonPath("$.value[1].ID").value(20))
61+
.andExpect(jsonPath("$.value[1].ID").value(200))
6262
.andExpect(jsonPath("$.value[1].name").value("Non-Fiction"))
6363
.andExpect(jsonPath("$.value[1].DistanceFromRoot").value(0))
6464
.andExpect(jsonPath("$.value[1].DrillState").value("collapsed"))
@@ -74,36 +74,36 @@ void testStartTwoLevels() throws Exception {
7474
+ "com.sap.vocabularies.Hierarchy.v1.TopLevels(HierarchyNodes=$root/GenreHierarchy,HierarchyQualifier='GenreHierarchy',NodeProperty='ID',Levels=2)"
7575
+ "&$count=true"))
7676
.andExpect(status().isOk())
77-
.andExpect(jsonPath("$.value[0].ID").value(10))
77+
.andExpect(jsonPath("$.value[0].ID").value(100))
7878
.andExpect(jsonPath("$.value[0].name").value("Fiction"))
7979
.andExpect(jsonPath("$.value[0].DrillState").value("expanded"))
8080
.andExpect(jsonPath("$.value[0].DistanceFromRoot").value(0))
81-
.andExpect(jsonPath("$.value[1].ID").value(11))
82-
.andExpect(jsonPath("$.value[1].name").value("Drama"))
81+
.andExpect(jsonPath("$.value[1].ID").value(101))
82+
.andExpect(jsonPath("$.value[1].name").value("Action"))
8383
.andExpect(jsonPath("$.value[1].DrillState").value("leaf"))
8484
.andExpect(jsonPath("$.value[1].DistanceFromRoot").value(1))
85-
.andExpect(jsonPath("$.value[11].ID").value(21))
86-
.andExpect(jsonPath("$.value[11].name").value("Biography"))
87-
.andExpect(jsonPath("$.value[11].DrillState").value("collapsed"))
88-
.andExpect(jsonPath("$.value[11].DistanceFromRoot").value(1))
89-
.andExpect(jsonPath("$.value[14]").doesNotExist());
85+
.andExpect(jsonPath("$.value[20].ID").value(204))
86+
.andExpect(jsonPath("$.value[20].name").value("Speech"))
87+
.andExpect(jsonPath("$.value[20].DrillState").value("leaf"))
88+
.andExpect(jsonPath("$.value[20].DistanceFromRoot").value(1))
89+
.andExpect(jsonPath("$.value[21]").doesNotExist());
9090
}
9191

9292
@Test
9393
@WithMockUser(username = "admin")
9494
void testExpandNonFiction() throws Exception {
9595
client.perform(get(genresURI
9696
+ "?$select=DrillState,ID,name"
97-
+ "&$apply=descendants($root/GenreHierarchy,GenreHierarchy,ID,filter(ID eq 20),1)"
97+
+ "&$apply=descendants($root/GenreHierarchy,GenreHierarchy,ID,filter(ID eq 200),1)"
9898
+ "/orderby(ID)"))
9999
.andExpect(status().isOk())
100-
.andExpect(jsonPath("$.value[0].ID").value(21))
100+
.andExpect(jsonPath("$.value[0].ID").value(201))
101101
.andExpect(jsonPath("$.value[0].name").value("Biography"))
102102
.andExpect(jsonPath("$.value[0].DrillState").value("collapsed"))
103-
.andExpect(jsonPath("$.value[1].ID").value(23))
103+
.andExpect(jsonPath("$.value[1].ID").value(203))
104104
.andExpect(jsonPath("$.value[1].name").value("Essay"))
105105
.andExpect(jsonPath("$.value[1].DrillState").value("leaf"))
106-
.andExpect(jsonPath("$.value[2].ID").value(24))
106+
.andExpect(jsonPath("$.value[2].ID").value(204))
107107
.andExpect(jsonPath("$.value[2].name").value("Speech"))
108108
.andExpect(jsonPath("$.value[2].DrillState").value("leaf"))
109109
.andExpect(jsonPath("$.value[3]").doesNotExist());
@@ -134,15 +134,15 @@ void testExpandAll() throws Exception {
134134

135135
ResultActions expectations = client.perform(get(url))
136136
.andExpect(status().isOk())
137-
.andExpect(jsonPath("$.value[0].ID").value(10))
137+
.andExpect(jsonPath("$.value[0].ID").value(100))
138138
.andExpect(jsonPath("$.value[0].name").value("Fiction"))
139139
.andExpect(jsonPath("$.value[0].DrillState").value("expanded"))
140140
.andExpect(jsonPath("$.value[0].DistanceFromRoot").value(0))
141-
.andExpect(jsonPath("$.value[14].name").value("Speech"))
142-
.andExpect(jsonPath("$.value[14].DrillState").value("leaf"))
143-
.andExpect(jsonPath("$.value[15]").doesNotExist());
141+
.andExpect(jsonPath("$.value[29].name").value("Speech"))
142+
.andExpect(jsonPath("$.value[29].DrillState").value("leaf"))
143+
.andExpect(jsonPath("$.value[30]").doesNotExist());
144144
if (isOnHana()) {
145-
expectations.andExpect(jsonPath("$.value[0].LimitedDescendantCount").value(9));
145+
expectations.andExpect(jsonPath("$.value[0].LimitedDescendantCount").value(24));
146146
}
147147
}
148148

@@ -156,28 +156,29 @@ void testSearch() throws Exception {
156156
+ "/com.sap.vocabularies.Hierarchy.v1.TopLevels(HierarchyNodes=$root/GenreHierarchy,HierarchyQualifier='GenreHierarchy',NodeProperty='ID')"
157157
+ "&$count=true"))
158158
.andExpect(status().isOk())
159-
.andExpect(jsonPath("$.value[0].ID").value(10))
159+
.andExpect(jsonPath("$.value[0].ID").value(100))
160160
.andExpect(jsonPath("$.value[0].name").value("Fiction"))
161161
.andExpect(jsonPath("$.value[0].DrillState").value("expanded"))
162162
.andExpect(jsonPath("$.value[0].DistanceFromRoot").value(0))
163-
.andExpect(jsonPath("$.value[1].ID").value(19))
164-
.andExpect(jsonPath("$.value[1].name").value("Fairy Tale"))
163+
.andExpect(jsonPath("$.value[1].ID").value(120))
164+
.andExpect(jsonPath("$.value[1].name").value("Contemporary Fiction"))
165165
.andExpect(jsonPath("$.value[1].DrillState").value("leaf"))
166166
.andExpect(jsonPath("$.value[1].DistanceFromRoot").value(1))
167-
.andExpect(jsonPath("$.value[2].ID").value(16))
168-
.andExpect(jsonPath("$.value[2].name").value("Mystery"))
167+
.andExpect(jsonPath("$.value[2].ID").value(128))
168+
.andExpect(jsonPath("$.value[2].name").value("Fairy Tale"))
169169
.andExpect(jsonPath("$.value[2].DrillState").value("leaf"))
170170
.andExpect(jsonPath("$.value[2].DistanceFromRoot").value(1))
171-
.andExpect(jsonPath("$.value[3].ID").value(12))
172-
.andExpect(jsonPath("$.value[3].name").value("Poetry"))
173-
.andExpect(jsonPath("$.value[3].DrillState").value("leaf"))
174-
.andExpect(jsonPath("$.value[3].DistanceFromRoot").value(1))
175-
.andExpect(jsonPath("$.value[4]").doesNotExist());
171+
.andExpect(jsonPath("$.value[3].ID").value(122))
172+
.andExpect(jsonPath("$.value[6].name").value("Short Story"))
173+
.andExpect(jsonPath("$.value[6].DrillState").value("leaf"))
174+
.andExpect(jsonPath("$.value[6].DistanceFromRoot").value(1))
175+
.andExpect(jsonPath("$.value[7]").doesNotExist())
176+
;
176177
if (isOnHana()) {
177-
expectations.andExpect(jsonPath("$.value[0].LimitedDescendantCount").value(3))
178+
expectations.andExpect(jsonPath("$.value[0].LimitedDescendantCount").value(6))
178179
.andExpect(jsonPath("$.value[1].LimitedDescendantCount").value(0))
179180
.andExpect(jsonPath("$.value[2].LimitedDescendantCount").value(0))
180-
.andExpect(jsonPath("$.value[3].LimitedDescendantCount").value(0));
181+
.andExpect(jsonPath("$.value[6].LimitedDescendantCount").value(0));
181182
}
182183
}
183184

@@ -189,7 +190,7 @@ void testFilterNotExpanded() throws Exception {
189190
+ "&$apply=ancestors($root/GenreHierarchy,GenreHierarchy,ID,filter(name eq 'Autobiography'),keep start)/orderby(name)"
190191
+ "/com.sap.vocabularies.Hierarchy.v1.TopLevels(HierarchyNodes=$root/GenreHierarchy,HierarchyQualifier='GenreHierarchy',NodeProperty='ID',Levels=1)"))
191192
.andExpect(status().isOk())
192-
.andExpect(jsonPath("$.value[0].ID").value(20))
193+
.andExpect(jsonPath("$.value[0].ID").value(200))
193194
.andExpect(jsonPath("$.value[0].name").value("Non-Fiction"))
194195
.andExpect(jsonPath("$.value[0].DrillState").value("collapsed"))
195196
.andExpect(jsonPath("$.value[0].DistanceFromRoot").value(0))
@@ -228,19 +229,10 @@ void testStartTwoLevelsOrderByDescHANA() throws Exception {
228229
+ "com.sap.vocabularies.Hierarchy.v1.TopLevels(HierarchyNodes=$root/GenreHierarchy,HierarchyQualifier='GenreHierarchy',NodeProperty='ID',Levels=2)"
229230
+ "&$count=true"))
230231
.andExpect(status().isOk())
231-
.andExpect(jsonPath("$.value[0].ID").value(20))
232-
.andExpect(jsonPath("$.value[0].name").value("Non-Fiction"))
233-
.andExpect(jsonPath("$.value[0].DrillState").value("expanded"))
234-
.andExpect(jsonPath("$.value[0].DistanceFromRoot").value(0))
235-
.andExpect(jsonPath("$.value[1].ID").value(24))
236-
.andExpect(jsonPath("$.value[1].name").value("Speech"))
237-
.andExpect(jsonPath("$.value[1].DrillState").value("leaf"))
238-
.andExpect(jsonPath("$.value[1].DistanceFromRoot").value(1))
239-
.andExpect(jsonPath("$.value[3].ID").value(21))
240-
.andExpect(jsonPath("$.value[3].name").value("Biography"))
241-
.andExpect(jsonPath("$.value[3].DrillState").value("collapsed"))
242-
.andExpect(jsonPath("$.value[3].DistanceFromRoot").value(1))
243-
.andExpect(jsonPath("$.value[14]").doesNotExist());
232+
.andExpect(jsonPath("$.value[0].ID").value(200))
233+
.andExpect(jsonPath("$.value[1].ID").value(204))
234+
.andExpect(jsonPath("$.value[20].ID").value(101))
235+
.andExpect(jsonPath("$.value[21]").doesNotExist());
244236
}
245237

246238
private boolean isOnHana() {

0 commit comments

Comments
 (0)