Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 12 additions & 15 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
<exclusion>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
Expand Down Expand Up @@ -219,11 +223,6 @@
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.mosip.kernel</groupId>
<artifactId>kernel-websubclient-api</artifactId>
Expand Down Expand Up @@ -268,21 +267,19 @@
<artifactId>kernel-auth-adapter</artifactId>
<version>1.2.1-SNAPSHOT</version>
</dependency> -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${junit-jupiter.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-inline</artifactId>
<version>${mockito.inline.version}</version>
<scope>test</scope>
</dependency>

</dependencies>
</dependencies>

<repositories>
<repository>
Expand Down
52 changes: 24 additions & 28 deletions src/test/java/io/mosip/print/entity/BDBInfoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,24 @@
import java.util.Collections;
import java.util.List;

import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;

/**
* Unit tests for {@link BDBInfo}
* Unit tests for {@link BDBInfo}.
*/
class BDBInfoTest {

/**
* Test default constructor and check if all fields are null or empty.
* Verifies default constructor creates an object with all fields unset.
*/
@Test
void defaultConstructor() {
void verifyDefaultConstructor() {
BDBInfo info = new BDBInfo();
assertNotNull(info);
assertNull(info.getChallengeResponse());
assertNull(info.getIndex());
assertNull(info.getFormat());
Expand All @@ -49,12 +48,12 @@ void defaultConstructor() {
}

/**
* Test builder pattern and getter/setter methods for all fields.
* Verifies builder assigns all fields correctly.
*/
@Test
void builderAndGetterSetter() {
void verifyBuilderPopulatesFields() {
byte[] challengeResponse = {1, 2, 3};
String index = "1";
String index = "IDX";
RegistryIDType format = new RegistryIDType();
Boolean encryption = Boolean.TRUE;
LocalDateTime now = LocalDateTime.now();
Expand Down Expand Up @@ -109,42 +108,39 @@ void builderAndGetterSetter() {
}

/**
* Test equals() and hashCode() implementations for logical equality.
* Verifies equals and hashCode for multiple branches.
*/
@Test
void equalsAndHashCode() {
BDBInfo.BDBInfoBuilder builder = new BDBInfo.BDBInfoBuilder()
.withIndex("10");

BDBInfo info1 = builder.build();
BDBInfo info2 = builder.build();
void verifyEqualsAndHashCode() {
BDBInfo info1 = new BDBInfo.BDBInfoBuilder().withIndex("IDX").build();
BDBInfo info2 = new BDBInfo.BDBInfoBuilder().withIndex("IDX").build();
BDBInfo info3 = new BDBInfo.BDBInfoBuilder().withIndex("DIFF").build();

assertEquals(info1, info2);
assertEquals(info1.hashCode(), info2.hashCode());

BDBInfo info3 = new BDBInfo.BDBInfoBuilder().withIndex("20").build();
assertEquals(info1, info1);
assertNotEquals(info1, null);
assertNotEquals(info1, "string");
assertNotEquals(info1, info3);
assertNotEquals(info1.hashCode(), info3.hashCode());
}

/**
* Test toString() method for non-null and expected content.
* Verifies toString produces a non-empty representation.
*/
@Test
void toStringMethod() {
BDBInfo info = new BDBInfo.BDBInfoBuilder()
.withIndex("123")
.build();

String toString = info.toString();
assertNotNull(toString);
assertTrue(toString.contains("123"));
void verifyToString() {
BDBInfo info = new BDBInfo.BDBInfoBuilder().withIndex("123").build();
String out = info.toString();
assertNotNull(out);
assertTrue(out.contains("123"));
}

/**
* Test builder when all fields are set to null.
* Verifies builder behaves correctly when all values are null.
*/
@Test
void builderWithNullValues() {
void verifyBuilderWithNulls() {
BDBInfo info = new BDBInfo.BDBInfoBuilder()
.withChallengeResponse(null)
.withIndex(null)
Expand Down
Loading