Skip to content

Commit

Permalink
Added unit tests for enetities module
Browse files Browse the repository at this point in the history
  • Loading branch information
Aman Rajput committed Jan 7, 2024
1 parent 5df14c3 commit aef9254
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 0 deletions.
25 changes: 25 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
<log4j.version>2.17.1</log4j.version>
<bson.version>2.3</bson.version>
<fusionauth.version>5.3.0</fusionauth.version>
<junit.version>4.13.2</junit.version>
<mockito.version>5.8.0</mockito.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -92,6 +94,19 @@
<artifactId>aws-java-sdk-sts</artifactId>
<version>${amazonaws.version}</version>
</dependency>

<!-- Test dependencies -->

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>${mockito.version}</version>
</dependency>
</dependencies>

<build>
Expand All @@ -118,6 +133,16 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M8</version>
<configuration>
<includes>
<include>**/*Test.java</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</project>
60 changes: 60 additions & 0 deletions src/test/java/com/techorgx/api/entities/CustomerTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package com.techorgx.api.entities;

import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;

class CustomerTest {

@Test
void testCustomerConstructorAndToString() {
// Arrange
String username = "john.doe";
String firstName = "John";
String lastName = "Doe";
String address = "123 Main St";
String city = "Anytown";
String pincode = "12345";
String email = "john.doe@example.com";

// Act
Customer customer = new Customer(username, firstName, lastName, address, city, pincode, email);

// Assert
assertEquals(username, customer.getUsername());
assertEquals(firstName, customer.getFirstName());
assertEquals(lastName, customer.getLastName());
assertEquals(address, customer.getAddress());
assertEquals(city, customer.getCity());
assertEquals(pincode, customer.getPincode());
assertEquals(email, customer.getEmail());
assertEquals(
"Customer{" +
"username='" + username + '\'' +
", firstName='" + firstName + '\'' +
", lastName='" + lastName + '\'' +
", address='" + address + '\'' +
", city='" + city + '\'' +
", pincode='" + pincode + '\'' +
", email='" + email + '\'' +
'}',
customer.toString()
);
}

@Test
void testDefaultConstructor() {
// Arrange
Customer customer = new Customer();

// Act and Assert
// Ensure that the default constructor initializes the object
// You can add more specific assertions based on your requirements
assertEquals(null, customer.getUsername());
assertEquals(null, customer.getFirstName());
assertEquals(null, customer.getLastName());
assertEquals(null, customer.getAddress());
assertEquals(null, customer.getCity());
assertEquals(null, customer.getPincode());
assertEquals(null, customer.getEmail());
}
}

0 comments on commit aef9254

Please sign in to comment.