Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/attribute/ArtifactTest.java')
-rw-r--r--plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/attribute/ArtifactTest.java174
1 files changed, 84 insertions, 90 deletions
diff --git a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/attribute/ArtifactTest.java b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/attribute/ArtifactTest.java
index 76382272577..19c1d658eed 100644
--- a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/attribute/ArtifactTest.java
+++ b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/attribute/ArtifactTest.java
@@ -33,10 +33,10 @@ import org.eclipse.osee.orcs.core.ds.AttributeData;
import org.eclipse.osee.orcs.core.ds.OrcsData;
import org.eclipse.osee.orcs.core.ds.VersionData;
import org.eclipse.osee.orcs.core.internal.artifact.Artifact;
+import org.eclipse.osee.orcs.core.internal.artifact.ArtifactImpl;
import org.eclipse.osee.orcs.core.internal.relation.RelationContainer;
import org.eclipse.osee.orcs.core.internal.util.ValueProvider;
import org.eclipse.osee.orcs.data.ArtifactTypes;
-import org.eclipse.osee.orcs.data.AttributeReadable;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
@@ -54,7 +54,7 @@ public class ArtifactTest {
public ExpectedException thrown = ExpectedException.none();
// @formatter:off
- @Mock private Artifact artifactImpl;
+ @Mock private Artifact artifact;
@Mock private ArtifactData artifactData;
@Mock private AttributeFactory attributeFactory;
@Mock private RelationContainer relationContainer;
@@ -83,7 +83,7 @@ public class ArtifactTest {
@Before
public void init() throws OseeCoreException {
MockitoAnnotations.initMocks(this);
- artifactImpl = new Artifact(types, artifactData, attributeFactory, relationContainer, branchProvider);
+ artifact = new ArtifactImpl(types, artifactData, attributeFactory, relationContainer, branchProvider);
when(types.isValidAttributeType(any(IArtifactType.class), any(Branch.class), any(IAttributeType.class))).thenReturn(
true);
@@ -112,13 +112,13 @@ public class ArtifactTest {
@Test
@SuppressWarnings("unchecked")
- public void testAddAndGet() {
+ public void testAddAndGet() throws OseeCoreException {
Attribute<Object> attribute = mock(Attribute.class);
when(attribute.getOrcsData()).thenReturn(attributeData);
- Assert.assertEquals(0, artifactImpl.getAllAttributes().size());
- artifactImpl.add(CoreAttributeTypes.City, attribute);
- Assert.assertTrue(artifactImpl.getAllAttributes().contains(attribute));
- Assert.assertEquals(1, artifactImpl.getAllAttributes().size());
+ Assert.assertEquals(0, artifact.getAttributes().size());
+ artifact.add(CoreAttributeTypes.City, attribute);
+ Assert.assertTrue(artifact.getAttributes().contains(attribute));
+ Assert.assertEquals(1, artifact.getAttributes().size());
}
@Test
@@ -130,9 +130,9 @@ public class ArtifactTest {
when(two.getOrcsData()).thenReturn(attributeData);
when(attributeFactory.getMaxOccurrenceLimit(attributeType)).thenReturn(1);
- artifactImpl.add(attributeType, one);
- artifactImpl.add(attributeType, two);
- Assert.assertEquals(2, artifactImpl.getAttributes(attributeType).size());
+ artifact.add(attributeType, one);
+ artifact.add(attributeType, two);
+ Assert.assertEquals(2, artifact.getAttributes(attributeType).size());
}
@Test
@@ -140,64 +140,58 @@ public class ArtifactTest {
public void testAreAttributesDirty() {
Attribute<Object> attribute = mock(Attribute.class);
when(attribute.getOrcsData()).thenReturn(attributeData);
- artifactImpl.add(CoreAttributeTypes.City, attribute);
- Assert.assertFalse(artifactImpl.areAttributesDirty());
+ artifact.add(CoreAttributeTypes.City, attribute);
+ Assert.assertFalse(artifact.areAttributesDirty());
when(attribute.isDirty()).thenReturn(true);
- Assert.assertTrue(artifactImpl.areAttributesDirty());
+ Assert.assertTrue(artifact.areAttributesDirty());
}
@Test
public void testCreateAttribute() throws OseeCoreException {
- artifactImpl.createAttribute(CoreAttributeTypes.City);
- verify(attributeFactory).createAttributeWithDefaults(artifactImpl, artifactData, CoreAttributeTypes.City);
+ artifact.createAttribute(CoreAttributeTypes.City);
+ verify(attributeFactory).createAttributeWithDefaults(artifact, artifactData, CoreAttributeTypes.City);
}
@Test
public void testSetOrcsData() {
ArtifactData newOrcsData = mock(ArtifactData.class);
- artifactImpl.setOrcsData(newOrcsData);
+ artifact.setOrcsData(newOrcsData);
verify(branchProvider).setOrcsData(newOrcsData);
}
@Test
- public void testGetModificationType() {
- artifactImpl.getModificationType();
- verify(artifactData).getModType();
- }
-
- @Test
public void testGetLocalId() {
- artifactImpl.getLocalId();
+ artifact.getLocalId();
verify(artifactData).getLocalId();
}
@Test
public void testGetGuid() {
- artifactImpl.getGuid();
+ artifact.getGuid();
verify(artifactData).getGuid();
}
@Test
public void testGetHumanReadableId() {
- artifactImpl.getHumanReadableId();
+ artifact.getHumanReadableId();
verify(artifactData).getHumanReadableId();
}
@Test
public void testGetTransactionId() {
- artifactImpl.getTransaction();
+ artifact.getTransaction();
verify(version).getTransactionId();
}
@Test
public void testGetBranch() throws OseeCoreException {
- artifactImpl.getBranch();
+ artifact.getBranch();
verify(branchProvider).get();
}
@Test
public void testArtifactType() throws OseeCoreException {
- artifactImpl.getArtifactType();
+ artifact.getArtifactType();
verify(types).getByUuid(artifactData.getTypeUuid());
}
@@ -209,7 +203,7 @@ public class ArtifactTest {
when(
attributeFactory.createAttributeWithDefaults(any(AttributeManager.class), any(ArtifactData.class),
eq(CoreAttributeTypes.Name))).thenReturn(attr);
- artifactImpl.setName("test");
+ artifact.setName("test");
verify(attr).setFromString("test");
}
@@ -217,7 +211,7 @@ public class ArtifactTest {
public void testSetArtifactType() throws OseeCoreException {
when(version.isInStorage()).thenReturn(true);
- artifactImpl.setArtifactType(CoreArtifactTypes.CodeUnit);
+ artifact.setArtifactType(CoreArtifactTypes.CodeUnit);
verify(artifactData).setTypeUuid(CoreArtifactTypes.CodeUnit.getGuid());
verify(artifactData).setModType(ModificationType.MODIFIED);
@@ -230,13 +224,13 @@ public class ArtifactTest {
when(artifactData.getVersion()).thenReturn(version);
when(artifactData.getTypeUuid()).thenReturn(artifactType.getGuid());
- artifactImpl.setArtifactType(CoreArtifactTypes.CodeUnit);
+ artifact.setArtifactType(CoreArtifactTypes.CodeUnit);
verify(artifactData, never()).setModType(ModificationType.MODIFIED);
}
@Test
public void testIsOfType() throws OseeCoreException {
- artifactImpl.isOfType(CoreArtifactTypes.CodeUnit);
+ artifact.isOfType(CoreArtifactTypes.CodeUnit);
verify(types).inheritsFrom(CoreArtifactTypes.GeneralData, CoreArtifactTypes.CodeUnit);
}
@@ -244,26 +238,26 @@ public class ArtifactTest {
@Test
@SuppressWarnings({"rawtypes", "unchecked"})
public void testIsDirty() throws OseeCoreException {
- Assert.assertFalse(artifactImpl.isDirty());
+ Assert.assertFalse(artifact.isDirty());
// add dirty attribute
Attribute dirty = mock(Attribute.class);
when(dirty.getOrcsData()).thenReturn(attributeData);
when(dirty.isDirty()).thenReturn(true);
- artifactImpl.add(CoreAttributeTypes.Active, dirty);
- Assert.assertTrue(artifactImpl.isDirty());
+ artifact.add(CoreAttributeTypes.Active, dirty);
+ Assert.assertTrue(artifact.isDirty());
// change artifactType
reset(dirty);
- Assert.assertFalse(artifactImpl.isDirty());
- artifactImpl.setArtifactType(CoreArtifactTypes.CodeUnit);
- Assert.assertTrue(artifactImpl.isDirty());
+ Assert.assertFalse(artifact.isDirty());
+ artifact.setArtifactType(CoreArtifactTypes.CodeUnit);
+ Assert.assertTrue(artifact.isDirty());
// set mod type to replace with version
- artifactImpl.setOrcsData(artifactData);
- Assert.assertFalse(artifactImpl.isDirty());
+ artifact.setOrcsData(artifactData);
+ Assert.assertFalse(artifact.isDirty());
when(artifactData.getModType()).thenReturn(ModificationType.REPLACED_WITH_VERSION);
- Assert.assertTrue(artifactImpl.isDirty());
+ Assert.assertTrue(artifact.isDirty());
}
@Test
@@ -271,19 +265,19 @@ public class ArtifactTest {
for (ModificationType modType : ModificationType.values()) {
reset(artifactData);
when(artifactData.getModType()).thenReturn(modType);
- Assert.assertEquals(modType.isDeleted(), artifactImpl.isDeleted());
+ Assert.assertEquals(modType.isDeleted(), artifact.isDeleted());
}
}
@Test
public void testIsAttributeTypeValid() throws OseeCoreException {
- artifactImpl.isAttributeTypeValid(CoreAttributeTypes.Afha);
+ artifact.isAttributeTypeValid(CoreAttributeTypes.Afha);
verify(types).isValidAttributeType(artifactType, branch, CoreAttributeTypes.Afha);
}
@Test
public void testGetValidAttributeTypes() throws OseeCoreException {
- artifactImpl.getValidAttributeTypes();
+ artifact.getValidAttributeTypes();
verify(types).getAttributeTypes(artifactType, branch);
}
@@ -294,9 +288,9 @@ public class ArtifactTest {
Attribute two = mock(Attribute.class);
when(one.getOrcsData()).thenReturn(attributeData);
when(two.getOrcsData()).thenReturn(attributeData);
- artifactImpl.add(CoreAttributeTypes.AccessContextId, one);
- artifactImpl.add(CoreAttributeTypes.AccessContextId, two);
- artifactImpl.setAttributesNotDirty();
+ artifact.add(CoreAttributeTypes.AccessContextId, one);
+ artifact.add(CoreAttributeTypes.AccessContextId, two);
+ artifact.setAttributesNotDirty();
verify(one).clearDirty();
verify(two).clearDirty();
}
@@ -304,7 +298,7 @@ public class ArtifactTest {
@Test
@SuppressWarnings({"rawtypes", "unchecked"})
public void testGetName() throws OseeCoreException {
- String name = artifactImpl.getName();
+ String name = artifact.getName();
Assert.assertTrue(name.contains("AttributeDoesNotExist"));
Attribute attr = mock(Attribute.class);
@@ -313,9 +307,9 @@ public class ArtifactTest {
attributeFactory.createAttributeWithDefaults(any(AttributeManager.class), any(ArtifactData.class),
eq(CoreAttributeTypes.Name))).thenReturn(attr);
when(attr.getValue()).thenReturn("test");
- artifactImpl.add(CoreAttributeTypes.Name, attr);
- artifactImpl.setName("test");
- name = artifactImpl.getName();
+ artifact.add(CoreAttributeTypes.Name, attr);
+ artifact.setName("test");
+ name = artifact.getName();
Assert.assertEquals("test", name);
}
@@ -325,11 +319,11 @@ public class ArtifactTest {
when(attributeFactory.getMaxOccurrenceLimit(CoreAttributeTypes.AccessContextId)).thenReturn(expected);
- int result = artifactImpl.getMaximumAttributeTypeAllowed(CoreAttributeTypes.AccessContextId);
+ int result = artifact.getMaximumAttributeTypeAllowed(CoreAttributeTypes.AccessContextId);
Assert.assertEquals(expected, result);
reset(types);
- result = artifactImpl.getMaximumAttributeTypeAllowed(CoreAttributeTypes.AccessContextId);
+ result = artifact.getMaximumAttributeTypeAllowed(CoreAttributeTypes.AccessContextId);
Assert.assertEquals(-1, result);
}
@@ -339,38 +333,38 @@ public class ArtifactTest {
when(attributeFactory.getMinOccurrenceLimit(CoreAttributeTypes.AccessContextId)).thenReturn(expected);
- int result = artifactImpl.getMinimumAttributeTypeAllowed(CoreAttributeTypes.AccessContextId);
+ int result = artifact.getMinimumAttributeTypeAllowed(CoreAttributeTypes.AccessContextId);
Assert.assertEquals(expected, result);
reset(types);
- result = artifactImpl.getMaximumAttributeTypeAllowed(CoreAttributeTypes.AccessContextId);
+ result = artifact.getMaximumAttributeTypeAllowed(CoreAttributeTypes.AccessContextId);
Assert.assertEquals(-1, result);
}
@Test
@SuppressWarnings("unchecked")
public void testGetAttributeCount() throws OseeCoreException {
- artifactImpl.add(CoreAttributeTypes.AccessContextId, notDeleted);
- artifactImpl.add(CoreAttributeTypes.AccessContextId, deleted);
- artifactImpl.add(CoreAttributeTypes.Name, differentType);
- int result = artifactImpl.getAttributeCount(CoreAttributeTypes.AccessContextId);
+ artifact.add(CoreAttributeTypes.AccessContextId, notDeleted);
+ artifact.add(CoreAttributeTypes.AccessContextId, deleted);
+ artifact.add(CoreAttributeTypes.Name, differentType);
+ int result = artifact.getAttributeCount(CoreAttributeTypes.AccessContextId);
Assert.assertEquals(1, result);
- result = artifactImpl.getAttributeCount(CoreAttributeTypes.Name);
+ result = artifact.getAttributeCount(CoreAttributeTypes.Name);
Assert.assertEquals(1, result);
}
@Test
@SuppressWarnings("unchecked")
public void testGetAttributes() throws OseeCoreException {
- artifactImpl.add(CoreAttributeTypes.AccessContextId, notDeleted);
- artifactImpl.add(CoreAttributeTypes.AccessContextId, deleted);
- artifactImpl.add(CoreAttributeTypes.Name, differentType);
- List<AttributeReadable<Object>> attributes = artifactImpl.getAttributes();
+ artifact.add(CoreAttributeTypes.AccessContextId, notDeleted);
+ artifact.add(CoreAttributeTypes.AccessContextId, deleted);
+ artifact.add(CoreAttributeTypes.Name, differentType);
+ List<Attribute<Object>> attributes = artifact.getAttributes();
Assert.assertTrue(attributes.contains(notDeleted));
Assert.assertTrue(attributes.contains(differentType));
Assert.assertFalse(attributes.contains(deleted));
- attributes = artifactImpl.getAttributes(CoreAttributeTypes.AccessContextId);
+ attributes = artifact.getAttributes(CoreAttributeTypes.AccessContextId);
Assert.assertEquals(1, attributes.size());
Assert.assertTrue(attributes.contains(notDeleted));
}
@@ -378,11 +372,11 @@ public class ArtifactTest {
@Test
@SuppressWarnings("unchecked")
public void testGetAttributeValues() throws OseeCoreException {
- artifactImpl.add(CoreAttributeTypes.AccessContextId, notDeleted);
- artifactImpl.add(CoreAttributeTypes.AccessContextId, deleted);
+ artifact.add(CoreAttributeTypes.AccessContextId, notDeleted);
+ artifact.add(CoreAttributeTypes.AccessContextId, deleted);
when(notDeleted.getValue()).thenReturn("notDeleted");
when(deleted.getValue()).thenReturn("deleted");
- List<Object> values = artifactImpl.getAttributeValues(CoreAttributeTypes.AccessContextId);
+ List<Object> values = artifact.getAttributeValues(CoreAttributeTypes.AccessContextId);
Assert.assertEquals(1, values.size());
Assert.assertTrue(values.contains("notDeleted"));
}
@@ -391,11 +385,11 @@ public class ArtifactTest {
@SuppressWarnings("unchecked")
public void testGetSoleAttributeAsString() throws OseeCoreException {
when(notDeleted.getValue()).thenReturn(new Integer(5));
- artifactImpl.add(CoreAttributeTypes.AccessContextId, notDeleted);
- String attribute = artifactImpl.getSoleAttributeAsString(CoreAttributeTypes.AccessContextId);
+ artifact.add(CoreAttributeTypes.AccessContextId, notDeleted);
+ String attribute = artifact.getSoleAttributeAsString(CoreAttributeTypes.AccessContextId);
Assert.assertEquals("5", attribute);
- attribute = artifactImpl.getSoleAttributeAsString(CoreAttributeTypes.Category, "default");
+ attribute = artifact.getSoleAttributeAsString(CoreAttributeTypes.Category, "default");
Assert.assertEquals("default", attribute);
}
@@ -406,19 +400,19 @@ public class ArtifactTest {
Attribute two = mock(Attribute.class);
when(one.getOrcsData()).thenReturn(attributeData);
when(two.getOrcsData()).thenReturn(attributeData);
- artifactImpl.add(CoreAttributeTypes.AccessContextId, one);
- artifactImpl.add(CoreAttributeTypes.AccessContextId, two);
+ artifact.add(CoreAttributeTypes.AccessContextId, one);
+ artifact.add(CoreAttributeTypes.AccessContextId, two);
thrown.expect(MultipleAttributesExist.class);
- artifactImpl.getSoleAttributeAsString(CoreAttributeTypes.AccessContextId);
+ artifact.getSoleAttributeAsString(CoreAttributeTypes.AccessContextId);
}
@Test
@SuppressWarnings("unchecked")
public void testDeleteAttributesByArtifact() throws OseeCoreException {
- artifactImpl.add(CoreAttributeTypes.AccessContextId, notDeleted);
- artifactImpl.add(CoreAttributeTypes.AccessContextId, deleted);
- artifactImpl.add(CoreAttributeTypes.Active, differentType);
- artifactImpl.deleteAttributesByArtifact();
+ artifact.add(CoreAttributeTypes.AccessContextId, notDeleted);
+ artifact.add(CoreAttributeTypes.AccessContextId, deleted);
+ artifact.add(CoreAttributeTypes.Active, differentType);
+ artifact.deleteAttributesByArtifact();
verify(notDeleted).setArtifactDeleted();
verify(deleted).setArtifactDeleted();
verify(differentType).setArtifactDeleted();
@@ -429,9 +423,9 @@ public class ArtifactTest {
public void testDeleteSoleAttribute() throws OseeCoreException {
when(attributeFactory.getMinOccurrenceLimit(attributeType)).thenReturn(0);
when(notDeleted.getAttributeType()).thenReturn(attributeType);
- when(notDeleted.getContainer()).thenReturn(artifactImpl);
- artifactImpl.add(attributeType, notDeleted);
- artifactImpl.deleteSoleAttribute(attributeType);
+ when(notDeleted.getContainer()).thenReturn(artifact);
+ artifact.add(attributeType, notDeleted);
+ artifact.deleteSoleAttribute(attributeType);
verify(notDeleted).delete();
}
@@ -441,10 +435,10 @@ public class ArtifactTest {
when(attributeFactory.getMinOccurrenceLimit(attributeType)).thenReturn(1);
when(notDeleted.getAttributeType()).thenReturn(attributeType);
- artifactImpl.add(attributeType, notDeleted);
+ artifact.add(attributeType, notDeleted);
thrown.expect(OseeStateException.class);
- artifactImpl.deleteSoleAttribute(attributeType);
+ artifact.deleteSoleAttribute(attributeType);
}
@Test
@@ -459,9 +453,9 @@ public class ArtifactTest {
when(attributeFactory.getMaxOccurrenceLimit(attributeType)).thenReturn(3);
- when(attributeFactory.createAttributeWithDefaults(eq(artifactImpl), any(ArtifactData.class), eq(attributeType))).thenReturn(
+ when(attributeFactory.createAttributeWithDefaults(eq(artifact), any(ArtifactData.class), eq(attributeType))).thenReturn(
one, two, three);
- artifactImpl.setAttributesFromStrings(attributeType, "one", "two", "three");
+ artifact.setAttributesFromStrings(attributeType, "one", "two", "three");
verify(one).setFromString("one");
verify(two).setFromString("two");
verify(three).setFromString("three");
@@ -477,16 +471,16 @@ public class ArtifactTest {
when(attributeFactory.getMaxOccurrenceLimit(attributeType)).thenReturn(3);
- when(attributeFactory.createAttributeWithDefaults(eq(artifactImpl), any(ArtifactData.class), eq(attributeType))).thenReturn(
+ when(attributeFactory.createAttributeWithDefaults(eq(artifact), any(ArtifactData.class), eq(attributeType))).thenReturn(
two);
- artifactImpl.add(attributeType, one);
- artifactImpl.setAttributesFromStrings(attributeType, "1", "2");
+ artifact.add(attributeType, one);
+ artifact.setAttributesFromStrings(attributeType, "1", "2");
verify(one).setFromString("1");
verify(two).setFromString("2");
reset(one, two);
when(one.getValue()).thenReturn("1");
- artifactImpl.setAttributesFromStrings(attributeType, "1", "2");
+ artifact.setAttributesFromStrings(attributeType, "1", "2");
verify(one, never()).setFromString("1");
verify(two).setFromString("2");
}

Back to the top