-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement source code model copy functionality (#125)
* develop tests for go method modifiers * Fix test * Implement code model copy function * Bump version --------- Co-authored-by: Muntazir Fadhel <mfadhel@hadii.ca>
- Loading branch information
Showing
7 changed files
with
102 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package com.hadii.test; | ||
|
||
import static junit.framework.TestCase.assertEquals; | ||
|
||
import org.junit.Test; | ||
|
||
import com.hadii.clarpse.sourcemodel.Component; | ||
import com.hadii.clarpse.sourcemodel.OOPSourceCodeModel; | ||
import com.hadii.clarpse.sourcemodel.OOPSourceModelConstants.ComponentType; | ||
|
||
public class OOPSourceCodeModelTest { | ||
|
||
@Test | ||
public void codeModelCopyTest() { | ||
OOPSourceCodeModel original = new OOPSourceCodeModel(); | ||
Component component = new Component(); | ||
component.setComponentName("Test"); | ||
original.insertComponent(component); | ||
OOPSourceCodeModel copy = original.copy(); | ||
assertEquals(true, copy.size() == original.size()); | ||
assertEquals(1, copy.size()); | ||
} | ||
|
||
@Test | ||
public void codeModelTrueCopyTest() { | ||
OOPSourceCodeModel original = new OOPSourceCodeModel(); | ||
Component component = new Component(); | ||
component.setComponentName("Test"); | ||
original.insertComponent(component); | ||
OOPSourceCodeModel copy = original.copy(); | ||
copy.removeComponent(component.uniqueName()); | ||
assertEquals(false, copy.size() == original.size()); | ||
assertEquals(1, original.size()); | ||
assertEquals(0, copy.size()); | ||
} | ||
|
||
@Test | ||
public void parentBaseCmpTest() { | ||
OOPSourceCodeModel codeModel = new OOPSourceCodeModel(); | ||
Component testComponent = new Component(); | ||
testComponent.setComponentName("Test"); | ||
testComponent.insertChildComponent("ChildA"); | ||
testComponent.setComponentType(ComponentType.CLASS); | ||
|
||
Component componentA = new Component(); | ||
componentA.setComponentName("Test.ChildA"); | ||
componentA.insertChildComponent("ChildB"); | ||
componentA.setComponentType(ComponentType.METHOD); | ||
|
||
Component componentB = new Component(); | ||
componentB.setComponentName("Test.ChildA.ChildB"); | ||
componentB.setComponentType(ComponentType.LOCAL); | ||
|
||
codeModel.insertComponent(testComponent); | ||
codeModel.insertComponent(componentA); | ||
codeModel.insertComponent(componentB); | ||
|
||
assertEquals(testComponent, codeModel.parentBaseCmp(componentB.uniqueName())); | ||
} | ||
|
||
@Test(expected = IllegalArgumentException.class) | ||
public void parentBaseCmpTestTThrows() { | ||
OOPSourceCodeModel childCmp = new OOPSourceCodeModel(); | ||
Component component = new Component(); | ||
component.setComponentName("Test"); | ||
childCmp.parentBaseCmp("Test"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters