Skip to main content
summaryrefslogtreecommitdiffstats
blob: d792ac1535e6fa762731bcae094bf4615fa038c4 (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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/*******************************************************************************
 * 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.orcs.core.internal.proxy.impl;

import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.util.Date;
import org.eclipse.osee.framework.core.data.AttributeId;
import org.eclipse.osee.framework.core.data.IAttributeType;
import org.eclipse.osee.framework.core.enums.ModificationType;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.orcs.OrcsSession;
import org.eclipse.osee.orcs.core.internal.attribute.Attribute;
import org.eclipse.osee.orcs.core.internal.proxy.ExternalArtifactManager;
import org.eclipse.osee.orcs.data.AttributeReadable;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;

/**
 * Test Case for @{link AttributeReadOnlyImpl}
 *
 * @author Roberto E. Escobar
 */
public class AttributeReadOnlyImplTest {

   //@formatter:off
   @Mock private ExternalArtifactManager proxyManager;
   @Mock private OrcsSession session;
   @Mock private Attribute<Date> proxiedObject;

   @Mock private IAttributeType attributeType;

   @Mock private AttributeId attributeId;

   @Mock private Attribute<Object> attribute1;
   @Mock private AttributeReadable<Object> attributeReadable1;
   //@formatter:on

   private AttributeReadOnlyImpl<Date> readOnly;

   @Before
   public void setUp() {
      MockitoAnnotations.initMocks(this);

      readOnly = new AttributeReadOnlyImpl<>(proxyManager, session, proxiedObject);
   }

   @Test
   public void testGetAttributeType() throws OseeCoreException {
      IAttributeType expected = attributeType;
      when(proxiedObject.getAttributeType()).thenReturn(expected);

      IAttributeType actual = readOnly.getAttributeType();

      assertEquals(expected, actual);
      verify(proxiedObject).getAttributeType();
   }

   @Test
   public void testGetDisplayableString() throws OseeCoreException {
      String expected = "Hello";
      when(proxiedObject.getDisplayableString()).thenReturn(expected);

      String actual = readOnly.getDisplayableString();

      assertEquals(expected, actual);
      verify(proxiedObject).getDisplayableString();
   }

   @Test
   public void testGetGammaId() {
      long expected = 1231232112L;
      when(proxiedObject.getGammaId()).thenReturn(expected);

      long actual = readOnly.getGammaId();

      assertEquals(expected, actual);
      verify(proxiedObject).getGammaId();
   }

   @Test
   public void testGetLocalId() {
      int expected = 123;
      when(proxiedObject.getLocalId()).thenReturn(expected);

      int actual = readOnly.getLocalId();

      assertEquals(expected, actual);
      verify(proxiedObject).getLocalId();
   }

   @Test
   public void testGetModificationType() {
      ModificationType expected = ModificationType.ARTIFACT_DELETED;
      when(proxiedObject.getModificationType()).thenReturn(expected);

      ModificationType actual = readOnly.getModificationType();

      assertEquals(expected, actual);
      verify(proxiedObject).getModificationType();
   }

   @Test
   public void testGetValue() throws OseeCoreException {
      Date expected = new Date();
      when(proxiedObject.getValue()).thenReturn(expected);

      Date actual = readOnly.getValue();

      assertEquals(expected, actual);
      verify(proxiedObject).getValue();
   }

   @Test
   public void testIsDeleted() {
      boolean expected = true;
      when(proxiedObject.isDeleted()).thenReturn(expected);

      boolean actual = readOnly.isDeleted();

      assertEquals(expected, actual);
      verify(proxiedObject).isDeleted();
   }

   @Test
   public void testIsOfType() throws OseeCoreException {
      boolean expected = true;
      when(proxiedObject.isOfType(attributeType)).thenReturn(expected);

      boolean actual = readOnly.isOfType(attributeType);

      assertEquals(expected, actual);
      verify(proxiedObject).isOfType(attributeType);
   }

}

Back to the top