1   /*
2    * Copyright (C) 2010 Atlassian
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package com.atlassian.jira.rest.client.domain;
18  
19  import com.atlassian.jira.rest.client.TestUtil;
20  import org.junit.Test;
21  
22  import static com.atlassian.jira.rest.client.TestUtil.assertNotEquals;
23  import static com.atlassian.jira.rest.client.TestUtil.toUri;
24  import static org.junit.Assert.assertEquals;
25  
26  public class PriorityTest {
27  	private static final Priority P1 = new Priority(toUri("http://localhost/1"), 1L, "a", "#223344", "a description", toUri("http://localhost/2"));
28  	private static final Priority P2 = new Priority(toUri("http://localhost/1"), 2L, "a", "#223344", "a description", toUri("http://localhost/2"));
29  	private static final Priority P3 = new Priority(toUri("http://localhost/1"), 3L, "b", "#223344", "a description", toUri("http://localhost/2"));
30  	private static final Priority P4 = new Priority(toUri("http://localhost/2"), 4L, "a", "#223344", "a description", toUri("http://localhost/2"));
31  	private static final Priority P5 = new Priority(toUri("http://localhost/1"), 5L, "a", "#123344", "a description", toUri("http://localhost/2"));
32  	private static final Priority P6 = new Priority(toUri("http://localhost/1"), 6L, "a", "#223344", "a description2", toUri("http://localhost/2"));
33  	private static final Priority P7 = new Priority(toUri("http://localhost/1"), 7L, "a", "#223344", "a description", toUri("http://localhost/3"));
34  
35  	
36  	@Test
37  	public void testEquals() throws Exception {
38  		TestUtil.assertEqualsSymmetrical(P1, P2);
39  		assertEquals(P1, P1);
40  		assertNotEquals(P1, null);
41  		assertNotEquals(P1, P3);
42  		assertNotEquals(P1, P4);
43  		assertNotEquals(P1, P5);
44  		assertNotEquals(P1, P6);
45  		assertNotEquals(P1, P7);
46  	}
47  
48  	@Test
49  	public void testHashCode() throws Exception {
50  		assertEquals(P1.hashCode(), P2.hashCode());
51  	}
52  }