Commit 52d66bf7 authored by Santi's avatar Santi

Modified datasets to add, delete and modify

parent 1498a048
...@@ -5,28 +5,40 @@ import es.uvigo.esei.daa.entities.Pet; ...@@ -5,28 +5,40 @@ import es.uvigo.esei.daa.entities.Pet;
import static java.util.Arrays.stream; import static java.util.Arrays.stream;
public final class PetsDataset { public final class PetsDataset {
private PetsDataset() {} private PetsDataset() {
}
public static Pet[] pets() {
return new Pet[] { public static Pet[] pets() {
new Pet(1, 1, "Tom"), return new Pet[]{
new Pet(2, 1, "Jerry") new Pet(1, 1, "Tom"),
}; new Pet(2, 1, "Jerry")
} };
}
public static Pet pet(int id) {
return stream(pets()) public static Pet pet(int id) {
.filter(p -> p.getId() == id) return stream(pets())
.findAny() .filter(p -> p.getId() == id)
.orElseThrow(IllegalArgumentException::new); .findAny()
} .orElseThrow(IllegalArgumentException::new);
public static int existentId() { }
return 1;
} public static int existentId() {
return 1;
public static Pet existentPet() { }
return pet(existentId());
} public static Pet existentPet() {
return pet(existentId());
}
public static String newName() { return "Nibbles";}
public static int newOwner() {
return 2;
}
public static Pet newPet() {
return new Pet(pets().length + 1, newOwner(), newName());
}
} }
...@@ -14,6 +14,11 @@ ...@@ -14,6 +14,11 @@
<people id="10" name="Juan" surname="Jiménez" /> <people id="10" name="Juan" surname="Jiménez" />
<people id="11" name="John" surname="Doe" /> <people id="11" name="John" surname="Doe" />
<pets id="1" owner="1" name="Tom"/>
<pets id="2" owner="1" name="Jerry"/>
<pets id="3" owner="2" name="Nibbles"/>
<users login="admin" password="713bfda78870bf9d1b261f565286f85e97ee614efe5f0faf7c34e7ca4f65baca" role="ADMIN"/> <users login="admin" password="713bfda78870bf9d1b261f565286f85e97ee614efe5f0faf7c34e7ca4f65baca" role="ADMIN"/>
<users login="normal" password="7bf24d6ca2242430343ab7e3efb89559a47784eea1123be989c1b2fb2ef66e83" role="USER" /> <users login="normal" password="7bf24d6ca2242430343ab7e3efb89559a47784eea1123be989c1b2fb2ef66e83" role="USER" />
</dataset> </dataset>
\ No newline at end of file
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
<people id="9" name="Julia" surname="Justa" /> <people id="9" name="Julia" surname="Justa" />
<people id="10" name="Juan" surname="Jiménez" /> <people id="10" name="Juan" surname="Jiménez" />
<pets id="2" owner="1" name="Jerry"/>
<users login="admin" password="713bfda78870bf9d1b261f565286f85e97ee614efe5f0faf7c34e7ca4f65baca" role="ADMIN"/> <users login="admin" password="713bfda78870bf9d1b261f565286f85e97ee614efe5f0faf7c34e7ca4f65baca" role="ADMIN"/>
<users login="normal" password="7bf24d6ca2242430343ab7e3efb89559a47784eea1123be989c1b2fb2ef66e83" role="USER" /> <users login="normal" password="7bf24d6ca2242430343ab7e3efb89559a47784eea1123be989c1b2fb2ef66e83" role="USER" />
</dataset> </dataset>
\ No newline at end of file
...@@ -13,6 +13,10 @@ ...@@ -13,6 +13,10 @@
<people id="9" name="Julia" surname="Justa" /> <people id="9" name="Julia" surname="Justa" />
<people id="10" name="Juan" surname="Jiménez" /> <people id="10" name="Juan" surname="Jiménez" />
<pets id="1" owner="2" name="Nibbles"/>
<pets id="2" owner="1" name="Jerry"/>
<users login="admin" password="713bfda78870bf9d1b261f565286f85e97ee614efe5f0faf7c34e7ca4f65baca" role="ADMIN"/> <users login="admin" password="713bfda78870bf9d1b261f565286f85e97ee614efe5f0faf7c34e7ca4f65baca" role="ADMIN"/>
<users login="normal" password="7bf24d6ca2242430343ab7e3efb89559a47784eea1123be989c1b2fb2ef66e83" role="USER" /> <users login="normal" password="7bf24d6ca2242430343ab7e3efb89559a47784eea1123be989c1b2fb2ef66e83" role="USER" />
</dataset> </dataset>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment