From 1867131cfc43e7e004b1c23f676c76fd076ebe5b Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 12 Oct 2019 10:31:46 +0200 Subject: [PATCH] =?utf8?q?=F0=9F=8E=A8=20Remove=20inheritance=20from=20ide?= =?utf8?q?ntity=20events=20and=20replace=20with=20Kotlin=20versions?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../java/net/pterodactylus/sone/core/Core.java | 14 ++-- .../sone/freenet/wot/event/IdentityAddedEvent.java | 40 ----------- .../sone/freenet/wot/event/IdentityEvent.java | 83 ---------------------- .../freenet/wot/event/IdentityRemovedEvent.java | 40 ----------- .../freenet/wot/event/IdentityUpdatedEvent.java | 40 ----------- .../freenet/wot/event/OwnIdentityAddedEvent.java | 37 ---------- .../sone/freenet/wot/event/OwnIdentityEvent.java | 67 ----------------- .../freenet/wot/event/OwnIdentityRemovedEvent.java | 37 ---------- .../sone/freenet/wot/event/IdentityAddedEvent.kt | 25 +++++++ .../sone/freenet/wot/event/IdentityRemovedEvent.kt | 26 +++++++ .../sone/freenet/wot/event/IdentityUpdatedEvent.kt | 25 +++++++ .../freenet/wot/event/OwnIdentityAddedEvent.kt | 25 +++++++ .../freenet/wot/event/OwnIdentityRemovedEvent.kt | 25 +++++++ .../sone/freenet/wot/event/IdentityEventTest.java | 52 -------------- .../freenet/wot/event/OwnIdentityEventTest.java | 46 ------------ 15 files changed, 133 insertions(+), 449 deletions(-) delete mode 100644 src/main/java/net/pterodactylus/sone/freenet/wot/event/IdentityAddedEvent.java delete mode 100644 src/main/java/net/pterodactylus/sone/freenet/wot/event/IdentityEvent.java delete mode 100644 src/main/java/net/pterodactylus/sone/freenet/wot/event/IdentityRemovedEvent.java delete mode 100644 src/main/java/net/pterodactylus/sone/freenet/wot/event/IdentityUpdatedEvent.java delete mode 100644 src/main/java/net/pterodactylus/sone/freenet/wot/event/OwnIdentityAddedEvent.java delete mode 100644 src/main/java/net/pterodactylus/sone/freenet/wot/event/OwnIdentityEvent.java delete mode 100644 src/main/java/net/pterodactylus/sone/freenet/wot/event/OwnIdentityRemovedEvent.java create mode 100644 src/main/kotlin/net/pterodactylus/sone/freenet/wot/event/IdentityAddedEvent.kt create mode 100644 src/main/kotlin/net/pterodactylus/sone/freenet/wot/event/IdentityRemovedEvent.kt create mode 100644 src/main/kotlin/net/pterodactylus/sone/freenet/wot/event/IdentityUpdatedEvent.kt create mode 100644 src/main/kotlin/net/pterodactylus/sone/freenet/wot/event/OwnIdentityAddedEvent.kt create mode 100644 src/main/kotlin/net/pterodactylus/sone/freenet/wot/event/OwnIdentityRemovedEvent.kt delete mode 100644 src/test/java/net/pterodactylus/sone/freenet/wot/event/IdentityEventTest.java delete mode 100644 src/test/java/net/pterodactylus/sone/freenet/wot/event/OwnIdentityEventTest.java diff --git a/src/main/java/net/pterodactylus/sone/core/Core.java b/src/main/java/net/pterodactylus/sone/core/Core.java index c3af217..6bb664d 100644 --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@ -1582,7 +1582,7 @@ public class Core extends AbstractService implements SoneProvider, PostProvider, */ @Subscribe public void ownIdentityAdded(OwnIdentityAddedEvent ownIdentityAddedEvent) { - OwnIdentity ownIdentity = ownIdentityAddedEvent.ownIdentity(); + OwnIdentity ownIdentity = ownIdentityAddedEvent.getOwnIdentity(); logger.log(Level.FINEST, String.format("Adding OwnIdentity: %s", ownIdentity)); if (ownIdentity.hasContext("Sone")) { addLocalSone(ownIdentity); @@ -1597,7 +1597,7 @@ public class Core extends AbstractService implements SoneProvider, PostProvider, */ @Subscribe public void ownIdentityRemoved(OwnIdentityRemovedEvent ownIdentityRemovedEvent) { - OwnIdentity ownIdentity = ownIdentityRemovedEvent.ownIdentity(); + OwnIdentity ownIdentity = ownIdentityRemovedEvent.getOwnIdentity(); logger.log(Level.FINEST, String.format("Removing OwnIdentity: %s", ownIdentity)); trustedIdentities.removeAll(ownIdentity); } @@ -1610,9 +1610,9 @@ public class Core extends AbstractService implements SoneProvider, PostProvider, */ @Subscribe public void identityAdded(IdentityAddedEvent identityAddedEvent) { - Identity identity = identityAddedEvent.identity(); + Identity identity = identityAddedEvent.getIdentity(); logger.log(Level.FINEST, String.format("Adding Identity: %s", identity)); - trustedIdentities.put(identityAddedEvent.ownIdentity(), identity); + trustedIdentities.put(identityAddedEvent.getOwnIdentity(), identity); addRemoteSone(identity); } @@ -1624,7 +1624,7 @@ public class Core extends AbstractService implements SoneProvider, PostProvider, */ @Subscribe public void identityUpdated(IdentityUpdatedEvent identityUpdatedEvent) { - Identity identity = identityUpdatedEvent.identity(); + Identity identity = identityUpdatedEvent.getIdentity(); final Sone sone = getRemoteSone(identity.getId()); if (sone.isLocal()) { return; @@ -1648,8 +1648,8 @@ public class Core extends AbstractService implements SoneProvider, PostProvider, */ @Subscribe public void identityRemoved(IdentityRemovedEvent identityRemovedEvent) { - OwnIdentity ownIdentity = identityRemovedEvent.ownIdentity(); - Identity identity = identityRemovedEvent.identity(); + OwnIdentity ownIdentity = identityRemovedEvent.getOwnIdentity(); + Identity identity = identityRemovedEvent.getIdentity(); trustedIdentities.remove(ownIdentity, identity); for (Entry> trustedIdentity : trustedIdentities.asMap().entrySet()) { if (trustedIdentity.getKey().equals(ownIdentity)) { diff --git a/src/main/java/net/pterodactylus/sone/freenet/wot/event/IdentityAddedEvent.java b/src/main/java/net/pterodactylus/sone/freenet/wot/event/IdentityAddedEvent.java deleted file mode 100644 index 2d7ab32..0000000 --- a/src/main/java/net/pterodactylus/sone/freenet/wot/event/IdentityAddedEvent.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Sone - IdentityAddedEvent.java - Copyright © 2013–2019 David Roden - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package net.pterodactylus.sone.freenet.wot.event; - -import net.pterodactylus.sone.freenet.wot.Identity; -import net.pterodactylus.sone.freenet.wot.OwnIdentity; - -/** - * Event that signals that an {@link Identity} was added. - */ -public class IdentityAddedEvent extends IdentityEvent { - - /** - * Creates a new “identity added” event. - * - * @param ownIdentity - * The own identity that added the identity - * @param identity - * The identity that was added - */ - public IdentityAddedEvent(OwnIdentity ownIdentity, Identity identity) { - super(ownIdentity, identity); - } - -} diff --git a/src/main/java/net/pterodactylus/sone/freenet/wot/event/IdentityEvent.java b/src/main/java/net/pterodactylus/sone/freenet/wot/event/IdentityEvent.java deleted file mode 100644 index 8a23ae1..0000000 --- a/src/main/java/net/pterodactylus/sone/freenet/wot/event/IdentityEvent.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Sone - IdentityEvent.java - Copyright © 2013–2019 David Roden - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package net.pterodactylus.sone.freenet.wot.event; - -import net.pterodactylus.sone.freenet.wot.Identity; -import net.pterodactylus.sone.freenet.wot.OwnIdentity; - -/** - * Base class for {@link Identity} events. - */ -public abstract class IdentityEvent { - - /** The own identity this event relates to. */ - private final OwnIdentity ownIdentity; - - /** The identity this event is about. */ - private final Identity identity; - - /** - * Creates a new identity-based event. - * - * @param ownIdentity - * The own identity that relates to the identity - * @param identity - * The identity this event is about - */ - protected IdentityEvent(OwnIdentity ownIdentity, Identity identity) { - this.ownIdentity = ownIdentity; - this.identity = identity; - } - - // - // ACCESSORS - // - - /** - * Returns the own identity this event relates to. - * - * @return The own identity this event relates to - */ - public OwnIdentity ownIdentity() { - return ownIdentity; - } - - /** - * Returns the identity this event is about. - * - * @return The identity this event is about - */ - public Identity identity() { - return identity; - } - - @Override - public int hashCode() { - return ownIdentity().hashCode() ^ identity().hashCode(); - } - - @Override - public boolean equals(Object object) { - if ((object == null) || !object.getClass().equals(getClass())) { - return false; - } - IdentityEvent identityEvent = (IdentityEvent) object; - return ownIdentity().equals(identityEvent.ownIdentity()) && identity().equals(identityEvent.identity()); - } - -} diff --git a/src/main/java/net/pterodactylus/sone/freenet/wot/event/IdentityRemovedEvent.java b/src/main/java/net/pterodactylus/sone/freenet/wot/event/IdentityRemovedEvent.java deleted file mode 100644 index 655015e..0000000 --- a/src/main/java/net/pterodactylus/sone/freenet/wot/event/IdentityRemovedEvent.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Sone - IdentityRemovedEvent.java - Copyright © 2013–2019 David Roden - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package net.pterodactylus.sone.freenet.wot.event; - -import net.pterodactylus.sone.freenet.wot.Identity; -import net.pterodactylus.sone.freenet.wot.OwnIdentity; - -/** - * Event that signals that an {@link Identity} was removed. - */ -public class IdentityRemovedEvent extends IdentityEvent { - - /** - * Creates a new “identity removed” event. - * - * @param ownIdentity - * The own identity that removed the identity - * @param identity - * The identity that was removed - */ - public IdentityRemovedEvent(OwnIdentity ownIdentity, Identity identity) { - super(ownIdentity, identity); - } - -} diff --git a/src/main/java/net/pterodactylus/sone/freenet/wot/event/IdentityUpdatedEvent.java b/src/main/java/net/pterodactylus/sone/freenet/wot/event/IdentityUpdatedEvent.java deleted file mode 100644 index a71ad5b..0000000 --- a/src/main/java/net/pterodactylus/sone/freenet/wot/event/IdentityUpdatedEvent.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Sone - IdentityUpdatedEvent.java - Copyright © 2013–2019 David Roden - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package net.pterodactylus.sone.freenet.wot.event; - -import net.pterodactylus.sone.freenet.wot.Identity; -import net.pterodactylus.sone.freenet.wot.OwnIdentity; - -/** - * Event that signals that an {@link Identity} was updated. - */ -public class IdentityUpdatedEvent extends IdentityEvent { - - /** - * Creates a new “identity updated” event. - * - * @param ownIdentity - * The own identity that tracks the identity - * @param identity - * The identity that was updated - */ - public IdentityUpdatedEvent(OwnIdentity ownIdentity, Identity identity) { - super(ownIdentity, identity); - } - -} diff --git a/src/main/java/net/pterodactylus/sone/freenet/wot/event/OwnIdentityAddedEvent.java b/src/main/java/net/pterodactylus/sone/freenet/wot/event/OwnIdentityAddedEvent.java deleted file mode 100644 index fc34848..0000000 --- a/src/main/java/net/pterodactylus/sone/freenet/wot/event/OwnIdentityAddedEvent.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Sone - OwnIdentityAddedEvent.java - Copyright © 2013–2019 David Roden - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package net.pterodactylus.sone.freenet.wot.event; - -import net.pterodactylus.sone.freenet.wot.OwnIdentity; - -/** - * Event that signals that an {@link OwnIdentity} was added. - */ -public class OwnIdentityAddedEvent extends OwnIdentityEvent { - - /** - * Creates new “own identity added” event. - * - * @param ownIdentity - * The own identity that was added - */ - public OwnIdentityAddedEvent(OwnIdentity ownIdentity) { - super(ownIdentity); - } - -} diff --git a/src/main/java/net/pterodactylus/sone/freenet/wot/event/OwnIdentityEvent.java b/src/main/java/net/pterodactylus/sone/freenet/wot/event/OwnIdentityEvent.java deleted file mode 100644 index 9e88d20..0000000 --- a/src/main/java/net/pterodactylus/sone/freenet/wot/event/OwnIdentityEvent.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Sone - OwnIdentityEvent.java - Copyright © 2013–2019 David Roden - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package net.pterodactylus.sone.freenet.wot.event; - -import net.pterodactylus.sone.freenet.wot.OwnIdentity; - -/** - * Base class for {@link OwnIdentity} events. - */ -public abstract class OwnIdentityEvent { - - /** The own identity this event is about. */ - private final OwnIdentity ownIdentity; - - /** - * Creates a new own identity-based event. - * - * @param ownIdentity - * The own identity this event is about - */ - protected OwnIdentityEvent(OwnIdentity ownIdentity) { - this.ownIdentity = ownIdentity; - } - - // - // ACCESSORS - // - - /** - * Returns the own identity this event is about. - * - * @return The own identity this event is about - */ - public OwnIdentity ownIdentity() { - return ownIdentity; - } - - @Override - public int hashCode() { - return ownIdentity().hashCode(); - } - - @Override - public boolean equals(Object object) { - if ((object == null) || !object.getClass().equals(getClass())) { - return false; - } - OwnIdentityEvent ownIdentityEvent = (OwnIdentityEvent) object; - return ownIdentity().equals(ownIdentityEvent.ownIdentity()); - } - -} diff --git a/src/main/java/net/pterodactylus/sone/freenet/wot/event/OwnIdentityRemovedEvent.java b/src/main/java/net/pterodactylus/sone/freenet/wot/event/OwnIdentityRemovedEvent.java deleted file mode 100644 index 73761b0..0000000 --- a/src/main/java/net/pterodactylus/sone/freenet/wot/event/OwnIdentityRemovedEvent.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Sone - OwnIdentityRemovedEvent.java - Copyright © 2013–2019 David Roden - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package net.pterodactylus.sone.freenet.wot.event; - -import net.pterodactylus.sone.freenet.wot.OwnIdentity; - -/** - * Event that signals that an {@link OwnIdentity} was removed. - */ -public class OwnIdentityRemovedEvent extends OwnIdentityEvent { - - /** - * Creates a new “own identity removed” event. - * - * @param ownIdentity - * The own identity that was removed - */ - public OwnIdentityRemovedEvent(OwnIdentity ownIdentity) { - super(ownIdentity); - } - -} diff --git a/src/main/kotlin/net/pterodactylus/sone/freenet/wot/event/IdentityAddedEvent.kt b/src/main/kotlin/net/pterodactylus/sone/freenet/wot/event/IdentityAddedEvent.kt new file mode 100644 index 0000000..9fb2bbf --- /dev/null +++ b/src/main/kotlin/net/pterodactylus/sone/freenet/wot/event/IdentityAddedEvent.kt @@ -0,0 +1,25 @@ +/* + * Sone - IdentityAddedEvent.java - Copyright © 2013–2019 David Roden + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.pterodactylus.sone.freenet.wot.event + +import net.pterodactylus.sone.freenet.wot.* + +/** + * Event that signals that an [Identity] was added. + */ +data class IdentityAddedEvent(val ownIdentity: OwnIdentity, val identity: Identity) diff --git a/src/main/kotlin/net/pterodactylus/sone/freenet/wot/event/IdentityRemovedEvent.kt b/src/main/kotlin/net/pterodactylus/sone/freenet/wot/event/IdentityRemovedEvent.kt new file mode 100644 index 0000000..f8c9cd0 --- /dev/null +++ b/src/main/kotlin/net/pterodactylus/sone/freenet/wot/event/IdentityRemovedEvent.kt @@ -0,0 +1,26 @@ +/* + * Sone - IdentityRemovedEvent.java - Copyright © 2013–2019 David Roden + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.pterodactylus.sone.freenet.wot.event + +import net.pterodactylus.sone.freenet.wot.Identity +import net.pterodactylus.sone.freenet.wot.OwnIdentity + +/** + * Event that signals that an [Identity] was removed. + */ +data class IdentityRemovedEvent(val ownIdentity: OwnIdentity, val identity: Identity) diff --git a/src/main/kotlin/net/pterodactylus/sone/freenet/wot/event/IdentityUpdatedEvent.kt b/src/main/kotlin/net/pterodactylus/sone/freenet/wot/event/IdentityUpdatedEvent.kt new file mode 100644 index 0000000..40557d3 --- /dev/null +++ b/src/main/kotlin/net/pterodactylus/sone/freenet/wot/event/IdentityUpdatedEvent.kt @@ -0,0 +1,25 @@ +/* + * Sone - IdentityUpdatedEvent.java - Copyright © 2013–2019 David Roden + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.pterodactylus.sone.freenet.wot.event + +import net.pterodactylus.sone.freenet.wot.* + +/** + * Event that signals that an [Identity] was updated. + */ +data class IdentityUpdatedEvent(val ownIdentity: OwnIdentity, val identity: Identity) diff --git a/src/main/kotlin/net/pterodactylus/sone/freenet/wot/event/OwnIdentityAddedEvent.kt b/src/main/kotlin/net/pterodactylus/sone/freenet/wot/event/OwnIdentityAddedEvent.kt new file mode 100644 index 0000000..6f76564 --- /dev/null +++ b/src/main/kotlin/net/pterodactylus/sone/freenet/wot/event/OwnIdentityAddedEvent.kt @@ -0,0 +1,25 @@ +/* + * Sone - OwnIdentityAddedEvent.java - Copyright © 2013–2019 David Roden + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.pterodactylus.sone.freenet.wot.event + +import net.pterodactylus.sone.freenet.wot.OwnIdentity + +/** + * Event that signals that an [OwnIdentity] was added. + */ +data class OwnIdentityAddedEvent(val ownIdentity: OwnIdentity) diff --git a/src/main/kotlin/net/pterodactylus/sone/freenet/wot/event/OwnIdentityRemovedEvent.kt b/src/main/kotlin/net/pterodactylus/sone/freenet/wot/event/OwnIdentityRemovedEvent.kt new file mode 100644 index 0000000..7b0e3fe --- /dev/null +++ b/src/main/kotlin/net/pterodactylus/sone/freenet/wot/event/OwnIdentityRemovedEvent.kt @@ -0,0 +1,25 @@ +/* + * Sone - OwnIdentityRemovedEvent.java - Copyright © 2013–2019 David Roden + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.pterodactylus.sone.freenet.wot.event + +import net.pterodactylus.sone.freenet.wot.* + +/** + * Event that signals that an [OwnIdentity] was removed. + */ +data class OwnIdentityRemovedEvent(val ownIdentity: OwnIdentity) diff --git a/src/test/java/net/pterodactylus/sone/freenet/wot/event/IdentityEventTest.java b/src/test/java/net/pterodactylus/sone/freenet/wot/event/IdentityEventTest.java deleted file mode 100644 index 4fa5bc9..0000000 --- a/src/test/java/net/pterodactylus/sone/freenet/wot/event/IdentityEventTest.java +++ /dev/null @@ -1,52 +0,0 @@ -package net.pterodactylus.sone.freenet.wot.event; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.not; -import static org.mockito.Mockito.mock; - -import net.pterodactylus.sone.freenet.wot.Identity; -import net.pterodactylus.sone.freenet.wot.OwnIdentity; - -import org.junit.Test; - -/** - * Unit test for {@link IdentityEvent}. - */ -public class IdentityEventTest { - - private final OwnIdentity ownIdentity = mock(OwnIdentity.class); - private final Identity identity = mock(Identity.class); - private final IdentityEvent identityEvent = createIdentityEvent(ownIdentity, identity); - - private IdentityEvent createIdentityEvent(final OwnIdentity ownIdentity, final Identity identity) { - return new IdentityEvent(ownIdentity, identity) { - }; - } - - @Test - public void identityEventRetainsIdentities() { - assertThat(identityEvent.ownIdentity(), is(ownIdentity)); - assertThat(identityEvent.identity(), is(identity)); - } - - @Test - public void eventsWithTheSameIdentityHaveTheSameHashCode() { - IdentityEvent secondIdentityEvent = createIdentityEvent(ownIdentity, identity); - assertThat(identityEvent.hashCode(), is(secondIdentityEvent.hashCode())); - } - - @Test - public void eventsWithTheSameIdentitiesAreEqual() { - IdentityEvent secondIdentityEvent = createIdentityEvent(ownIdentity, identity); - assertThat(identityEvent, is(secondIdentityEvent)); - assertThat(secondIdentityEvent, is(identityEvent)); - } - - @Test - public void nullDoesNotEqualIdentityEvent() { - assertThat(identityEvent, not(is((Object) null))); - } - - -} diff --git a/src/test/java/net/pterodactylus/sone/freenet/wot/event/OwnIdentityEventTest.java b/src/test/java/net/pterodactylus/sone/freenet/wot/event/OwnIdentityEventTest.java deleted file mode 100644 index 3d27c34..0000000 --- a/src/test/java/net/pterodactylus/sone/freenet/wot/event/OwnIdentityEventTest.java +++ /dev/null @@ -1,46 +0,0 @@ -package net.pterodactylus.sone.freenet.wot.event; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.not; -import static org.mockito.Mockito.mock; - -import net.pterodactylus.sone.freenet.wot.OwnIdentity; - -import org.junit.Test; - -/** - * Unit test for {@link OwnIdentityEvent}. - */ -public class OwnIdentityEventTest { - - private final OwnIdentity ownIdentity = mock(OwnIdentity.class); - private final OwnIdentityEvent ownIdentityEvent = createOwnIdentityEvent(ownIdentity); - - @Test - public void eventRetainsOwnIdentity() { - assertThat(ownIdentityEvent.ownIdentity(), is(ownIdentity)); - } - - protected OwnIdentityEvent createOwnIdentityEvent(final OwnIdentity ownIdentity) { - return new OwnIdentityEvent(ownIdentity) { - }; - } - - @Test - public void twoOwnIdentityEventsWithTheSameIdentityHaveTheSameHashCode() { - OwnIdentityEvent secondOwnIdentityEvent = createOwnIdentityEvent(ownIdentity); - assertThat(secondOwnIdentityEvent.hashCode(), is(ownIdentityEvent.hashCode())); - } - - @Test - public void ownIdentityEventDoesNotMatchNull() { - assertThat(ownIdentityEvent, not(is((Object) null))); - } - - @Test - public void ownIdentityEventDoesNotMatchObjectWithADifferentClass() { - assertThat(ownIdentityEvent, not(is(new Object()))); - } - -} -- 2.7.4