Removed all left over example code

This commit is contained in:
Mei Chang van der Werff 2025-12-18 03:44:01 +01:00
commit a45f31abed
11 changed files with 0 additions and 829 deletions

View file

@ -1,63 +0,0 @@
/*
* Copyright 2021 Delft University of Technology
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package commons;
import static org.apache.commons.lang3.builder.ToStringStyle.MULTI_LINE_STYLE;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
@Entity
public class Person {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
public long id;
public String firstName;
public String lastName;
@SuppressWarnings("unused")
private Person() {
// for object mapper
}
public Person(String firstName, String lastName) {
this.firstName = firstName;
this.lastName = lastName;
}
@Override
public boolean equals(Object obj) {
return EqualsBuilder.reflectionEquals(this, obj);
}
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, MULTI_LINE_STYLE);
}
}

View file

@ -1,66 +0,0 @@
/*
* Copyright 2021 Delft University of Technology
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package commons;
import static org.apache.commons.lang3.builder.ToStringStyle.MULTI_LINE_STYLE;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import jakarta.persistence.CascadeType;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.OneToOne;
@Entity
public class Quote {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
public long id;
@OneToOne(cascade = CascadeType.PERSIST)
public Person person;
public String quote;
@SuppressWarnings("unused")
private Quote() {
// for object mappers
}
public Quote(Person person, String quote) {
this.person = person;
this.quote = quote;
}
@Override
public boolean equals(Object obj) {
return EqualsBuilder.reflectionEquals(this, obj);
}
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, MULTI_LINE_STYLE);
}
}

View file

@ -1,56 +0,0 @@
/*
* Copyright 2021 Delft University of Technology
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package commons;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
public class PersonTest {
@Test
public void checkConstructor() {
var p = new Person("f", "l");
assertEquals("f", p.firstName);
assertEquals("l", p.lastName);
}
@Test
public void equalsHashCode() {
var a = new Person("a", "b");
var b = new Person("a", "b");
assertEquals(a, b);
assertEquals(a.hashCode(), b.hashCode());
}
@Test
public void notEqualsHashCode() {
var a = new Person("a", "b");
var b = new Person("a", "c");
assertNotEquals(a, b);
assertNotEquals(a.hashCode(), b.hashCode());
}
@Test
public void hasToString() {
var actual = new Person("a", "b").toString();
assertTrue(actual.contains(Person.class.getSimpleName()));
assertTrue(actual.contains("\n"));
assertTrue(actual.contains("firstName"));
}
}

View file

@ -1,58 +0,0 @@
/*
* Copyright 2021 Delft University of Technology
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package commons;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
public class QuoteTest {
private static final Person SOME_PERSON = new Person("a", "b");
@Test
public void checkConstructor() {
var q = new Quote(SOME_PERSON, "q");
assertEquals(SOME_PERSON, q.person);
assertEquals("q", q.quote);
}
@Test
public void equalsHashCode() {
var a = new Quote(new Person("a", "b"), "c");
var b = new Quote(new Person("a", "b"), "c");
assertEquals(a, b);
assertEquals(a.hashCode(), b.hashCode());
}
@Test
public void notEqualsHashCode() {
var a = new Quote(new Person("a", "b"), "c");
var b = new Quote(new Person("a", "b"), "d");
assertNotEquals(a, b);
assertNotEquals(a.hashCode(), b.hashCode());
}
@Test
public void hasToString() {
var actual = new Quote(new Person("a", "b"), "c").toString();
assertTrue(actual.contains(Quote.class.getSimpleName()));
assertTrue(actual.contains("\n"));
assertTrue(actual.contains("person"));
}
}