Commit 3475f9fb authored by Martti Käärik's avatar Martti Käärik
Browse files

Proper rendering of multi-line text + TD and related TO notifications. #188

parent 2b6beb51
Loading
Loading
Loading
Loading
Loading
+17 −7
Original line number Diff line number Diff line
@@ -827,7 +827,10 @@ public class JUnitTestGenerator extends Renderer {
		blockOpen();

		Set<String> thrownExceptions = new HashSet<String>();
		writeNotification(tc, true);
		write(tc.getBehaviourDescription().getBehaviour(), null, null, thrownExceptions);
		writeNotification(tc, false);
		writeObjective(tc.getTestObjective());

		blockClose();

@@ -1513,7 +1516,7 @@ public class JUnitTestGenerator extends Renderer {
		}

		writeNotification(b, false);
		writeObjective(b);
		writeObjective(b.getTestObjective());

		newLine();
		exceptionalBehaviours.forEach(eb -> {
@@ -2511,18 +2514,25 @@ public class JUnitTestGenerator extends Renderer {
		});
	}

	private void writeObjective(Behaviour b) {
	private void writeObjective(List<TestObjective> objectives) {
		// TODO multiple URIs
		b.getTestObjective().forEach(to -> {
		objectives.forEach(to -> {
			append(REPORTER_FIELD + ".testObjectiveReached(");
			append(COMPONENT_FIELD + ".getTesterComponent().getName(), ");
			append("\"" + to.getObjectiveURI() + "\", ");
			append("\"" + to.getDescription() + "\"");
			writeTextBlock(String.join(" | ", to.getObjectiveURI()));
			append(", ");
			writeTextBlock(to.getDescription());
			line(");");
		});
	}
	
	private void writeNotification(Behaviour b, boolean started) {
	private void writeTextBlock(String text) {
		line("\"\"\"");
		append(text);
		append("\"\"\"");
	}

	private void writeNotification(Element b, boolean started) {
		if (logEvents) {
			String behaviour = "";
			if (settings.logBehaviourTraces && b instanceof AtomicBehaviour && b.eResource() instanceof XtextResource) {
@@ -2555,7 +2565,7 @@ public class JUnitTestGenerator extends Renderer {
	 * 
	 * @return A descriptive name of the behaviour.
	 */
	private String getQName(Behaviour b) {
	private String getQName(Element b) {
		// XXX
		String name = b.getName();
		if (name == null)