1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2015 EDIT
|
4
|
* European Distributed Institute of Taxonomy
|
5
|
* http://www.e-taxonomy.eu
|
6
|
*
|
7
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
8
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
9
|
*/
|
10
|
package eu.etaxonomy.taxeditor.operation;
|
11
|
|
12
|
import java.util.ArrayList;
|
13
|
import java.util.List;
|
14
|
import java.util.UUID;
|
15
|
|
16
|
import org.eclipse.core.commands.ExecutionException;
|
17
|
import org.junit.Assert;
|
18
|
import org.junit.Ignore;
|
19
|
import org.junit.Test;
|
20
|
import org.unitils.dbunit.annotation.DataSet;
|
21
|
|
22
|
import eu.etaxonomy.cdm.api.service.IPolytomousKeyService;
|
23
|
import eu.etaxonomy.cdm.model.description.PolytomousKey;
|
24
|
import eu.etaxonomy.taxeditor.navigation.key.polytomous.operation.RemotingDeletePolytomousKeyOperation;
|
25
|
import eu.etaxonomy.taxeditor.navigation.key.polytomous.operation.RemotingUpdatePolytomousKeyAllNodesOperation;
|
26
|
|
27
|
/**
|
28
|
* @author cmathew
|
29
|
* @date 25 Jun 2015
|
30
|
*
|
31
|
*/
|
32
|
@DataSet
|
33
|
public class PolytomousKeyViewPartTest extends BaseOperationTest {
|
34
|
|
35
|
IPolytomousKeyService polytomousKeyService = getRemoteApplicationController().getPolytomousKeyService();
|
36
|
private static UUID pkey1Uuid = UUID.fromString("f82cef88-5a9e-4917-9938-d08bda40836f");
|
37
|
private static UUID pkey2Uuid = UUID.fromString("a00ca7ec-b660-433c-bd14-596826ab2243");
|
38
|
private static UUID pkey3Uuid = UUID.fromString("197bc542-bf5b-4a52-aa66-c65df32c196b");
|
39
|
|
40
|
@Ignore // waiting for #3998 to be fixed
|
41
|
@Test
|
42
|
public void testDeletePolytomousKey() throws ExecutionException {
|
43
|
List<PolytomousKey> pKeysBeforeDelete = polytomousKeyService.list(PolytomousKey.class, null, null, null, null);
|
44
|
int initialCount = pKeysBeforeDelete.size();
|
45
|
|
46
|
List<PolytomousKey> keysToDelete = new ArrayList<PolytomousKey>();
|
47
|
keysToDelete.add(polytomousKeyService.load(pkey1Uuid));
|
48
|
keysToDelete.add(polytomousKeyService.load(pkey2Uuid));
|
49
|
keysToDelete.add(polytomousKeyService.load(pkey3Uuid));
|
50
|
|
51
|
List<UUID> uuids = new ArrayList<UUID>();
|
52
|
uuids.add(pkey1Uuid);
|
53
|
uuids.add(pkey2Uuid);
|
54
|
uuids.add(pkey3Uuid);
|
55
|
|
56
|
int keysToDeleteCount = keysToDelete.size();
|
57
|
operation = new RemotingDeletePolytomousKeyOperation(sessionOwner,
|
58
|
false,
|
59
|
uuids);
|
60
|
operation.execute(monitor, info);
|
61
|
|
62
|
List<PolytomousKey> pKeysAfterDelete = polytomousKeyService.list(PolytomousKey.class, null, null, null, null);
|
63
|
Assert.assertEquals(initialCount - keysToDeleteCount, pKeysAfterDelete.size());
|
64
|
for(PolytomousKey key : keysToDelete) {
|
65
|
Assert.assertFalse(pKeysAfterDelete.contains(key));
|
66
|
}
|
67
|
|
68
|
}
|
69
|
|
70
|
@Test
|
71
|
public void testUpdateAllNodes() throws ExecutionException {
|
72
|
operation = new RemotingUpdatePolytomousKeyAllNodesOperation(sessionOwner,
|
73
|
false,
|
74
|
pkey1Uuid);
|
75
|
operation.execute(monitor, info);
|
76
|
}
|
77
|
|
78
|
}
|