JAL-2295 feature and colour commands refactored to use AtomSpecModel
[jalview.git] / test / jalview / ext / rbvi / chimera / ChimeraCommandsTest.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3  * Copyright (C) $$Year-Rel$$ The Jalview Authors
4  * 
5  * This file is part of Jalview.
6  * 
7  * Jalview is free software: you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License 
9  * as published by the Free Software Foundation, either version 3
10  * of the License, or (at your option) any later version.
11  *  
12  * Jalview is distributed in the hope that it will be useful, but 
13  * WITHOUT ANY WARRANTY; without even the implied warranty 
14  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
15  * PURPOSE.  See the GNU General Public License for more details.
16  * 
17  * You should have received a copy of the GNU General Public License
18  * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
19  * The Jalview Authors are detailed in the 'AUTHORS' file.
20  */
21 package jalview.ext.rbvi.chimera;
22
23 import static org.testng.AssertJUnit.assertEquals;
24
25 import java.awt.Color;
26 import java.util.LinkedHashMap;
27 import java.util.Map;
28
29 import org.testng.annotations.Test;
30
31 public class ChimeraCommandsTest
32 {
33   @Test(groups = { "Functional" })
34   public void testBuildColourCommands()
35   {
36
37     Map<Object, AtomSpecModel> map = new LinkedHashMap<Object, AtomSpecModel>();
38     ChimeraCommands.addRange(map, Color.blue, 0, 2, 5, "A");
39     ChimeraCommands.addRange(map, Color.blue, 0, 7, 7, "B");
40     ChimeraCommands.addRange(map, Color.blue, 0, 9, 23, "A");
41     ChimeraCommands.addRange(map, Color.blue, 1, 1, 1, "A");
42     ChimeraCommands.addRange(map, Color.blue, 1, 4, 7, "B");
43     ChimeraCommands.addRange(map, Color.yellow, 1, 8, 8, "A");
44     ChimeraCommands.addRange(map, Color.yellow, 1, 3, 5, "A");
45     ChimeraCommands.addRange(map, Color.red, 0, 3, 5, "A");
46     ChimeraCommands.addRange(map, Color.red, 0, 6, 9, "A");
47
48     // Colours should appear in the Chimera command in the order in which
49     // they were added; within colour, by model, by chain, ranges in start order
50     String command = ChimeraCommands.buildColourCommands(map).get(0);
51     assertEquals(
52             "color #0000ff #0:2-5.A,9-23.A,7.B|#1:1.A,4-7.B; color #ffff00 #1:3-5.A,8.A; color #ff0000 #0:3-9.A",
53             command);
54   }
55 }