-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[AB2D-6147] increase ab2d-events-client
coverage
#399
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
72c5d32
test shells
coilysiren 5433b26
ApiRequestEventTest
coilysiren 723aa1c
ApiResponseEventTest, BeneficiarySearchEventTest
coilysiren 50b16b2
ContractSearchEventTest
coilysiren a0f1d4e
ErrorEventTest
coilysiren 8506544
FileEventTest
coilysiren cad8eec
SlackEvents
coilysiren 1a0a9ca
JobSummaryEventTest
coilysiren 723e445
ReloadEventTest
coilysiren 93961b3
final cleanups
coilysiren 850f7a1
LoggableEventTest
coilysiren 69e7cc1
Merge branch 'main' into AB2D-6147-p2
coilysiren File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
279 changes: 279 additions & 0 deletions
279
ab2d-events-client/src/test/java/gov/cms/ab2d/eventclient/events/LoggableEventTest.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,279 @@ | ||
package gov.cms.ab2d.eventclient.events; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import java.time.OffsetDateTime; | ||
import java.time.ZoneOffset; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import gov.cms.ab2d.eventclient.config.Ab2dEnvironment; | ||
|
||
class LoggableEventTest { | ||
|
||
// LoggableEvent is abstract, so we use a subclass instead | ||
class MockLoggableEvent extends LoggableEvent { | ||
public String asMessage() { | ||
return ""; | ||
} | ||
} | ||
|
||
@Test | ||
void testSetEnvironment() { | ||
LoggableEvent event = new MockLoggableEvent(); | ||
|
||
event.setEnvironment("example"); | ||
assertEquals("example", event.getEnvironment()); | ||
|
||
event.setEnvironment(Ab2dEnvironment.LOCAL); | ||
assertEquals("local", event.getEnvironment()); | ||
} | ||
|
||
@Test | ||
void testHashCodeCaseOne() { | ||
LoggableEvent event = new MockLoggableEvent(); | ||
assertEquals(437864549, event.hashCode()); | ||
} | ||
|
||
@Test | ||
void testHashCodeCaseTwo() { | ||
LoggableEvent event = new MockLoggableEvent(); | ||
event.setEnvironment("example"); | ||
event.setId(99L); | ||
event.setAwsId("AWS"); | ||
event.setTimeOfEvent(OffsetDateTime.of(1, 1, 1, 1, 1, 1, 1, ZoneOffset.of("Z"))); | ||
event.setOrganization("CMS"); | ||
event.setJobId("1234"); | ||
assertEquals(1726282058, event.hashCode()); | ||
} | ||
|
||
@Test | ||
void testEqualsCaseOne() { | ||
LoggableEvent event = new MockLoggableEvent(); | ||
assertEquals(true, event.equals(event)); | ||
} | ||
|
||
@Test | ||
void testEqualsCaseTwo() { | ||
LoggableEvent event = new MockLoggableEvent(); | ||
Object other = new LoggableEventTest(); | ||
assertEquals(false, event.equals(other)); | ||
} | ||
|
||
// testEqualsEnvironment // | ||
|
||
@Test | ||
void testEqualsEnvironmentCaseOne() { | ||
LoggableEvent event = new MockLoggableEvent(); | ||
LoggableEvent other = new MockLoggableEvent(); | ||
other.setEnvironment("example"); | ||
assertEquals(false, event.equals(other)); | ||
} | ||
|
||
@Test | ||
void testEqualsEnvironmentCaseTwo() { | ||
LoggableEvent event = new MockLoggableEvent(); | ||
LoggableEvent other = new MockLoggableEvent(); | ||
event.setEnvironment("example"); | ||
assertEquals(false, event.equals(other)); | ||
} | ||
|
||
@Test | ||
void testEqualsEnvironmentCaseThree() { | ||
LoggableEvent event = new MockLoggableEvent(); | ||
LoggableEvent other = new MockLoggableEvent(); | ||
event.setEnvironment("example1"); | ||
other.setEnvironment("example2"); | ||
assertEquals(false, event.equals(other)); | ||
} | ||
|
||
@Test | ||
void testEqualsEnvironmentCaseFour() { | ||
LoggableEvent event = new MockLoggableEvent(); | ||
LoggableEvent other = new MockLoggableEvent(); | ||
event.setEnvironment("example"); | ||
other.setEnvironment("example"); | ||
assertEquals(true, event.equals(other)); | ||
} | ||
|
||
// testEqualsId // | ||
|
||
@Test | ||
void testEqualsIdCaseOne() { | ||
LoggableEvent event = new MockLoggableEvent(); | ||
LoggableEvent other = new MockLoggableEvent(); | ||
other.setId(99L); | ||
assertEquals(false, event.equals(other)); | ||
} | ||
|
||
@Test | ||
void testEqualsIdCaseTwo() { | ||
LoggableEvent event = new MockLoggableEvent(); | ||
LoggableEvent other = new MockLoggableEvent(); | ||
event.setId(99L); | ||
assertEquals(false, event.equals(other)); | ||
} | ||
|
||
@Test | ||
void testEqualsIdCaseThree() { | ||
LoggableEvent event = new MockLoggableEvent(); | ||
LoggableEvent other = new MockLoggableEvent(); | ||
event.setId(1L); | ||
other.setId(2L); | ||
assertEquals(false, event.equals(other)); | ||
} | ||
|
||
@Test | ||
void testEqualsIdCaseFour() { | ||
LoggableEvent event = new MockLoggableEvent(); | ||
LoggableEvent other = new MockLoggableEvent(); | ||
event.setId(99L); | ||
other.setId(99L); | ||
assertEquals(true, event.equals(other)); | ||
} | ||
|
||
// testEqualsAwsId // | ||
|
||
@Test | ||
void testEqualsAwsIdCaseOne() { | ||
LoggableEvent event = new MockLoggableEvent(); | ||
LoggableEvent other = new MockLoggableEvent(); | ||
other.setAwsId("AWS"); | ||
assertEquals(false, event.equals(other)); | ||
} | ||
|
||
@Test | ||
void testEqualsAwsIdCaseTwo() { | ||
LoggableEvent event = new MockLoggableEvent(); | ||
LoggableEvent other = new MockLoggableEvent(); | ||
event.setAwsId("AWS"); | ||
assertEquals(false, event.equals(other)); | ||
} | ||
|
||
@Test | ||
void testEqualsAwsIdCaseThree() { | ||
LoggableEvent event = new MockLoggableEvent(); | ||
LoggableEvent other = new MockLoggableEvent(); | ||
event.setAwsId("AWS1"); | ||
other.setAwsId("AWS2"); | ||
assertEquals(false, event.equals(other)); | ||
} | ||
|
||
@Test | ||
void testEqualsAwsIdCaseFour() { | ||
LoggableEvent event = new MockLoggableEvent(); | ||
LoggableEvent other = new MockLoggableEvent(); | ||
event.setAwsId("AWS"); | ||
other.setAwsId("AWS"); | ||
assertEquals(true, event.equals(other)); | ||
} | ||
|
||
// testEqualsTime // | ||
|
||
@Test | ||
void testEqualsTimeCaseOne() { | ||
LoggableEvent event = new MockLoggableEvent(); | ||
LoggableEvent other = new MockLoggableEvent(); | ||
other.setTimeOfEvent(OffsetDateTime.of(1, 1, 1, 1, 1, 1, 1, ZoneOffset.of("Z"))); | ||
assertEquals(false, event.equals(other)); | ||
} | ||
|
||
@Test | ||
void testEqualsTimeCaseTwo() { | ||
LoggableEvent event = new MockLoggableEvent(); | ||
LoggableEvent other = new MockLoggableEvent(); | ||
event.setTimeOfEvent(OffsetDateTime.of(1, 1, 1, 1, 1, 1, 1, ZoneOffset.of("Z"))); | ||
assertEquals(false, event.equals(other)); | ||
} | ||
|
||
@Test | ||
void testEqualsTimeCaseThree() { | ||
LoggableEvent event = new MockLoggableEvent(); | ||
LoggableEvent other = new MockLoggableEvent(); | ||
event.setTimeOfEvent(OffsetDateTime.of(1, 1, 1, 1, 1, 1, 1, ZoneOffset.of("Z"))); | ||
other.setTimeOfEvent(OffsetDateTime.of(9, 9, 9, 9, 9, 9, 9, ZoneOffset.of("Z"))); | ||
assertEquals(false, event.equals(other)); | ||
} | ||
|
||
@Test | ||
void testEqualsTimeCaseFour() { | ||
LoggableEvent event = new MockLoggableEvent(); | ||
LoggableEvent other = new MockLoggableEvent(); | ||
event.setTimeOfEvent(OffsetDateTime.of(1, 1, 1, 1, 1, 1, 1, ZoneOffset.of("Z"))); | ||
other.setTimeOfEvent(OffsetDateTime.of(1, 1, 1, 1, 1, 1, 1, ZoneOffset.of("Z"))); | ||
assertEquals(true, event.equals(other)); | ||
} | ||
|
||
// testEqualsOrg // | ||
|
||
@Test | ||
void testEqualsOrgCaseOne() { | ||
LoggableEvent event = new MockLoggableEvent(); | ||
LoggableEvent other = new MockLoggableEvent(); | ||
other.setOrganization("CMS"); | ||
assertEquals(false, event.equals(other)); | ||
} | ||
|
||
@Test | ||
void testEqualsOrgCaseTwo() { | ||
LoggableEvent event = new MockLoggableEvent(); | ||
LoggableEvent other = new MockLoggableEvent(); | ||
event.setOrganization("CMS"); | ||
assertEquals(false, event.equals(other)); | ||
} | ||
|
||
@Test | ||
void testEqualsOrgCaseThree() { | ||
LoggableEvent event = new MockLoggableEvent(); | ||
LoggableEvent other = new MockLoggableEvent(); | ||
event.setOrganization("CMS1"); | ||
other.setOrganization("CMS2"); | ||
assertEquals(false, event.equals(other)); | ||
} | ||
|
||
@Test | ||
void testEqualsOrgCaseFour() { | ||
LoggableEvent event = new MockLoggableEvent(); | ||
LoggableEvent other = new MockLoggableEvent(); | ||
event.setOrganization("CMS"); | ||
other.setOrganization("CMS"); | ||
assertEquals(true, event.equals(other)); | ||
} | ||
|
||
// testEqualsJob // | ||
|
||
@Test | ||
void testEqualsJobCaseOne() { | ||
LoggableEvent event = new MockLoggableEvent(); | ||
LoggableEvent other = new MockLoggableEvent(); | ||
other.setJobId("1234"); | ||
assertEquals(false, event.equals(other)); | ||
} | ||
|
||
@Test | ||
void testEqualsJobCaseTwo() { | ||
LoggableEvent event = new MockLoggableEvent(); | ||
LoggableEvent other = new MockLoggableEvent(); | ||
event.setJobId("1234"); | ||
assertEquals(false, event.equals(other)); | ||
} | ||
|
||
@Test | ||
void testEqualsJobCaseThree() { | ||
LoggableEvent event = new MockLoggableEvent(); | ||
LoggableEvent other = new MockLoggableEvent(); | ||
event.setJobId("1234"); | ||
other.setJobId("9999"); | ||
assertEquals(false, event.equals(other)); | ||
} | ||
|
||
@Test | ||
void testEqualsJobCaseFour() { | ||
LoggableEvent event = new MockLoggableEvent(); | ||
LoggableEvent other = new MockLoggableEvent(); | ||
event.setJobId("1234"); | ||
other.setJobId("1234"); | ||
assertEquals(true, event.equals(other)); | ||
} | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found this missing null check when writing the tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you plan to increase library version? may be later?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, thanks for catching that @smirnovaae! I forgot that part. I'll do it in another PR.