forked from alibaba/COLA
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
fulan.zjf
committed
Aug 20, 2020
1 parent
94fad64
commit e09d58d
Showing
8 changed files
with
199 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
cola-framework-core/src/test/java/com/alibaba/cola/test/ExtensionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package com.alibaba.cola.test; | ||
|
||
import com.alibaba.cola.TestSpringConfig; | ||
import com.alibaba.cola.dto.Response; | ||
import com.alibaba.cola.extension.BizScenario; | ||
import com.alibaba.cola.test.customer.*; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.springframework.test.context.ContextConfiguration; | ||
import org.springframework.test.context.junit4.SpringRunner; | ||
|
||
import javax.annotation.Resource; | ||
|
||
/** | ||
* ExtensionTest | ||
* | ||
* @author Frank Zhang | ||
* @date 2020-08-20 12:45 PM | ||
*/ | ||
@RunWith(SpringRunner.class) | ||
@ContextConfiguration(classes = {TestSpringConfig.class}) | ||
public class ExtensionTest { | ||
|
||
@Resource | ||
private CustomerServiceI customerService; | ||
|
||
@Test | ||
public void testBiz1UseCase1Scenario1AddCustomerSuccess(){ | ||
//1. Prepare | ||
AddCustomerCmd addCustomerCmd = new AddCustomerCmd(); | ||
CustomerCO customerCO = new CustomerCO(); | ||
customerCO.setCompanyName("alibaba"); | ||
customerCO.setSource(Constants.SOURCE_RFQ); | ||
customerCO.setCustomerType(CustomerType.IMPORTANT); | ||
addCustomerCmd.setCustomerCO(customerCO); | ||
BizScenario scenario = BizScenario.valueOf(Constants.BIZ_1, Constants.USE_CASE_1, Constants.SCENARIO_1); | ||
addCustomerCmd.setBizScenario(scenario); | ||
|
||
//2. Execute | ||
Response response = customerService.addCustomer(addCustomerCmd); | ||
|
||
//3. Expect Success | ||
Assert.assertTrue(response.isSuccess()); | ||
} | ||
|
||
@Test | ||
public void testBiz1UseCase1AddCustomerSuccess(){ | ||
//1. Prepare | ||
AddCustomerCmd addCustomerCmd = new AddCustomerCmd(); | ||
CustomerCO customerCO = new CustomerCO(); | ||
customerCO.setCompanyName("alibaba"); | ||
customerCO.setSource(Constants.SOURCE_RFQ); | ||
customerCO.setCustomerType(CustomerType.IMPORTANT); | ||
addCustomerCmd.setCustomerCO(customerCO); | ||
BizScenario scenario = BizScenario.valueOf(Constants.BIZ_1, Constants.USE_CASE_1); | ||
addCustomerCmd.setBizScenario(scenario); | ||
|
||
//2. Execute | ||
Response response = customerService.addCustomer(addCustomerCmd); | ||
|
||
//3. Expect Success | ||
Assert.assertTrue(response.isSuccess()); | ||
} | ||
|
||
@Test | ||
public void testBiz1AddCustomerSuccess(){ | ||
//1. Prepare | ||
AddCustomerCmd addCustomerCmd = new AddCustomerCmd(); | ||
CustomerCO customerCO = new CustomerCO(); | ||
customerCO.setCompanyName("jingdong"); | ||
customerCO.setSource(Constants.SOURCE_RFQ); | ||
customerCO.setCustomerType(CustomerType.IMPORTANT); | ||
addCustomerCmd.setCustomerCO(customerCO); | ||
BizScenario scenario = BizScenario.valueOf(Constants.BIZ_1); | ||
addCustomerCmd.setBizScenario(scenario); | ||
|
||
//2. Execute | ||
Response response = customerService.addCustomer(addCustomerCmd); | ||
|
||
//3. Expect Success | ||
Assert.assertTrue(response.isSuccess()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
...aba/cola/test/customer/validator/extension/AddCustomerBiz1UseCase1Scenario1Validator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.alibaba.cola.test.customer.validator.extension; | ||
|
||
import com.alibaba.cola.extension.Extension; | ||
import com.alibaba.cola.test.customer.AddCustomerCmd; | ||
import com.alibaba.cola.test.customer.Constants; | ||
import com.alibaba.cola.test.customer.validator.extensionpoint.AddCustomerValidatorExtPt; | ||
|
||
/** | ||
* AddCustomerBiz1UseCase1Scenario1Validator | ||
* | ||
* @author Frank Zhang | ||
* @date 2020-08-20 1:01 PM | ||
*/ | ||
@Extension(bizId = Constants.BIZ_1, useCase = Constants.USE_CASE_1, scenario = Constants.SCENARIO_1) | ||
public class AddCustomerBiz1UseCase1Scenario1Validator implements AddCustomerValidatorExtPt { | ||
public void validate(AddCustomerCmd addCustomerCmd) { | ||
System.out.println("Do validation for Biz_One's Use_Case_One's Scenario_One"); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
.../com/alibaba/cola/test/customer/validator/extension/AddCustomerBiz1UseCase1Validator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.alibaba.cola.test.customer.validator.extension; | ||
|
||
import com.alibaba.cola.extension.Extension; | ||
import com.alibaba.cola.test.customer.AddCustomerCmd; | ||
import com.alibaba.cola.test.customer.Constants; | ||
import com.alibaba.cola.test.customer.validator.extensionpoint.AddCustomerValidatorExtPt; | ||
|
||
/** | ||
* AddCustomerBiz1UseCase1Validator | ||
* | ||
* @author Frank Zhang | ||
* @date 2020-08-20 12:58 PM | ||
*/ | ||
@Extension(bizId = Constants.BIZ_1, useCase = Constants.USE_CASE_1) | ||
public class AddCustomerBiz1UseCase1Validator implements AddCustomerValidatorExtPt { | ||
public void validate(AddCustomerCmd addCustomerCmd) { | ||
System.out.println("Do validation for Biz_One's Use_Case_One"); | ||
} | ||
} |