generated from digitalservicebund/java-application-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove obsolete hashcode and equals implementation from inTransit record
- Loading branch information
Showing
4 changed files
with
66 additions
and
25 deletions.
There are no files selected for viewing
21 changes: 1 addition & 20 deletions
21
src/main/java/de/bund/digitalservice/a2j/repository/egvp/MessageInTransit.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,3 @@ | ||
package de.bund.digitalservice.a2j.repository.egvp; | ||
|
||
public record MessageInTransit(String userId, String customId, String bundIdMailbox) { | ||
|
||
public int hashCode() { | ||
|
||
return customId.hashCode(); | ||
} | ||
|
||
public boolean equals(Object obj) { | ||
if (obj == null) { | ||
return false; | ||
} | ||
|
||
if (obj.getClass() != this.getClass()) { | ||
return false; | ||
} | ||
|
||
return customId.equals(((MessageInTransit) obj).customId) | ||
&& userId.equals(((MessageInTransit) obj).userId); | ||
} | ||
} | ||
public record MessageInTransit(String userId, String customId, String bundIdMailbox) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
...va/de/bund/digitalservice/a2j/repository/egvp/MessageInTransitInMemoryRepositoryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package de.bund.digitalservice.a2j.repository.egvp; | ||
|
||
import java.util.List; | ||
import java.util.Set; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.springframework.test.context.junit.jupiter.SpringExtension; | ||
|
||
@ExtendWith(SpringExtension.class) | ||
public class MessageInTransitInMemoryRepositoryTest { | ||
|
||
MessagesInTransitInMemoryRepository repo; | ||
|
||
@BeforeEach | ||
void setup() { | ||
repo = new MessagesInTransitInMemoryRepository(); | ||
} | ||
|
||
@Test | ||
void deleteASpecificMessage() { | ||
MessageInTransit messageToBeDeleted = new MessageInTransit("userId", "customId2", "mailboxId"); | ||
|
||
List.of( | ||
new MessageInTransit("userId", "customId", "mailboxId"), | ||
new MessageInTransit("userId", "customId3", "mailboxId")) | ||
.forEach(m -> repo.add(m)); | ||
|
||
repo.removeAll(Set.of(messageToBeDeleted)); | ||
|
||
Assertions.assertFalse(repo.getAll().stream().anyMatch(m -> m.customId().equals("customId2"))); | ||
Assertions.assertEquals(2, repo.getAll().size()); | ||
} | ||
} |