Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package com.banda.truckmanagement; import com.banda.truckmanagement.config.AppConfig; import com.banda.truckmanagement.isp.Employee; import com.banda.truckmanagement.isp.compliance.service.Impl.DeliveryCostsImpl; import com.banda.truckmanagement.isp.compliance.service.Impl.HumanResourcesImpl; import com.banda.truckmanagement.isp.violation.HR_NotificationManager; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import static org.testng.Assert.assertEquals; import org.testng.annotations.AfterClass; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; /** * * @author itsbryan */ public class ISP_Test { static DeliveryCostsImpl dnlService; static HumanResourcesImpl hrService; static HR_NotificationManager ntfMgr; public ISP_Test() { } // TODO add test methods here. // The methods must be annotated with annotation @Test. For example: // // @Test // public void hello() {} @BeforeClass public static void setUpClass() throws Exception { ApplicationContext ctx = new AnnotationConfigApplicationContext(AppConfig.class); dnlService = (DeliveryCostsImpl) ctx.getBean("ispDelivery"); hrService = (HumanResourcesImpl) ctx.getBean("ispNotification"); ntfMgr = (HR_NotificationManager) ctx.getBean("notification"); } @AfterClass public static void tearDownClass() throws Exception { } @BeforeMethod public void setUpMethod() throws Exception { } @AfterMethod public void tearDownMethod() throws Exception { } @Test public void ispComplianceTest() { Employee jerry = Employee.EmployeeFactory.getInstanc("12345", "Jerry", "Bands", "C"); assertEquals(hrService.fireEmployee(jerry), "Jerry, you have been fired effective immediately"); } @Test public void ispViolationTest() { Employee markle = Employee.EmployeeFactory.getInstanc("12536", "Meghan", "Markle", "JustAnotherRandom"); assertEquals(ntfMgr.fireEmployee(markle), "Meghan, you have been fired effective immediately"); String msg = ntfMgr.sendDefaultNotification("System is currently down due to maintenance", -101278); assertEquals(msg, "-101278 - System is currently down due to maintenance"); } }