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