feat: first basic test

This commit is contained in:
Laureηt 2022-04-21 09:08:45 +02:00
parent 6bb8c7add9
commit 7358efe1d0
No known key found for this signature in database
GPG key ID: D88C6B294FD40994
3 changed files with 36 additions and 4 deletions

View file

@ -23,8 +23,11 @@ dependencies {
// Pour pouvoir parser le JSON // Pour pouvoir parser le JSON
implementation 'com.google.code.gson:gson:2.8.6' implementation 'com.google.code.gson:gson:2.8.6'
implementation 'org.hibernate:hibernate-core:5.4.30.Final' // implementation 'org.hibernate:hibernate-core:5.4.30.Final'
implementation 'mysql:mysql-connector-java:8.0.24' // implementation 'mysql:mysql-connector-java:8.0.24'
// des fonctions pratiques
implementation 'org.apache.commons:commons-lang3:3.0'
// Pour les tests // Pour les tests
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2' testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'

View file

@ -107,8 +107,9 @@ public class Pixel implements Serializable {
return false; return false;
} }
Pixel pixel = (Pixel) o; Pixel pixel = (Pixel) o;
return id.equals(pixel.id) && price == pixel.price && color == pixel.color return Objects.equals(id, pixel.id) && price == pixel.price && color == pixel.color
&& description.equals(pixel.description) && owner.equals(pixel.owner); && Objects.equals(description, pixel.description) && Objects.equals(owner, pixel.owner)
&& Objects.equals(transactions, pixel.transactions);
} }
@Override @Override

View file

@ -0,0 +1,28 @@
package com.pixels.beans;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.apache.commons.lang3.SerializationUtils;
public class PixelTest {
private static Pixel pixel;
@BeforeAll
public static void setUp() throws Exception {
pixel = new Pixel();
pixel.setId(123456789L);
pixel.setPrice(10);
}
@Test
public void beanIsSerializable() {
final byte[] serializedPixel = SerializationUtils.serialize(pixel);
final Pixel deserializedPixel = (Pixel) SerializationUtils.deserialize(serializedPixel);
assertEquals(pixel, deserializedPixel);
}
}