Skip to content

Commit

Permalink
Allow to set diagram concepts to null
Browse files Browse the repository at this point in the history
- The corresponding methods setArchimateElement() and setArchimateRelationship() can be set to null so these should allow it too

- Note that eUnset() will set setArchimateElement() and setArchimateRelationship() to null and this can be called by EMF Compare, for example
  • Loading branch information
Phillipus committed Jul 30, 2024
1 parent f412315 commit 7d11e7a
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public IArchimateRelationship getArchimateConcept() {
*/
@Override
public void setArchimateConcept(IArchimateConcept concept) {
if(!(concept instanceof IArchimateRelationship)) {
if(concept != null && !(concept instanceof IArchimateRelationship)) {
throw new IllegalArgumentException("Should be of type IArchimateRelationship"); //$NON-NLS-1$
}
setArchimateRelationship((IArchimateRelationship)concept);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ public IArchimateElement getArchimateConcept() {
*/
@Override
public void setArchimateConcept(IArchimateConcept concept) {
if(!(concept instanceof IArchimateElement)) {
if(concept != null && !(concept instanceof IArchimateElement)) {
throw new IllegalArgumentException("Should be of type IArchimateElement"); //$NON-NLS-1$
}
setArchimateElement((IArchimateElement)concept);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ public void testReconnect() {
public void testGetArchimateRelationship() {
assertSame(relationship, connection.getArchimateRelationship());
}

@Test
public void testSetArchimateRelationshipCanBeNull() {
connection.setArchimateRelationship(null);
assertNull(connection.getArchimateRelationship());
}

@Test
public void testGetArchimateConcept() {
Expand All @@ -100,6 +106,20 @@ public void testSetArchimateConcept() {
assertSame(r, connection.getArchimateConcept());
assertSame(r, connection.getArchimateRelationship());
}

@Test
public void testSetArchimateConceptCanBeNull() {
connection.setArchimateConcept(null);
assertNull(connection.getArchimateConcept());
assertNull(connection.getArchimateRelationship());
}

@Test
public void testSetArchimateConceptThrowsException() {
assertThrows(IllegalArgumentException.class, () -> {
connection.setArchimateConcept(IArchimateFactory.eINSTANCE.createBusinessActor());
});
}

@Test
public void testAddArchimateRelationshipToModel_AlreadyHasParent() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ public void testGetArchimateElement() {
assertSame(element, object.getArchimateElement());
}

@Test
public void testSetArchimateElementCanBeNull() {
object.setArchimateElement(null);
assertNull(object.getArchimateElement());
}

@Test
public void testGetArchimateConcept() {
assertSame(element, object.getArchimateConcept());
Expand All @@ -77,6 +83,20 @@ public void testSetArchimateConcept() {
assertSame(e, object.getArchimateConcept());
assertSame(e, object.getArchimateElement());
}

@Test
public void testSetArchimateConceptCanBeNull() {
object.setArchimateConcept(null);
assertNull(object.getArchimateConcept());
assertNull(object.getArchimateElement());
}

@Test
public void testSetArchimateConceptThrowsException() {
assertThrows(IllegalArgumentException.class, () -> {
object.setArchimateConcept(IArchimateFactory.eINSTANCE.createAssociationRelationship());
});
}

@Test
public void testGetType() {
Expand Down

0 comments on commit 7d11e7a

Please sign in to comment.