Q.1.4 Make use of a class named EstateAgent that contains methods to calculate estate agent

sales, estate agent commission, and the top-performing estate agent. The EstateAgent
class must implement an IEstateAgent interface that contains the following:
public interface IEstateAgent {
double EstateAgentSales(double[] propertySales);
double EstateAgentCommission(double propertySales);
int TopEstateAgent(double[] totalSales);
}
Q.1.5 You are required to write unit tests for the application. Create a test package within the
application you created, which will contain the necessary unit tests.
You are required to write the following unit tests:
Test Name Test Purpose
CalculateTotalSales_ReturnsTotalSales() To supply the property sales to the
estate agent sales method. The test
will determine that the correct total
sales value is returned from the estate
agent sales method.
CalculateTotalCommission_ReturnsCommission() To supply a total property sales
amount to the estate agent
commission method. The test will
determine that the correct estate
agent commission has been
calculated.
TopAgent_ReturnsTopPosition() To supply total sales for each estate
agent to the top estate agent method.
The test will determine the top selling
total property sales for the estate
agent..INCLUDE import method.In java.

Here is an example implementation of the EstateAgent class and the IEstateAgent interface in Java:

```java
import java.util.Arrays;

public class EstateAgent implements IEstateAgent {

@Override
public double EstateAgentSales(double[] propertySales) {
double totalSales = 0;
for (double sale : propertySales) {
totalSales += sale;
}
return totalSales;
}

@Override
public double EstateAgentCommission(double propertySales) {
return propertySales * 0.05; // Assume estate agent commission is 5%
}

@Override
public int TopEstateAgent(double[] totalSales) {
double maxSales = Double.MIN_VALUE;
int topAgent = -1;

for (int i = 0; i < totalSales.length; i++) {
if (totalSales[i] > maxSales) {
maxSales = totalSales[i];
topAgent = i;
}
}

return topAgent;
}
}
```

And here is an example of unit test cases in a separate test package:

```java
import org.junit.Test;
import static org.junit.Assert.assertEquals;

public class EstateAgentTest {

@Test
public void CalculateTotalSales_ReturnsTotalSales() {
EstateAgent estateAgent = new EstateAgent();
double[] propertySales = {100000, 200000, 300000};
double expectedTotalSales = 600000;

double actualTotalSales = estateAgent.EstateAgentSales(propertySales);

assertEquals(expectedTotalSales, actualTotalSales, 0);
}

@Test
public void CalculateTotalCommission_ReturnsCommission() {
EstateAgent estateAgent = new EstateAgent();
double propertySales = 500000;
double expectedCommission = 25000;

double actualCommission = estateAgent.EstateAgentCommission(propertySales);

assertEquals(expectedCommission, actualCommission, 0);
}

@Test
public void TopAgent_ReturnsTopPosition() {
EstateAgent estateAgent = new EstateAgent();
double[] totalSales = {500000, 700000, 300000};
int expectedTopPosition = 1;

int actualTopPosition = estateAgent.TopEstateAgent(totalSales);

assertEquals(expectedTopPosition, actualTopPosition);
}
}
```

Note that you will need to include the necessary testing framework in your project, such as JUnit, to run these unit tests.