|
@@ -1,22 +1,19 @@
|
|
package com.mooctest.crowd.domain.mediator.impl;
|
|
package com.mooctest.crowd.domain.mediator.impl;
|
|
|
|
|
|
-import com.mooctest.crowd.domain.command.LoginCommand;
|
|
|
|
-import com.mooctest.crowd.domain.command.RegisterCommand;
|
|
|
|
|
|
+import com.mooctest.crowd.domain.command.*;
|
|
|
|
+import com.mooctest.crowd.domain.data.dto.*;
|
|
import com.mooctest.crowd.domain.domainobject.Account;
|
|
import com.mooctest.crowd.domain.domainobject.Account;
|
|
import com.mooctest.crowd.domain.exception.PasswordErrorException;
|
|
import com.mooctest.crowd.domain.exception.PasswordErrorException;
|
|
import com.mooctest.crowd.domain.factory.AccountFactory;
|
|
import com.mooctest.crowd.domain.factory.AccountFactory;
|
|
import com.mooctest.crowd.domain.mediator.Mediator;
|
|
import com.mooctest.crowd.domain.mediator.Mediator;
|
|
-import com.mooctest.crowd.domain.service.RegisterService;
|
|
|
|
import org.junit.Before;
|
|
import org.junit.Before;
|
|
import org.junit.Test;
|
|
import org.junit.Test;
|
|
import org.junit.runner.RunWith;
|
|
import org.junit.runner.RunWith;
|
|
-import org.mockito.Mock;
|
|
|
|
import org.powermock.api.mockito.PowerMockito;
|
|
import org.powermock.api.mockito.PowerMockito;
|
|
import org.powermock.core.classloader.annotations.PrepareForTest;
|
|
import org.powermock.core.classloader.annotations.PrepareForTest;
|
|
import org.powermock.modules.junit4.PowerMockRunner;
|
|
import org.powermock.modules.junit4.PowerMockRunner;
|
|
|
|
|
|
import static org.junit.Assert.*;
|
|
import static org.junit.Assert.*;
|
|
-import static org.mockito.Matchers.any;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* @Author: xuexb
|
|
* @Author: xuexb
|
|
@@ -54,12 +51,81 @@ public class WebMediatorImplTest {
|
|
@Test
|
|
@Test
|
|
public void should_return_account_when_register_success() {
|
|
public void should_return_account_when_register_success() {
|
|
//arrange
|
|
//arrange
|
|
- RegisterCommand cmd = new RegisterCommand("NEW_MOBILE","CODE","PWD");
|
|
|
|
|
|
+ RegisterCommand registerCommand = new RegisterCommand("NEW_MOBILE","CODE","PWD");
|
|
|
|
|
|
//action
|
|
//action
|
|
- Account newAccount = RegisterService.register(cmd);
|
|
|
|
|
|
+ Account newAccount = mediator.register(registerCommand);
|
|
|
|
|
|
//assert
|
|
//assert
|
|
assertEquals("NEW_MOBILE", newAccount.getMobileNum());
|
|
assertEquals("NEW_MOBILE", newAccount.getMobileNum());
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Test
|
|
|
|
+ public void should_return_index_dto_when_render_index(){
|
|
|
|
+ //arrange
|
|
|
|
+ //action
|
|
|
|
+ IndexDTO indexDTO = mediator.renderIndex();
|
|
|
|
+ //assert
|
|
|
|
+ assertNotNull(indexDTO);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Test
|
|
|
|
+ public void should_return_mycrowd_dto_when_render_mycrowd_success(){
|
|
|
|
+ //arrange
|
|
|
|
+ AccountCommand accountCommand = new AccountCommand();
|
|
|
|
+ //action
|
|
|
|
+ MyCrowdDTO myCrowdDTO = mediator.renderMyCrowd(accountCommand);
|
|
|
|
+ //assert
|
|
|
|
+ assertNotNull(myCrowdDTO);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Test
|
|
|
|
+ public void should_return_project_details_dto_when_render_project_details_success(){
|
|
|
|
+ //arrange
|
|
|
|
+ CrowdTestProjectCommand crowdTestProjectCommand = new CrowdTestProjectCommand();
|
|
|
|
+ //action
|
|
|
|
+ ProjectDetailsDTO projectDetailsDTO = mediator.renderProjectDetails(crowdTestProjectCommand);
|
|
|
|
+ //assert
|
|
|
|
+ assertNotNull(projectDetailsDTO);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Test
|
|
|
|
+ public void should_return_task_square_dto_when_render_task_square_success(){
|
|
|
|
+ //arrange
|
|
|
|
+ CrowdTestTaskCommand crowdTestTaskCommand = new CrowdTestTaskCommand();
|
|
|
|
+ //action
|
|
|
|
+ TaskSquareDTO taskSquareDTO = mediator.renderTaskSquare(crowdTestTaskCommand);
|
|
|
|
+ //assert
|
|
|
|
+ assertNotNull(taskSquareDTO);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Test
|
|
|
|
+ public void should_return_report_details_dto_when_render_report_details_success(){
|
|
|
|
+ //arrange
|
|
|
|
+ CrowdTestReportCommand crowdTestReportCommand = new CrowdTestReportCommand();
|
|
|
|
+ //action
|
|
|
|
+ ReportDetailsDTO reportDetailsDTO = mediator.renderReportDetails(crowdTestReportCommand);
|
|
|
|
+ //assert
|
|
|
|
+ assertNotNull(reportDetailsDTO);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Test
|
|
|
|
+ public void should_return_task_details_dto_when_render_task_details_success(){
|
|
|
|
+ //arrange
|
|
|
|
+ CrowdTestTaskCommand crowdTestTaskCommand = new CrowdTestTaskCommand();
|
|
|
|
+ //action
|
|
|
|
+ TaskDetailsDTO taskDetailsDTO = mediator.renderTaskDetails(crowdTestTaskCommand);
|
|
|
|
+ //assert
|
|
|
|
+ assertNotNull(taskDetailsDTO);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Test
|
|
|
|
+ public void should_return_user_dto_when_render_user_success(){
|
|
|
|
+ //arrage
|
|
|
|
+ AccountCommand accountCommand = new AccountCommand();
|
|
|
|
+ //action
|
|
|
|
+ UserDTO userDTO = mediator.renderUser(accountCommand);
|
|
|
|
+ //assert
|
|
|
|
+ assertNotNull(userDTO);
|
|
|
|
+ }
|
|
}
|
|
}
|