DAO interface and class implementation---> Service Class (Invoke DAO class and interface)--facade Class (Call service Class)
In this exercise,
This time, the test code was written first, and then the service class code needed in the test code was written.
Interestingly, there are two kinds of test code.
1) One is the integration test code, which invokes the service class code (the service Class code calls the DAO interface and Class).
2) The other is the unit test code, which also calls the service class code, but the service class code is called the DAO interface and the mock implementation.
1 fully tested DAO interface and class implementation---> Service class (Call DAO class and interface) two stages of code
2 is testing the service class code without relying on/Not testing the DAO interface and class implementation
Note: The code for Defaultstadiumservice implements Stadiumservice is not @Component (value = "xxxxx")
So for other code to use Defaultstadiumservice, such as Stadiumservice's spring bean, it needs to be declared in the Spring Config file: <alias name= " Defaultstadiumservice "alias=" Stadiumservice "/>
<bean id= "Defaultstadiumservice" class= "De.hybris.platform.cuppytrail.impl.DefaultStadiumService" >
<property name= "Stadiumdao" ref= "Stadiumdao"/>
</bean>
The test code Defaultstadiumserviceintegrationtest.java can be declared, and then directly applicable to the Stadiumservice bean.
@Resource//Here is the declaration to use the Stadiumservice bean
Private Stadiumservice Stadiumservice;
... ...
@Test
public void Teststadiumservice ()
{
list<stadiummodel> stadiummodels = Stadiumservice.getstadiums (); Open this stadiumservice bean right here.
Defaultstadiumservice