com.banda.truckmanagement.EncapsulationTest.java Source code

Java tutorial

Introduction

Here is the source code for com.banda.truckmanagement.EncapsulationTest.java

Source

/*
 * 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.encapsulation.services.AddNewEmployeeService;
import com.banda.truckmanagement.model.Employee;
import com.banda.truckmanagement.model.EmployeeFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import static org.testng.Assert.*;
import org.testng.annotations.Test;

/**
 *
 * @author itsbryan
 */
public class EncapsulationTest {
    static AddNewEmployeeService addEmployeeServ;

    public EncapsulationTest() {
    }

    @org.testng.annotations.BeforeClass
    public static void setUpClass() throws Exception {
        ApplicationContext ctx = new AnnotationConfigApplicationContext(AppConfig.class);
        addEmployeeServ = (AddNewEmployeeService) ctx.getBean("addNewEmployee");
    }

    @org.testng.annotations.AfterClass
    public static void tearDownClass() throws Exception {
    }

    @org.testng.annotations.BeforeMethod
    public void setUpMethod() throws Exception {
    }

    @org.testng.annotations.AfterMethod
    public void tearDownMethod() throws Exception {
    }

    @Test
    public void encapsulationTest() {
        Employee emp = addEmployeeServ.addNewEmployee();
        emp.setEmployeeId("101234C56");
        assertEquals("101234C56", emp.getEmployeeId());
    }
}