Start implementing Trello API service
Implement name of system to import Implement need validate data Fix allowed system list Start implementing Trello API service Signed-off-by: Vitor Mattos <vitor@php.rio>
This commit is contained in:
committed by
Julius Härtl
parent
c7a37ea425
commit
202ea30090
@@ -58,7 +58,7 @@ class BoardImportTest extends \Test\TestCase {
|
||||
['config']
|
||||
)
|
||||
->will($this->returnValueMap([
|
||||
['system', 'trello'],
|
||||
['system', 'trelloJson'],
|
||||
['config', null]
|
||||
]));
|
||||
|
||||
|
||||
@@ -59,8 +59,8 @@ class BoardImportServiceTest extends \Test\TestCase {
|
||||
private $assignmentMapper;
|
||||
/** @var ICommentsManager|MockObject */
|
||||
private $commentsManager;
|
||||
/** @var BoardImportTrelloService|MockObject */
|
||||
private $importTrelloService;
|
||||
/** @var BoardImportTrelloJsonService|MockObject */
|
||||
private $importTrelloJsonService;
|
||||
/** @var BoardImportService|MockObject */
|
||||
private $boardImportService;
|
||||
public function setUp(): void {
|
||||
@@ -85,16 +85,16 @@ class BoardImportServiceTest extends \Test\TestCase {
|
||||
$this->commentsManager
|
||||
);
|
||||
|
||||
$this->boardImportService->setSystem('trello');
|
||||
$this->boardImportService->setSystem('trelloJson');
|
||||
|
||||
$data = json_decode(file_get_contents(__DIR__ . '/../../data/data-trello.json'));
|
||||
$data = json_decode(file_get_contents(__DIR__ . '/../../data/data-trelloJson.json'));
|
||||
$this->boardImportService->setData($data);
|
||||
|
||||
$configInstance = json_decode(file_get_contents(__DIR__ . '/../../data/config-trello.json'));
|
||||
$configInstance = json_decode(file_get_contents(__DIR__ . '/../../data/config-trelloJson.json'));
|
||||
$this->boardImportService->setConfigInstance($configInstance);
|
||||
|
||||
$this->importTrelloService = $this->createMock(BoardImportTrelloService::class);
|
||||
$this->boardImportService->setImportSystem($this->importTrelloService);
|
||||
$this->importTrelloJsonService = $this->createMock(BoardImportTrelloJsonService::class);
|
||||
$this->boardImportService->setImportSystem($this->importTrelloJsonService);
|
||||
|
||||
$owner = $this->createMock(IUser::class);
|
||||
$owner
|
||||
@@ -122,35 +122,35 @@ class BoardImportServiceTest extends \Test\TestCase {
|
||||
->expects($this->once())
|
||||
->method('insert');
|
||||
|
||||
$this->importTrelloService
|
||||
$this->importTrelloJsonService
|
||||
->method('getAclList')
|
||||
->willReturn([new Acl()]);
|
||||
$this->aclMapper
|
||||
->expects($this->once())
|
||||
->method('insert');
|
||||
|
||||
$this->importTrelloService
|
||||
$this->importTrelloJsonService
|
||||
->method('getLabels')
|
||||
->willReturn([new Label()]);
|
||||
$this->labelMapper
|
||||
->expects($this->once())
|
||||
->method('insert');
|
||||
|
||||
$this->importTrelloService
|
||||
$this->importTrelloJsonService
|
||||
->method('getStacks')
|
||||
->willReturn([new Stack()]);
|
||||
$this->stackMapper
|
||||
->expects($this->once())
|
||||
->method('insert');
|
||||
|
||||
$this->importTrelloService
|
||||
$this->importTrelloJsonService
|
||||
->method('getCards')
|
||||
->willReturn([new Card()]);
|
||||
$this->cardMapper
|
||||
->expects($this->any())
|
||||
->method('insert');
|
||||
|
||||
$this->importTrelloService
|
||||
$this->importTrelloJsonService
|
||||
->method('getComments')
|
||||
->willReturn([
|
||||
'fakecardid' => [new Comment()]
|
||||
@@ -159,7 +159,7 @@ class BoardImportServiceTest extends \Test\TestCase {
|
||||
->expects($this->once())
|
||||
->method('save');
|
||||
|
||||
$this->importTrelloService
|
||||
$this->importTrelloJsonService
|
||||
->method('getCardAssignments')
|
||||
->willReturn([
|
||||
'fakecardid' => [new Assignment()]
|
||||
|
||||
@@ -26,8 +26,8 @@ use OCP\IL10N;
|
||||
use OCP\IUser;
|
||||
use OCP\IUserManager;
|
||||
|
||||
class BoardImportTrelloServiceTest extends \Test\TestCase {
|
||||
/** @var BoardImportTrelloService */
|
||||
class BoardImportTrelloJsonServiceTest extends \Test\TestCase {
|
||||
/** @var BoardImportTrelloJsonService */
|
||||
private $service;
|
||||
/** @var IUserManager */
|
||||
private $userManager;
|
||||
@@ -36,7 +36,7 @@ class BoardImportTrelloServiceTest extends \Test\TestCase {
|
||||
public function setUp(): void {
|
||||
$this->userManager = $this->createMock(IUserManager::class);
|
||||
$this->l10n = $this->createMock(IL10N::class);
|
||||
$this->service = new BoardImportTrelloService(
|
||||
$this->service = new BoardImportTrelloJsonService(
|
||||
$this->userManager,
|
||||
$this->l10n
|
||||
);
|
||||
@@ -62,7 +62,7 @@ class BoardImportTrelloServiceTest extends \Test\TestCase {
|
||||
->willReturn(json_decode('{"members": [{"username": "othre_trello_user"}]}'));
|
||||
$this->service->setImportService($importService);
|
||||
$actual = $this->service->validateUsers();
|
||||
$this->assertInstanceOf(BoardImportTrelloService::class, $actual);
|
||||
$this->assertInstanceOf(BoardImportTrelloJsonService::class, $actual);
|
||||
}
|
||||
|
||||
public function testValidateUsersWithNotStringNextcloud() {
|
||||
@@ -78,7 +78,7 @@ class BoardImportTrelloServiceTest extends \Test\TestCase {
|
||||
->willReturn(json_decode('{"members": [{"username": "trello_user"}]}'));
|
||||
$this->service->setImportService($importService);
|
||||
$actual = $this->service->validateUsers();
|
||||
$this->assertInstanceOf(BoardImportTrelloService::class, $actual);
|
||||
$this->assertInstanceOf(BoardImportTrelloJsonService::class, $actual);
|
||||
}
|
||||
|
||||
public function testValidateUsersWithNotFoundUser() {
|
||||
@@ -92,7 +92,7 @@ class BoardImportTrelloServiceTest extends \Test\TestCase {
|
||||
->willReturn(json_decode('{"members": [{"username": "trello_user"}]}'));
|
||||
$this->service->setImportService($importService);
|
||||
$actual = $this->service->validateUsers();
|
||||
$this->assertInstanceOf(BoardImportTrelloService::class, $actual);
|
||||
$this->assertInstanceOf(BoardImportTrelloJsonService::class, $actual);
|
||||
}
|
||||
|
||||
public function testValidateUsersWithValidUsers() {
|
||||
@@ -123,10 +123,10 @@ class BoardImportTrelloServiceTest extends \Test\TestCase {
|
||||
public function testGetBoardWithSuccess() {
|
||||
$importService = \OC::$server->get(BoardImportService::class);
|
||||
|
||||
$data = json_decode(file_get_contents(__DIR__ . '/../../data/data-trello.json'));
|
||||
$data = json_decode(file_get_contents(__DIR__ . '/../../data/data-trelloJson.json'));
|
||||
$importService->setData($data);
|
||||
|
||||
$configInstance = json_decode(file_get_contents(__DIR__ . '/../../data/config-trello.json'));
|
||||
$configInstance = json_decode(file_get_contents(__DIR__ . '/../../data/config-trelloJson.json'));
|
||||
$importService->setConfigInstance($configInstance);
|
||||
|
||||
$owner = $this->createMock(IUser::class);
|
||||
|
||||
@@ -50,16 +50,23 @@ class BoardImportApiControllerTest extends \Test\TestCase {
|
||||
}
|
||||
|
||||
public function testGetAllowedSystems() {
|
||||
$allowedSystems = [
|
||||
[
|
||||
'name' => '',
|
||||
'class' => '',
|
||||
'internalName' => 'trelloJson'
|
||||
]
|
||||
];
|
||||
$this->boardImportService
|
||||
->method('getAllowedImportSystems')
|
||||
->willReturn(['trello']);
|
||||
->willReturn($allowedSystems);
|
||||
$actual = $this->controller->getAllowedSystems();
|
||||
$expected = new DataResponse(['trello'], HTTP::STATUS_OK);
|
||||
$expected = new DataResponse($allowedSystems, HTTP::STATUS_OK);
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
public function testImport() {
|
||||
$system = 'trello';
|
||||
$system = 'trelloJson';
|
||||
$config = [
|
||||
'owner' => 'test'
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user