summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkwilk2012-03-23 14:11:23 (EDT)
committer Roberto E. Escobar2012-03-23 14:11:23 (EDT)
commit9e618c9fc620e0749027f5dc5a822c47868e5730 (patch)
treebe2ead9ac1db3bf36242c30259d6d360d3c3ac0f
parent46029c0c6e9937f989a6f1a6178d7a71f9410f9e (diff)
downloadorg.eclipse.osee-9e618c9fc620e0749027f5dc5a822c47868e5730.zip
org.eclipse.osee-9e618c9fc620e0749027f5dc5a822c47868e5730.tar.gz
org.eclipse.osee-9e618c9fc620e0749027f5dc5a822c47868e5730.tar.bz2
refactor: Update ChangeItem and ComputeNetChanges tests for new logic
-rw-r--r--plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/change/ChangeItemUtilTest.java32
-rw-r--r--plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/change/ChangeItemUtil.java21
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/commit/actions/CatchTrackedChanges.java4
-rw-r--r--plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/change/ComputeNetChangeTest.java18
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/change/ComputeNetChangeCallable.java9
5 files changed, 43 insertions, 41 deletions
diff --git a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/change/ChangeItemUtilTest.java b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/change/ChangeItemUtilTest.java
index 9166d28..1b9d939 100644
--- a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/change/ChangeItemUtilTest.java
+++ b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/change/ChangeItemUtilTest.java
@@ -104,22 +104,6 @@ public class ChangeItemUtilTest {
}
@Test
- public void testDestinationEqualOrNewerThanCurrent() {
- ChangeVersion isNew = ChangeTestUtility.createChange(2222L, ModificationType.NEW);
- ChangeVersion isIntroduced = ChangeTestUtility.createChange(2222L, ModificationType.NEW);
- ChangeVersion destination = ChangeTestUtility.createChange(1111L, ModificationType.NEW);
- ChangeItem item = ChangeTestUtility.createItem(200, null, null, isNew, destination, null);
- assertTrue(ChangeItemUtil.isDestinationEqualOrNewerThanCurrent(item));
-
- item = ChangeTestUtility.createItem(200, null, null, isIntroduced, destination, null);
- assertTrue(ChangeItemUtil.isDestinationEqualOrNewerThanCurrent(item));
-
- ChangeVersion isNotNew = ChangeTestUtility.createChange(2222L, ModificationType.MODIFIED);
- item = ChangeTestUtility.createItem(200, null, null, isNotNew, destination, null);
- assertFalse(ChangeItemUtil.isDestinationEqualOrNewerThanCurrent(item));
- }
-
- @Test
public void testIgnoreCase() {
ChangeVersion isNew = ChangeTestUtility.createChange(2222L, ModificationType.NEW);
@@ -148,7 +132,21 @@ public class ChangeItemUtilTest {
isNew = ChangeTestUtility.createChange(2222L, ModificationType.NEW);
destination = ChangeTestUtility.createChange(3333L, ModificationType.NEW);
item = ChangeTestUtility.createItem(200, null, null, isNew, destination, null);
- assertTrue(ChangeItemUtil.isIgnoreCase(item));
+ assertFalse(ChangeItemUtil.isIgnoreCase(item));
+
+ //destination Equal Or Newer Than Current
+ isNew = ChangeTestUtility.createChange(2222L, ModificationType.NEW);
+ ChangeVersion isIntroduced = ChangeTestUtility.createChange(2222L, ModificationType.NEW);
+ dest = ChangeTestUtility.createChange(1111L, ModificationType.NEW);
+ item = ChangeTestUtility.createItem(200, null, null, isNew, dest, null);
+ assertFalse(ChangeItemUtil.isIgnoreCase(item));
+
+ item = ChangeTestUtility.createItem(200, null, null, isIntroduced, dest, null);
+ assertFalse(ChangeItemUtil.isIgnoreCase(item));
+
+ ChangeVersion isNotNew = ChangeTestUtility.createChange(2222L, ModificationType.MODIFIED);
+ item = ChangeTestUtility.createItem(200, null, null, isNotNew, dest, null);
+ assertFalse(ChangeItemUtil.isIgnoreCase(item));
}
@Test
diff --git a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/change/ChangeItemUtil.java b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/change/ChangeItemUtil.java
index d0044c3..1c73eb1 100644
--- a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/change/ChangeItemUtil.java
+++ b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/change/ChangeItemUtil.java
@@ -87,7 +87,21 @@ public final class ChangeItemUtil {
public static boolean isAlreadyOnDestination(ChangeItem changeItem) {
return areGammasEqual(changeItem.getCurrentVersion(), changeItem.getDestinationVersion()) && //
- isDeleted(changeItem.getCurrentVersion()) == isDeleted(changeItem.getDestinationVersion());
+ areModTypesEqual(changeItem.getCurrentVersion(), changeItem.getDestinationVersion());
+ }
+
+ public static boolean areModTypesEqual(ChangeVersion object1, ChangeVersion object2) {
+ boolean result = false;
+ if (object1 == null && object2 == null) {
+ result = true;
+ } else if (object1 != null && object2 != null) {
+ if (object1.getModType() == object2.getModType()) {
+ result = true;
+ } else if (object1.getModType() != null) {
+ result = object1.getModType().equals(object2.getModType());
+ }
+ }
+ return result;
}
public static boolean areGammasEqual(ChangeVersion object1, ChangeVersion object2) {
@@ -110,7 +124,6 @@ public final class ChangeItemUtil {
isAlreadyOnDestination(changeItem) || //
isDeletedAndDoesNotExistInDestination(changeItem) || //
hasBeenDeletedInDestination(changeItem) || //
- isDestinationEqualOrNewerThanCurrent(changeItem) || //
hasBeenReplacedWithVersion(changeItem);
}
@@ -125,8 +138,4 @@ public final class ChangeItemUtil {
public static boolean hasBeenDeletedInDestination(ChangeItem changeItem) {
return changeItem.getDestinationVersion().isValid() && isDeleted(changeItem.getDestinationVersion());
}
-
- public static boolean isDestinationEqualOrNewerThanCurrent(ChangeItem changeItem) {
- return (isNew(changeItem.getCurrentVersion()) || isIntroduced(changeItem.getCurrentVersion())) && changeItem.getDestinationVersion().isValid();
- }
}
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/commit/actions/CatchTrackedChanges.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/commit/actions/CatchTrackedChanges.java
index 082ae26..294cc27 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/commit/actions/CatchTrackedChanges.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/commit/actions/CatchTrackedChanges.java
@@ -26,6 +26,7 @@ import org.eclipse.osee.framework.skynet.core.attribute.WordAttribute;
import org.eclipse.osee.framework.skynet.core.change.AttributeChange;
import org.eclipse.osee.framework.skynet.core.change.Change;
import org.eclipse.osee.framework.skynet.core.revision.ChangeManager;
+import org.eclipse.osee.framework.skynet.core.revision.LoadChangeType;
import org.eclipse.osee.framework.skynet.core.validation.IOseeValidator;
import org.eclipse.osee.framework.skynet.core.validation.OseeValidator;
@@ -48,8 +49,9 @@ public class CatchTrackedChanges implements CommitAction {
for (Change change : changes) {
if (!change.getModificationType().isDeleted()) {
- if (change instanceof AttributeChange) {
+ if (change.getChangeType() == LoadChangeType.attribute) {
Attribute<?> attribute = ((AttributeChange) change).getAttribute();
+
if (attribute instanceof WordAttribute) {
if (((WordAttribute) attribute).containsWordAnnotations()) {
throw new OseeCoreException(
diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/change/ComputeNetChangeTest.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/change/ComputeNetChangeTest.java
index 2bf4725..029ee41 100644
--- a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/change/ComputeNetChangeTest.java
+++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/change/ComputeNetChangeTest.java
@@ -39,24 +39,24 @@ public class ComputeNetChangeTest {
// New Or Introduced
data.add(createTest(1, null, entry(4L, NEW), entry(5L, MODIFIED), null, entry(5L, NEW), false));
data.add(createTest(2, null, entry(6L, INTRODUCED), entry(7L, MODIFIED), null, entry(7L, INTRODUCED), false));
+ data.add(createTest(3, null, null, entry(7693330L, INTRODUCED), entry(7693330L, NEW),
+ entry(7693330L, INTRODUCED), false));
// Modified Once
- data.add(createTest(3, entry(10L, MODIFIED), null, entry(11L, MODIFIED), entry(10L, MODIFIED),
+ data.add(createTest(4, entry(10L, MODIFIED), null, entry(11L, MODIFIED), entry(10L, MODIFIED),
entry(11L, MODIFIED), false));
// Modified Twice
- data.add(createTest(4, entry(10L, NEW), entry(11L, MODIFIED), entry(12L, MODIFIED), entry(10L, NEW),
+ data.add(createTest(5, entry(10L, NEW), entry(11L, MODIFIED), entry(12L, MODIFIED), entry(10L, NEW),
entry(12L, MODIFIED), false));
// Removal - new/intro and deleted
- data.add(createTest(5, null, entry(1L, NEW), entry(2L, DELETED), null, null, true));
- data.add(createTest(6, null, entry(2L, INTRODUCED), entry(3L, DELETED), null, null, true));
- data.add(createTest(7, null, entry(4L, NEW), entry(5L, ARTIFACT_DELETED), null, null, true));
- data.add(createTest(8, null, entry(6L, INTRODUCED), entry(7L, ARTIFACT_DELETED), null, null, true));
- data.add(createTest(9, null, null, entry(7693330L, INTRODUCED), entry(7693330L, NEW), null, true));
+ data.add(createTest(6, null, entry(1L, NEW), entry(2L, DELETED), null, null, true));
+ data.add(createTest(7, null, entry(2L, INTRODUCED), entry(3L, DELETED), null, null, true));
+ data.add(createTest(8, null, entry(4L, NEW), entry(5L, ARTIFACT_DELETED), null, null, true));
+ data.add(createTest(9, null, entry(6L, INTRODUCED), entry(7L, ARTIFACT_DELETED), null, null, true));
data.add(createTest(10, null, null, entry(21345L, NEW), entry(21345L, NEW), null, true));
-
- data.add(createTest(11, null, null, entry(1L, NEW), entry(2L, MODIFIED), null, null, true));
+ data.add(createTest(11, null, null, entry(1L, NEW), entry(2L, MODIFIED), null, entry(1L, NEW), false));
data.add(createTest(12, null, null, entry(1L, INTRODUCED), entry(2L, DELETED), null, null, true));
// Undelete then delete again
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/change/ComputeNetChangeCallable.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/change/ComputeNetChangeCallable.java
index 63b8b5a..a9ed852 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/change/ComputeNetChangeCallable.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/change/ComputeNetChangeCallable.java
@@ -26,13 +26,12 @@ public class ComputeNetChangeCallable extends CancellableCallable<List<ChangeIte
private final List<ChangeItem> changes;
public ComputeNetChangeCallable(List<ChangeItem> changes) {
- super();
this.changes = changes;
}
@Override
public List<ChangeItem> call() throws Exception {
- if (!changes.isEmpty()) {
+ if (changes != null) {
Iterator<ChangeItem> iterator = changes.iterator();
while (iterator.hasNext()) {
checkForCancelled();
@@ -96,11 +95,5 @@ public class ComputeNetChangeCallable extends CancellableCallable<List<ChangeIte
if (change.getDestinationVersion().isValid() && ChangeItemUtil.isDeleted(change.getDestinationVersion())) {
throw new OseeStateException("Destination was deleted - source should not modify [%s] ", change);
}
-
- if ((ChangeItemUtil.isIntroduced(change.getCurrentVersion()) || ChangeItemUtil.isNew(change.getCurrentVersion())) //
- && change.getDestinationVersion().isValid()) {
- throw new OseeStateException("Source item marked as new/introduced but destination already has item [%s]",
- change);
- }
}
} \ No newline at end of file