Skip to content

Commit d047f01

Browse files
committed
refactor: rename Contact to ContactCassandra and update related tests and repository interfaces
1 parent 1472d4c commit d047f01

File tree

5 files changed

+30
-30
lines changed

5 files changed

+30
-30
lines changed

jnosql-cassandra/src/test/java/org/eclipse/jnosql/databases/cassandra/mapping/CassandraColumnEntityConverterTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ public void shouldSupportUDT() {
283283
address.setCity("California");
284284
address.setStreet("Street");
285285

286-
Contact contact = new Contact();
286+
ContactCassandra contact = new ContactCassandra();
287287
contact.setAge(10);
288288
contact.setName("Ada");
289289
contact.setHome(address);
@@ -312,7 +312,7 @@ public void shouldSupportUDTToEntity() {
312312
.addUDT(columns).build();
313313
entity.add(udt);
314314

315-
Contact contact = converter.toEntity(entity);
315+
ContactCassandra contact = converter.toEntity(entity);
316316
assertNotNull(contact);
317317
Address home = contact.getHome();
318318
assertEquals("Poliana", contact.getName());

jnosql-cassandra/src/test/java/org/eclipse/jnosql/databases/cassandra/mapping/CassandraRepositoryProxyTest.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ public void setUp() {
6969
CassandraRepositoryProxy handler = new CassandraRepositoryProxy(template,
7070
HumanRepository.class, converters, entitiesMetadata);
7171

72-
when(template.insert(any(Contact.class))).thenReturn(new Contact());
73-
when(template.insert(any(Contact.class), any(Duration.class))).thenReturn(new Contact());
74-
when(template.update(any(Contact.class))).thenReturn(new Contact());
72+
when(template.insert(any(ContactCassandra.class))).thenReturn(new ContactCassandra());
73+
when(template.insert(any(ContactCassandra.class), any(Duration.class))).thenReturn(new ContactCassandra());
74+
when(template.update(any(ContactCassandra.class))).thenReturn(new ContactCassandra());
7575
this.personRepository = (HumanRepository) Proxy.newProxyInstance(HumanRepository.class.getClassLoader(),
7676
new Class[]{HumanRepository.class},
7777
handler);
@@ -114,45 +114,45 @@ public void shouldFindByName2CQL() {
114114

115115
@Test
116116
public void shouldSaveUsingInsert() {
117-
Contact contact = new Contact("Ada", 10);
117+
ContactCassandra contact = new ContactCassandra("Ada", 10);
118118
personRepository.save(contact);
119119
verify(template).insert(eq(contact));
120120
}
121121

122122
@Test
123123
public void shouldSaveUsingUpdate() {
124-
Contact contact = new Contact("Ada-2", 10);
125-
when(template.find(Contact.class, "Ada-2")).thenReturn(Optional.of(contact));
124+
ContactCassandra contact = new ContactCassandra("Ada-2", 10);
125+
when(template.find(ContactCassandra.class, "Ada-2")).thenReturn(Optional.of(contact));
126126
personRepository.save(contact);
127127
verify(template).update(eq(contact));
128128
}
129129

130130
@Test
131131
public void shouldDelete(){
132132
personRepository.deleteById("id");
133-
verify(template).delete(Contact.class, "id");
133+
verify(template).delete(ContactCassandra.class, "id");
134134
}
135135

136136

137137
@Test
138138
public void shouldDeleteEntity(){
139-
Contact contact = new Contact("Ada", 10);
139+
ContactCassandra contact = new ContactCassandra("Ada", 10);
140140
personRepository.delete(contact);
141-
verify(template).delete(Contact.class, contact.getName());
141+
verify(template).delete(ContactCassandra.class, contact.getName());
142142
}
143143

144-
interface HumanRepository extends CassandraRepository<Contact, String> {
144+
interface HumanRepository extends CassandraRepository<ContactCassandra, String> {
145145

146146
void deleteByName(String namel);
147147

148148
@CQL("select * from Person")
149-
List<Contact> findAllQuery();
149+
List<ContactCassandra> findAllQuery();
150150

151151
@CQL("select * from Person where name = ?")
152-
List<Contact> findByName(String name);
152+
List<ContactCassandra> findByName(String name);
153153

154154
@CQL("select * from Person where name = :name")
155-
List<Contact> findByName2(@Param("name") String name);
155+
List<ContactCassandra> findByName2(@Param("name") String name);
156156
}
157157

158158
}

jnosql-cassandra/src/test/java/org/eclipse/jnosql/databases/cassandra/mapping/Contact.java renamed to jnosql-cassandra/src/test/java/org/eclipse/jnosql/databases/cassandra/mapping/ContactCassandra.java

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

2424
@Entity
25-
public class Contact {
25+
public class ContactCassandra {
2626

2727
@Id("name")
2828
private String name;
@@ -57,19 +57,19 @@ public void setHome(Address home) {
5757
this.home = home;
5858
}
5959

60-
public Contact(String name, Integer age) {
60+
public ContactCassandra(String name, Integer age) {
6161
this.name = name;
6262
this.age = age;
6363
}
6464

65-
public Contact() {
65+
public ContactCassandra() {
6666
}
6767

6868
@Override
6969
public boolean equals(Object o) {
7070
if (this == o) return true;
7171
if (o == null || getClass() != o.getClass()) return false;
72-
Contact contact = (Contact) o;
72+
ContactCassandra contact = (ContactCassandra) o;
7373
return Objects.equals(name, contact.name) &&
7474
Objects.equals(age, contact.age);
7575
}

jnosql-cassandra/src/test/java/org/eclipse/jnosql/databases/cassandra/mapping/ContactRepository.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@
1818
import jakarta.data.repository.Repository;
1919

2020
@Repository
21-
public interface ContactRepository extends CassandraRepository<Contact, String> {
21+
public interface ContactRepository extends CassandraRepository<ContactCassandra, String> {
2222
}

jnosql-cassandra/src/test/java/org/eclipse/jnosql/databases/cassandra/mapping/DefaultCassandraTemplateTest.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ void shouldSaveConsistency() {
100100
save(Mockito.any(CommunicationEntity.class), Mockito.eq(level)))
101101
.thenReturn(entity);
102102

103-
Contact contact = new Contact();
103+
ContactCassandra contact = new ContactCassandra();
104104
contact.setName("Name");
105105
contact.setAge(20);
106106
assertEquals(contact, template.save(contact, level));
@@ -122,7 +122,7 @@ void shouldSaveConsistencyIterable() {
122122
save(Mockito.any(CommunicationEntity.class), Mockito.eq(level)))
123123
.thenReturn(entity);
124124

125-
Contact contact = new Contact();
125+
ContactCassandra contact = new ContactCassandra();
126126
contact.setName("Name");
127127
contact.setAge(20);
128128
assertThat(template.save(Collections.singletonList(contact), level)).contains(contact);
@@ -144,7 +144,7 @@ void shouldSaveConsistencyDuration() {
144144
Mockito.eq(level)))
145145
.thenReturn(entity);
146146

147-
Contact contact = new Contact();
147+
ContactCassandra contact = new ContactCassandra();
148148
contact.setName("Name");
149149
contact.setAge(20);
150150
assertEquals(contact, template.save(contact, duration, level));
@@ -166,7 +166,7 @@ void shouldSaveConsistencyDurationIterable() {
166166
Mockito.eq(level)))
167167
.thenReturn(entity);
168168

169-
Contact contact = new Contact();
169+
ContactCassandra contact = new ContactCassandra();
170170
contact.setName("Name");
171171
contact.setAge(20);
172172
assertThat(template.save(Collections.singletonList(contact), duration, level)).contains(contact);
@@ -186,7 +186,7 @@ void shouldDelete() {
186186

187187
@Test
188188
void shouldFind() {
189-
Contact contact = new Contact();
189+
ContactCassandra contact = new ContactCassandra();
190190
contact.setName("Name");
191191
contact.setAge(20);
192192

@@ -195,35 +195,35 @@ void shouldFind() {
195195
ConsistencyLevel level = ConsistencyLevel.THREE;
196196
when(manager.select(query, level)).thenReturn(Stream.of(entity));
197197

198-
Stream<Contact> people = template.find(query, level);
198+
Stream<ContactCassandra> people = template.find(query, level);
199199
assertThat(people.collect(Collectors.toList())).contains(contact);
200200
}
201201

202202
@Test
203203
void shouldFindCQL() {
204-
Contact contact = new Contact();
204+
ContactCassandra contact = new ContactCassandra();
205205
contact.setName("Name");
206206
contact.setAge(20);
207207
String cql = "select * from Person";
208208
CommunicationEntity entity = CommunicationEntity.of("Contact", asList(Element.of("name", "Name"), Element.of("age", 20)));
209209

210210
when(manager.cql(cql)).thenReturn(Stream.of(entity));
211211

212-
List<Contact> people = template.<Contact>cql(cql).collect(Collectors.toList());
212+
List<ContactCassandra> people = template.<ContactCassandra>cql(cql).collect(Collectors.toList());
213213
Assertions.assertThat(people).contains(contact);
214214
}
215215

216216
@Test
217217
void shouldFindSimpleStatement() {
218218
SimpleStatement statement = QueryBuilder.selectFrom("Contact").all().build();
219-
Contact contact = new Contact();
219+
ContactCassandra contact = new ContactCassandra();
220220
contact.setName("Name");
221221
contact.setAge(20);
222222
CommunicationEntity entity = CommunicationEntity.of("Contact", asList(Element.of("name", "Name"), Element.of("age", 20)));
223223

224224
when(manager.execute(statement)).thenReturn(Stream.of(entity));
225225

226-
List<Contact> people = template.<Contact>execute(statement).collect(Collectors.toList());
226+
List<ContactCassandra> people = template.<ContactCassandra>execute(statement).collect(Collectors.toList());
227227
Assertions.assertThat(people).contains(contact);
228228
}
229229

0 commit comments

Comments
 (0)