Your line manager has instructed you to write unit tests to determine the code coverage in the student management application. You are required to create a test package within the application you created in Section A, which will contain the required unit tests.

You are required to write the following unit tests:

TEST NAME: TEST PURPOSE:
TESTSAVESTUDENT(). To supply the student ID, name, age,email,and course to the save the student method.The test will determine whether the correct student will be save to memory.
TEST NAME : Test Purpose:
TestSearchStudent(). To supply the student id to the search student method.The test will determine that the correct student details have been returned.
TEST NAME: TEST PURPOSE:
TestSearchStudent_StudentNotFound(): To supply an incorrect student ID to the search method.The test will determine that no student no student was found
TEST NAME: TEST PURPOSE:
TestDeleteStudent(). To supply the student ID to the delete student method.The test will determine that the student has been successfully deleted.
TEST NAME: TEST PURPOSE:
TestDeleteStudent_StudentNotFound(). TO supply an incorrect student ID to the delete student method .The test will determine that no student could be found to delete.
TEST NAME: TEST PURPOSE:
TestStudentAge_StudentAgeValid(). To supply a valid student age to the student age method.The test will determine that the student age is valid.
TEST NAME: TEST PURPOSE:
TestStudentAge_StudentAgeInvalid(). To supply an invalid student age to the student age method.The test will determine that the students age is less than 16.
TEST NAME: TEST PURPOSE:
TestStudentAge_StudentAgeInvalidCharacter(). To supply an invalid character to the student age method.The test will determine that the student age supplied is not a number.

In java

import static org.junit.Assert.assertEquals;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;

import org.junit.Before;
import org.junit.Test;

public class StudentManagementApplicationTest {
private StudentManagementApplication studentManagementApplication;

@Before
public void setUp() {
studentManagementApplication = new StudentManagementApplication();
}

@Test
public void testSaveStudent() {
String studentId = "123";
String name = "John Doe";
int age = 20;
String email = "johndoe";
String course = "Computer Science";

studentManagementApplication.saveStudent(studentId, name, age, email, course);

assertNotNull(studentManagementApplication.getStudent(studentId));
}

@Test
public void testSearchStudent() {
String studentId = "123";
String name = "John Doe";
int age = 20;
String email = "johndoe";
String course = "Computer Science";

studentManagementApplication.saveStudent(studentId, name, age, email, course);

Student student = studentManagementApplication.searchStudent(studentId);

assertEquals(studentId, student.getStudentId());
assertEquals(name, student.getName());
assertEquals(age, student.getAge());
assertEquals(email, student.getEmail());
assertEquals(course, student.getCourse());
}

@Test
public void testSearchStudent_StudentNotFound() {
String studentId = "456";

Student student = studentManagementApplication.searchStudent(studentId);

assertNull(student);
}

@Test
public void testDeleteStudent() {
String studentId = "123";
String name = "John Doe";
int age = 20;
String email = "johndoe";
String course = "Computer Science";

studentManagementApplication.saveStudent(studentId, name, age, email, course);

boolean result = studentManagementApplication.deleteStudent(studentId);

assertTrue(result);
assertNull(studentManagementApplication.getStudent(studentId));
}

@Test
public void testDeleteStudent_StudentNotFound() {
String studentId = "456";

boolean result = studentManagementApplication.deleteStudent(studentId);

assertFalse(result);
}

@Test
public void testStudentAge_StudentAgeValid() {
int age = 20;

boolean result = studentManagementApplication.isValidAge(age);

assertTrue(result);
}

@Test
public void testStudentAge_StudentAgeInvalid() {
int age = 15;

boolean result = studentManagementApplication.isValidAge(age);

assertFalse(result);
}

@Test
public void testStudentAge_StudentAgeInvalidCharacter() {
String age = "twenty";

boolean result = studentManagementApplication.isValidAge(age);

assertFalse(result);
}
}

To create the test package and write the required unit tests in Java, follow these steps:

1. Open your student management application project in your preferred Integrated Development Environment (IDE).

2. Create a new package within your project to hold the unit tests. Right-click on your project folder and select "New" > "Package". Give the package a suitable name, such as "tests" or "unitTests".

3. Within the newly created test package, create a new Java class for each unit test. Right-click on the test package and select "New" > "Java Class". Name the class based on the test name provided.

4. For each test class, add the necessary code to write the unit tests. Below is an example for the first test, "TESTSAVESTUDENT()":

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

public class TESTSAVESTUDENT {
@Test
public void testSaveStudent() {
// Create a Student object with required attributes
String studentId = "123";
String name = "John Doe";
int age = 18;
String email = "johndoe";
String course = "Computer Science";
Student student = new Student(studentId, name, age, email, course);

// Call the saveStudent() method on your student management application
// and get the returned value
boolean result = saveStudent(student);

// Assert that the saveStudent() method returned true, indicating successful saving
assertEquals(true, result);
}
}
```

5. Implement the remaining test classes following a similar structure, modifying the test inputs, calling the appropriate methods, and asserting against the expected results.

6. Run the unit tests using your IDE's test runner or build tools such as Maven or Gradle.

By following these steps, you should be able to create the required unit tests and assess the code coverage of your student management application.

To write unit tests for the student management application in Java, follow these steps:

1. Open your Java IDE (Integrated Development Environment) such as Eclipse or IntelliJ.

2. Create a new test package within your application project. Right-click on the root of your project, navigate to "New" or "Create New," and select "Package." Enter a name for the package that indicates it is for testing, such as "com.example.app.test."

3. Open the newly created test package, right-click on it, and select "New" or "Create New." From the menu, choose "Class" to create a new test class. Name the class appropriately, such as "StudentManagerTest."

4. In the test class, import the necessary libraries. Your code should include the following import statements:

```java
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
```

5. Create test methods for each of the required unit tests. To create a test method, use the `@Test` annotation provided by the JUnit framework. Each test method should have a meaningful name that reflects its purpose. For example:

```java
@Test
public void testSaveStudent() {
// Test code to supply student ID, name, age, email, and course
// Invoke the save student method and assert the expected outcome using assertions
// Assertions.assertEquals(expectedResult, actualResult);
}
```

6. Implement the test code for each test method. In each test method, write code that supplies the necessary inputs to the corresponding method in the student management application and verifies the expected output. Use assertions provided by the JUnit framework to verify the correctness of the results. For example:

```java
@Test
public void testSaveStudent() {
// Test code to supply student ID, name, age, email, and course
// Invoke the save student method and assert the expected outcome using assertions
// Assertions.assertEquals(expectedResult, actualResult);
}

@Test
public void testSearchStudent() {
// Test code to supply student ID to the search student method
// Invoke the search student method and assert the expected outcome using assertions
// Assertions.assertEquals(expectedResult, actualResult);
}

// Implement other test methods similarly
```

Note that the actual implementation of the application's student management methods is not provided here; you would need to reference and call those methods in your test code.

7. Run the test suite to execute the unit tests. To run the tests, right-click on the test class or the test package and select "Run As" or "Run with Coverage" (depending on your IDE). Ensure that the tests pass successfully and validate the expected behavior of the student management application.

By following these steps, you can create the required unit tests for the student management application, ensuring code coverage and verifying the correctness of its functionality.