Skip to main content
summaryrefslogtreecommitdiffstats
blob: d814c9cb8e317ca56cbde98c4ea666c8c8384be9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*******************************************************************************
 * Copyright (c) 2013 Boeing.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Boeing - initial API and implementation
 *******************************************************************************/
package org.eclipse.osee.ats.core.model.impl;

import org.eclipse.osee.framework.jdk.core.util.Lib;
import org.junit.Assert;
import org.junit.Test;

/**
 * Test case for {@link AtsObject}
 *
 * @author Donald G. Dunne
 */
public class AtsObjectTest {

   @Test
   public void testGetNameGuidId() {
      AtsObject obj = new AtsObject("hello", 456);
      Assert.assertEquals("hello", obj.getName());
      Assert.assertEquals(456, obj.getUuid().longValue());

      obj = new AtsObject("hello", Lib.generateUuid());
      Assert.assertEquals("hello", obj.getName());
   }

   @Test
   public void testGetSetDescription() {
      AtsObject obj = new AtsObject("hello", Lib.generateUuid());
      Assert.assertNull(obj.getDescription());

      obj.setDescription("desc");
      Assert.assertEquals("desc", obj.getDescription());
   }

   @Test
   public void testEqualsObject() {
      AtsObject obj = new AtsObject("hello", 456);
      Assert.assertTrue(obj.equals(obj));

      AtsObject obj2 = new AtsObject("hello", 456);

      Assert.assertTrue(obj.equals(obj2));
      Assert.assertFalse(obj.equals(null));
      Assert.assertFalse(obj.equals("str"));

      AtsObject obj3 = new AtsObject("hello", 457);
      Assert.assertFalse(obj.equals(obj3));
      Assert.assertFalse(obj3.equals(obj));

   }

   @Test
   public void testHashCode() {
      AtsObject obj = new AtsObject("hello", 465);
      Assert.assertEquals(496, obj.hashCode());

      obj = new AtsObject("hello", 456);
      Assert.assertEquals(487, obj.hashCode());
   }

}

Back to the top