This repository has been archived by the owner on Mar 2, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/fix-ts-export' into releases/0.3
- Loading branch information
Showing
8 changed files
with
314 additions
and
196 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
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
134 changes: 69 additions & 65 deletions
134
...c/com/specmate/testspecification/internal/testskeleton/JavaTestSpecificationSkeleton.java
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 |
---|---|---|
@@ -1,65 +1,69 @@ | ||
package com.specmate.testspecification.internal.testskeleton; | ||
|
||
import java.util.List; | ||
|
||
import com.specmate.model.testspecification.ParameterAssignment; | ||
import com.specmate.model.testspecification.TestCase; | ||
import com.specmate.model.testspecification.TestParameter; | ||
import com.specmate.model.testspecification.TestSpecification; | ||
|
||
public class JavaTestSpecificationSkeleton extends BaseSkeleton { | ||
|
||
public JavaTestSpecificationSkeleton(String language) { | ||
super(language); | ||
} | ||
|
||
@Override | ||
protected String generateFileName(TestSpecification testSpecification) { | ||
return getClassName(testSpecification) + ".java"; | ||
} | ||
|
||
private String getClassName(TestSpecification testSpecification) { | ||
return replaceInvalidChars(testSpecification.getName()) + "Test"; | ||
} | ||
|
||
@Override | ||
protected void generateHeader(StringBuilder sb, TestSpecification testSpecification, | ||
List<TestParameter> parameters) { | ||
sb.append("import org.junit.Test;\n"); | ||
sb.append("import org.junit.Assert;\n\n"); | ||
appendDateComment(sb); | ||
sb.append("public class "); | ||
sb.append(getClassName(testSpecification)); | ||
sb.append(" {\n\n"); | ||
} | ||
|
||
@Override | ||
protected void generateTestCaseFooter(StringBuilder sb, TestCase tc) { | ||
sb.append("() {\n"); | ||
sb.append("\t\tAssert.throw();\n"); | ||
sb.append("\t}\n\n"); | ||
} | ||
|
||
@Override | ||
protected void generateTestCaseHeader(StringBuilder sb, TestSpecification ts, TestCase tc) { | ||
sb.append("\t/*\n"); | ||
sb.append("\t * Testfall: "); | ||
sb.append(tc.getName()); | ||
sb.append("\n\t */\n"); | ||
sb.append("\t@Test\n"); | ||
sb.append("\tpublic void "); | ||
sb.append(getClassName(ts)); | ||
} | ||
|
||
@Override | ||
protected void generateFooter(StringBuilder sb, TestSpecification testSpecification) { | ||
sb.append("}"); | ||
} | ||
|
||
@Override | ||
protected void generateTestCaseParameterAssignments(StringBuilder sb, List<ParameterAssignment> assignments) { | ||
for (ParameterAssignment pAssignment : assignments) { | ||
appendParameterValue(sb, pAssignment); | ||
} | ||
} | ||
} | ||
package com.specmate.testspecification.internal.testskeleton; | ||
|
||
import java.util.List; | ||
|
||
import com.specmate.model.testspecification.ParameterAssignment; | ||
import com.specmate.model.testspecification.TestCase; | ||
import com.specmate.model.testspecification.TestParameter; | ||
import com.specmate.model.testspecification.TestSpecification; | ||
|
||
public class JavaTestSpecificationSkeleton extends BaseSkeleton { | ||
|
||
public JavaTestSpecificationSkeleton(String language) { | ||
super(language); | ||
} | ||
|
||
@Override | ||
protected String generateFileName(TestSpecification testSpecification) { | ||
return getClassName(testSpecification) + ".java"; | ||
} | ||
|
||
private String getClassName(TestSpecification testSpecification) { | ||
String tsName = testSpecification.getName(); | ||
if (tsName == null) { | ||
tsName = ""; | ||
} | ||
return replaceInvalidChars(tsName) + "Test"; | ||
} | ||
|
||
@Override | ||
protected void generateHeader(StringBuilder sb, TestSpecification testSpecification, | ||
List<TestParameter> parameters) { | ||
sb.append("import org.junit.Test;\n"); | ||
sb.append("import org.junit.Assert;\n\n"); | ||
appendDateComment(sb); | ||
sb.append("public class "); | ||
sb.append(getClassName(testSpecification)); | ||
sb.append(" {\n\n"); | ||
} | ||
|
||
@Override | ||
protected void generateTestCaseFooter(StringBuilder sb, TestCase tc) { | ||
sb.append("() {\n"); | ||
sb.append("\t\tAssert.throw();\n"); | ||
sb.append("\t}\n\n"); | ||
} | ||
|
||
@Override | ||
protected void generateTestCaseHeader(StringBuilder sb, TestSpecification ts, TestCase tc) { | ||
sb.append("\t/*\n"); | ||
sb.append("\t * Testfall: "); | ||
sb.append(tc.getName()); | ||
sb.append("\n\t */\n"); | ||
sb.append("\t@Test\n"); | ||
sb.append("\tpublic void "); | ||
sb.append(getClassName(ts)); | ||
} | ||
|
||
@Override | ||
protected void generateFooter(StringBuilder sb, TestSpecification testSpecification) { | ||
sb.append("}"); | ||
} | ||
|
||
@Override | ||
protected void generateTestCaseParameterAssignments(StringBuilder sb, List<ParameterAssignment> assignments) { | ||
for (ParameterAssignment pAssignment : assignments) { | ||
appendParameterValue(sb, pAssignment); | ||
} | ||
} | ||
} |
102 changes: 102 additions & 0 deletions
102
...specmate-testspecification/test/com/specmate/testspecification/test/TestSkeletonTest.java
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,102 @@ | ||
package com.specmate.testspecification.test; | ||
|
||
import java.util.Arrays; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import com.specmate.model.testspecification.ParameterAssignment; | ||
import com.specmate.model.testspecification.ParameterType; | ||
import com.specmate.model.testspecification.TestCase; | ||
import com.specmate.model.testspecification.TestParameter; | ||
import com.specmate.model.testspecification.TestSpecification; | ||
import com.specmate.model.testspecification.TestSpecificationSkeleton; | ||
import com.specmate.model.testspecification.TestspecificationFactory; | ||
import com.specmate.testspecification.internal.testskeleton.JavaTestSpecificationSkeleton; | ||
|
||
public class TestSkeletonTest { | ||
@Test | ||
public void testJavaSkeleton() { | ||
TestSpecification ts = getTestSpecification(); | ||
|
||
JavaTestSpecificationSkeleton skel = new JavaTestSpecificationSkeleton("JAVA"); | ||
TestSpecificationSkeleton result = skel.generate(ts); | ||
String code = result.getCode(); | ||
|
||
Assert.assertTrue(code.contains("public void TSTest___in1__in11___in2__in12___out1__out11___out2__out12()")); | ||
Assert.assertTrue(code.contains("public void TSTest___in1__in21___in2__in22___out1__out21___out2__out22()")); | ||
} | ||
|
||
private TestSpecification getTestSpecification() { | ||
TestspecificationFactory f = TestspecificationFactory.eINSTANCE; | ||
TestSpecification ts = f.createTestSpecification(); | ||
ts.setName("TS"); | ||
|
||
TestParameter input1 = f.createTestParameter(); | ||
input1.setId("in1"); | ||
input1.setName("in1"); | ||
input1.setType(ParameterType.INPUT); | ||
|
||
TestParameter input2 = f.createTestParameter(); | ||
input2.setId("in2"); | ||
input2.setName("in2"); | ||
input2.setType(ParameterType.INPUT); | ||
|
||
TestParameter output1 = f.createTestParameter(); | ||
output1.setId("out1"); | ||
output1.setName("out1"); | ||
output1.setType(ParameterType.OUTPUT); | ||
|
||
TestParameter output2 = f.createTestParameter(); | ||
output2.setId("out2"); | ||
output2.setName("out2"); | ||
output2.setType(ParameterType.OUTPUT); | ||
|
||
ts.getContents().addAll(Arrays.asList(input1, input2, output1, output2)); | ||
|
||
TestCase tc1 = f.createTestCase(); | ||
tc1.setId("tc1"); | ||
tc1.setName("tc1"); | ||
|
||
ParameterAssignment assIn11 = f.createParameterAssignment(); | ||
assIn11.setParameter(input1); | ||
assIn11.setValue("in11"); | ||
|
||
ParameterAssignment assIn12 = f.createParameterAssignment(); | ||
assIn12.setParameter(input2); | ||
assIn12.setValue("in12"); | ||
|
||
ParameterAssignment assOut11 = f.createParameterAssignment(); | ||
assOut11.setParameter(output1); | ||
assOut11.setValue("out11"); | ||
|
||
ParameterAssignment assOut12 = f.createParameterAssignment(); | ||
assOut12.setParameter(output2); | ||
assOut12.setValue("out12"); | ||
tc1.getContents().addAll(Arrays.asList(assIn11, assIn12, assOut11, assOut12)); | ||
|
||
TestCase tc2 = f.createTestCase(); | ||
tc2.setId("tc2"); | ||
tc2.setName("tc2"); | ||
|
||
ParameterAssignment assIn21 = f.createParameterAssignment(); | ||
assIn21.setParameter(input1); | ||
assIn21.setValue("in21"); | ||
|
||
ParameterAssignment assIn22 = f.createParameterAssignment(); | ||
assIn22.setParameter(input2); | ||
assIn22.setValue("in22"); | ||
|
||
ParameterAssignment assOut21 = f.createParameterAssignment(); | ||
assOut21.setParameter(output1); | ||
assOut21.setValue("out21"); | ||
|
||
ParameterAssignment assOut22 = f.createParameterAssignment(); | ||
assOut22.setParameter(output2); | ||
assOut22.setValue("out22"); | ||
tc2.getContents().addAll(Arrays.asList(assIn21, assIn22, assOut21, assOut22)); | ||
|
||
ts.getContents().addAll(Arrays.asList(tc1, tc2)); | ||
return ts; | ||
} | ||
} |
58 changes: 29 additions & 29 deletions
58
.../app/modules/views/side/modules/errors-warnings/components/errors-warnings.component.html
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 |
---|---|---|
@@ -1,30 +1,30 @@ | ||
<div *ngIf="visible" class="card"> | ||
<h5 class="card-header"> | ||
{{'ErrorsandWarnings' | translate}} | ||
<button id="linksactions-expand-button" type="button" class="btn btn-sm btn-secondary pull-right" | ||
(click)="isCollapsed = !isCollapsed" [attr.aria-expanded]="!isCollapsed" aria-controls="collapseExample"><i | ||
*ngIf="isCollapsed" class="fa fa-angle-double-down"></i><i *ngIf="!isCollapsed" | ||
class="fa fa-angle-double-up"></i></button> | ||
</h5> | ||
<div class="card-body"> | ||
<p class="card-text"> | ||
<short-model-error-message-display [model]="model"></short-model-error-message-display> | ||
<span *ngIf="warnings && warnings.length == 0" class="text-success"> | ||
<i aria-hidden="true" class="fa fa-check"></i> {{'NoWarnings' | translate}}. | ||
</span> | ||
</p> | ||
</div> | ||
<table *ngIf="warnings && warnings.length > 0" class="table"> | ||
<colgroup> | ||
<col width="50%" /> | ||
<col width="50%" /> | ||
</colgroup> | ||
<thead> | ||
<tr> | ||
<th>Elements</th> | ||
<th>Message</th> | ||
</tr> | ||
</thead> | ||
<tbody *ngFor="let warningList of warnings" warning [warnElements]="warningList"></tbody> | ||
</table> | ||
<div *ngIf="visible && showErrors" class="card"> | ||
<h5 class="card-header"> | ||
{{'ErrorsandWarnings' | translate}} | ||
<button id="linksactions-expand-button" type="button" class="btn btn-sm btn-secondary pull-right" | ||
(click)="isCollapsed = !isCollapsed" [attr.aria-expanded]="!isCollapsed" aria-controls="collapseExample"><i | ||
*ngIf="isCollapsed" class="fa fa-angle-double-down"></i><i *ngIf="!isCollapsed" | ||
class="fa fa-angle-double-up"></i></button> | ||
</h5> | ||
<div class="card-body"> | ||
<p class="card-text"> | ||
<short-model-error-message-display [model]="model"></short-model-error-message-display> | ||
<span *ngIf="warnings && warnings.length == 0" class="text-success"> | ||
<i aria-hidden="true" class="fa fa-check"></i> {{'NoWarnings' | translate}}. | ||
</span> | ||
</p> | ||
</div> | ||
<table *ngIf="warnings && warnings.length > 0" class="table"> | ||
<colgroup> | ||
<col width="50%" /> | ||
<col width="50%" /> | ||
</colgroup> | ||
<thead> | ||
<tr> | ||
<th>Elements</th> | ||
<th>Message</th> | ||
</tr> | ||
</thead> | ||
<tbody *ngFor="let warningList of warnings" warning [warnElements]="warningList"></tbody> | ||
</table> | ||
</div> |
Oops, something went wrong.