Skip to content

Commit af3e735

Browse files
committed
feat: rename and update entities
Signed-off-by: Otavio Santana <[email protected]>
1 parent 9d69776 commit af3e735

File tree

5 files changed

+55
-55
lines changed

5 files changed

+55
-55
lines changed

jnosql-oracle-nosql/src/test/java/org/eclipse/jnosql/databases/oracle/integration/BeerBuilder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public BeerBuilder data(Map<String, Object> data) {
4343
return this;
4444
}
4545

46-
public Beer build() {
47-
return new Beer(id, comments, crew, data);
46+
public Wine build() {
47+
return new Wine(id, comments, crew, data);
4848
}
4949
}

jnosql-oracle-nosql/src/test/java/org/eclipse/jnosql/databases/oracle/integration/Book.java renamed to jnosql-oracle-nosql/src/test/java/org/eclipse/jnosql/databases/oracle/integration/Magazine.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import java.util.Objects;
2222

2323
@Entity
24-
public class Book {
24+
public class Magazine {
2525

2626
@Id
2727
private String id;
@@ -32,13 +32,13 @@ public class Book {
3232
@Column("edition")
3333
private int edition;
3434

35-
public Book(String id, String title, int edition) {
35+
public Magazine(String id, String title, int edition) {
3636
this.id = id;
3737
this.title = title;
3838
this.edition = edition;
3939
}
4040

41-
Book() {
41+
Magazine() {
4242
}
4343

4444
public String id() {
@@ -57,10 +57,10 @@ public int edition() {
5757
public boolean equals(Object o) {
5858
if (this == o) return true;
5959
if (o == null || getClass() != o.getClass()) return false;
60-
Book book = (Book) o;
61-
return edition == book.edition
62-
&& Objects.equals(id, book.id)
63-
&& Objects.equals(title, book.title);
60+
Magazine magazine = (Magazine) o;
61+
return edition == magazine.edition
62+
&& Objects.equals(id, magazine.id)
63+
&& Objects.equals(title, magazine.title);
6464
}
6565

6666
@Override

jnosql-oracle-nosql/src/test/java/org/eclipse/jnosql/databases/oracle/integration/OracleNoSQLTemplateIntegrationTest.java

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343
@EnableAutoWeld
4444
@AddPackages(value = {Database.class, EntityConverter.class, DocumentTemplate.class})
45-
@AddPackages(Book.class)
45+
@AddPackages(Magazine.class)
4646
@AddPackages(OracleNoSQLTemplate.class)
4747
@AddExtensions({EntityMetadataExtension.class,
4848
DocumentExtension.class})
@@ -61,79 +61,79 @@ class OracleNoSQLTemplateIntegrationTest {
6161

6262
@Test
6363
void shouldInsert() {
64-
Book book = new Book(randomUUID().toString(), "Effective Java", 1);
65-
template.insert(book);
66-
Optional<Book> optional = template.find(Book.class, book.id());
64+
Magazine magazine = new Magazine(randomUUID().toString(), "Effective Java", 1);
65+
template.insert(magazine);
66+
Optional<Magazine> optional = template.find(Magazine.class, magazine.id());
6767
assertThat(optional).isNotNull().isNotEmpty()
68-
.get().isEqualTo(book);
68+
.get().isEqualTo(magazine);
6969
}
7070

7171
@Test
7272
void shouldUpdate() {
73-
Book book = new Book(randomUUID().toString(), "Effective Java", 1);
74-
assertThat(template.insert(book))
73+
Magazine magazine = new Magazine(randomUUID().toString(), "Effective Java", 1);
74+
assertThat(template.insert(magazine))
7575
.isNotNull()
76-
.isEqualTo(book);
76+
.isEqualTo(magazine);
7777

78-
Book updated = new Book(book.id(), book.title() + " updated", 2);
78+
Magazine updated = new Magazine(magazine.id(), magazine.title() + " updated", 2);
7979

8080
assertThat(template.update(updated))
8181
.isNotNull()
82-
.isNotEqualTo(book);
82+
.isNotEqualTo(magazine);
8383

84-
assertThat(template.find(Book.class, book.id()))
84+
assertThat(template.find(Magazine.class, magazine.id()))
8585
.isNotNull().get().isEqualTo(updated);
8686

8787
}
8888

8989
@Test
9090
void shouldFindById() {
91-
Book book = new Book(randomUUID().toString(), "Effective Java", 1);
92-
assertThat(template.insert(book))
91+
Magazine magazine = new Magazine(randomUUID().toString(), "Effective Java", 1);
92+
assertThat(template.insert(magazine))
9393
.isNotNull()
94-
.isEqualTo(book);
94+
.isEqualTo(magazine);
9595

96-
assertThat(template.find(Book.class, book.id()))
97-
.isNotNull().get().isEqualTo(book);
96+
assertThat(template.find(Magazine.class, magazine.id()))
97+
.isNotNull().get().isEqualTo(magazine);
9898
}
9999

100100
@Test
101101
void shouldDelete() {
102-
Book book = new Book(randomUUID().toString(), "Effective Java", 1);
103-
assertThat(template.insert(book))
102+
Magazine magazine = new Magazine(randomUUID().toString(), "Effective Java", 1);
103+
assertThat(template.insert(magazine))
104104
.isNotNull()
105-
.isEqualTo(book);
105+
.isEqualTo(magazine);
106106

107-
template.delete(Book.class, book.id());
108-
assertThat(template.find(Book.class, book.id()))
107+
template.delete(Magazine.class, magazine.id());
108+
assertThat(template.find(Magazine.class, magazine.id()))
109109
.isNotNull().isEmpty();
110110
}
111111

112112
@Test
113113
void shouldDeleteAll(){
114114
for (int index = 0; index < 20; index++) {
115-
Book book = new Book(randomUUID().toString(), "Effective Java", 1);
116-
assertThat(template.insert(book))
115+
Magazine magazine = new Magazine(randomUUID().toString(), "Effective Java", 1);
116+
assertThat(template.insert(magazine))
117117
.isNotNull()
118-
.isEqualTo(book);
118+
.isEqualTo(magazine);
119119
}
120120

121-
template.delete(Book.class).execute();
122-
assertThat(template.select(Book.class).result()).isEmpty();
121+
template.delete(Magazine.class).execute();
122+
assertThat(template.select(Magazine.class).result()).isEmpty();
123123
}
124124

125125

126126
@Test
127127
void shouldUpdateNullValues(){
128-
var book = new Book(randomUUID().toString(), "Effective Java", 1);
128+
var book = new Magazine(randomUUID().toString(), "Effective Java", 1);
129129
template.insert(book);
130-
template.update(new Book(book.id(), null, 2));
131-
Optional<Book> optional = template.select(Book.class).where("id")
130+
template.update(new Magazine(book.id(), null, 2));
131+
Optional<Magazine> optional = template.select(Magazine.class).where("id")
132132
.eq(book.id()).singleResult();
133133
SoftAssertions.assertSoftly(softly -> {
134134
softly.assertThat(optional).isPresent();
135-
softly.assertThat(optional).get().extracting(Book::title).isNull();
136-
softly.assertThat(optional).get().extracting(Book::edition).isEqualTo(2);
135+
softly.assertThat(optional).get().extracting(Magazine::title).isNull();
136+
softly.assertThat(optional).get().extracting(Magazine::edition).isEqualTo(2);
137137
});
138138
}
139139

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import java.util.Objects;
2424

2525
@Entity
26-
public class Beer {
26+
public class Wine {
2727

2828
@Id
2929
private String id;
@@ -54,10 +54,10 @@ public Map<String, Object> data() {
5454
return data;
5555
}
5656

57-
Beer() {
57+
Wine() {
5858
}
5959

60-
Beer(String id, List<String> comments, List<Crew> crew, Map<String, Object> data) {
60+
Wine(String id, List<String> comments, List<Crew> crew, Map<String, Object> data) {
6161
this.id = id;
6262
this.comments = comments;
6363
this.crew = crew;
@@ -82,8 +82,8 @@ public boolean equals(Object o) {
8282
if (o == null || getClass() != o.getClass()) {
8383
return false;
8484
}
85-
Beer beer = (Beer) o;
86-
return Objects.equals(id, beer.id);
85+
Wine wine = (Wine) o;
86+
return Objects.equals(id, wine.id);
8787
}
8888

8989
@Override
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@
4343

4444
@EnableAutoWeld
4545
@AddPackages(value = {Database.class, EntityConverter.class, DocumentTemplate.class})
46-
@AddPackages(Beer.class)
46+
@AddPackages(Wine.class)
4747
@AddPackages(OracleNoSQLTemplate.class)
4848
@AddExtensions({EntityMetadataExtension.class,
4949
DocumentExtension.class})
5050
@AddPackages(Reflections.class)
5151
@AddPackages(Converters.class)
5252
@EnabledIfSystemProperty(named = NAMED, matches = MATCHES)
53-
class BeerTemplateIntegrationTest {
53+
class WineTemplateIntegrationTest {
5454

5555
@Inject
5656
private OracleNoSQLTemplate template;
@@ -63,24 +63,24 @@ class BeerTemplateIntegrationTest {
6363
@Test
6464
void shouldInsert() {
6565

66-
Beer beer = Beer.builder()
66+
Wine wine = Wine.builder()
6767
.id(UUID.randomUUID().toString())
6868
.data(Map.of("name", "beer"))
6969
.comments(List.of("comment1", "comment2"))
7070
.crew(List.of(new Crew("Otavio")))
7171
.build();
7272

73-
this.template.insert(beer);
73+
this.template.insert(wine);
7474

75-
Optional<Beer> result = this.template.select(Beer.class).where("id").eq(beer.id()).singleResult();
75+
Optional<Wine> result = this.template.select(Wine.class).where("id").eq(wine.id()).singleResult();
7676

7777
SoftAssertions.assertSoftly(soft ->{
7878
soft.assertThat(result).isPresent();
79-
Beer updateBeer = result.orElseThrow();
80-
soft.assertThat(updateBeer.id()).isEqualTo(beer.id());
81-
soft.assertThat(updateBeer.data()).isEqualTo(beer.data());
82-
soft.assertThat(updateBeer.comments()).isEqualTo(beer.comments());
83-
soft.assertThat(updateBeer.crew()).isEqualTo(beer.crew());
79+
Wine updateWine = result.orElseThrow();
80+
soft.assertThat(updateWine.id()).isEqualTo(wine.id());
81+
soft.assertThat(updateWine.data()).isEqualTo(wine.data());
82+
soft.assertThat(updateWine.comments()).isEqualTo(wine.comments());
83+
soft.assertThat(updateWine.crew()).isEqualTo(wine.crew());
8484
});
8585

8686
}

0 commit comments

Comments
 (0)