[JAVA-6455] Remove Lombok

This commit is contained in:
Haroon Khan 2021-11-18 13:23:25 +00:00
parent 9e22d43bab
commit e1331505c5
2 changed files with 51 additions and 4 deletions

View File

@ -1,15 +1,13 @@
package com.baeldung.h2db.springboot.models;
import lombok.Data;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.Objects;
@Table(name = "countries")
@Entity
@Data
public class Country {
@Id
@ -18,4 +16,42 @@ public class Country {
private String name;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
Country country = (Country) o;
return id == country.id && name.equals(country.name);
}
@Override
public int hashCode() {
return Objects.hash(id, name);
}
@Override
public String toString() {
return "Country{" +
"id=" + id +
", name='" + name + '\'' +
'}';
}
}

View File

@ -15,6 +15,8 @@ import static org.assertj.core.api.Assertions.assertThat;
@SpringBootTest(classes = SpringBootH2Application.class)
public class SpringBootH2IntegrationTest {
private static final Country AN_EXPECTED_COUNTRY = buildCountry();
@Autowired
private CountryRepository countryRepository;
@ -22,7 +24,16 @@ public class SpringBootH2IntegrationTest {
public void givenInitData_whenApplicationStarts_thenDataIsLoaded() {
Iterable<Country> users = countryRepository.findAll();
assertThat(users).hasSize(5);
assertThat(users)
.hasSize(5)
.contains(AN_EXPECTED_COUNTRY);
}
private static Country buildCountry() {
Country c = new Country();
c.setId(5);
c.setName("Canada");
return c;
}
}