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.cdm.model;
|
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.RemotingPolytomousKeyDeleteOperation;
|
25
|
import eu.etaxonomy.taxeditor.navigation.key.polytomous.operation.RemotingPolytomousKeyUpdateAllNodesOperation;
|
26
|
import eu.etaxonomy.taxeditor.operations.BaseOperationTest;
|
27
|
|
28
|
/**
|
29
|
* @author cmathew
|
30
|
* @date 25 Jun 2015
|
31
|
*
|
32
|
*/
|
33
|
@DataSet
|
34
|
public class PolytomousKeyViewPartTest extends BaseOperationTest {
|
35
|
|
36
|
IPolytomousKeyService polytomousKeyService = getRemoteApplicationController().getPolytomousKeyService();
|
37
|
private static UUID pkey1Uuid = UUID.fromString("f82cef88-5a9e-4917-9938-d08bda40836f");
|
38
|
private static UUID pkey2Uuid = UUID.fromString("a00ca7ec-b660-433c-bd14-596826ab2243");
|
39
|
private static UUID pkey3Uuid = UUID.fromString("197bc542-bf5b-4a52-aa66-c65df32c196b");
|
40
|
|
41
|
@Ignore // waiting for #3998 to be fixed
|
42
|
@Test
|
43
|
public void testDeletePolytomousKey() throws ExecutionException {
|
44
|
List<PolytomousKey> pKeysBeforeDelete = polytomousKeyService.list(PolytomousKey.class, null, null, null, null);
|
45
|
int initialCount = pKeysBeforeDelete.size();
|
46
|
|
47
|
List<PolytomousKey> keysToDelete = new ArrayList<PolytomousKey>();
|
48
|
keysToDelete.add(polytomousKeyService.load(pkey1Uuid));
|
49
|
keysToDelete.add(polytomousKeyService.load(pkey2Uuid));
|
50
|
keysToDelete.add(polytomousKeyService.load(pkey3Uuid));
|
51
|
|
52
|
List<UUID> uuids = new ArrayList<UUID>();
|
53
|
uuids.add(pkey1Uuid);
|
54
|
uuids.add(pkey2Uuid);
|
55
|
uuids.add(pkey3Uuid);
|
56
|
|
57
|
int keysToDeleteCount = keysToDelete.size();
|
58
|
operation = new RemotingPolytomousKeyDeleteOperation(sessionOwner,
|
59
|
false,
|
60
|
uuids);
|
61
|
operation.execute(monitor, info);
|
62
|
|
63
|
List<PolytomousKey> pKeysAfterDelete = polytomousKeyService.list(PolytomousKey.class, null, null, null, null);
|
64
|
Assert.assertEquals(initialCount - keysToDeleteCount, pKeysAfterDelete.size());
|
65
|
for(PolytomousKey key : keysToDelete) {
|
66
|
Assert.assertFalse(pKeysAfterDelete.contains(key));
|
67
|
}
|
68
|
|
69
|
}
|
70
|
|
71
|
@Test
|
72
|
public void testUpdateAllNodes() throws ExecutionException {
|
73
|
operation = new RemotingPolytomousKeyUpdateAllNodesOperation(sessionOwner,
|
74
|
false,
|
75
|
pkey1Uuid);
|
76
|
operation.execute(monitor, info);
|
77
|
}
|
78
|
|
79
|
}
|