Skip to content

Commit

Permalink
[#17] Xtend-compilation error in tests
Browse files Browse the repository at this point in the history
Add generated Java files.
  • Loading branch information
ghillairet committed Oct 23, 2015
1 parent 03d9628 commit 8aaaed9
Show file tree
Hide file tree
Showing 5 changed files with 686 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.reprezen.swagedit.tests

import com.reprezen.swagedit.editor.SwaggerDocument
import io.swagger.util.Yaml
import org.junit.Test
import org.yaml.snakeyaml.events.ScalarEvent

Expand Down Expand Up @@ -48,4 +49,25 @@ class SwaggerDocumentTest {
assertThat(e2.value).isEqualTo("Tax Blaster")
}

@Test
def void testGetRootMapping() {
val yaml = '''
info:
description: ""
tags:
- foo: ""
- bar: ""
'''

document.set(yaml)
val path = document.getPath(1)
println(path)

println(document.getPath(3))
val node = Yaml.mapper.readTree(yaml)
println(node)
//val events = document.getEvent(1)
//println(events)
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
package com.reprezen.swagedit.tests;

import com.reprezen.swagedit.assist.SwaggerCompletionProposal;
import com.reprezen.swagedit.assist.SwaggerContentAssistProcessor;
import com.reprezen.swagedit.assist.SwaggerProposal;
import com.reprezen.swagedit.editor.SwaggerDocument;
import com.reprezen.swagedit.validation.SwaggerSchema;
import java.util.Map;
import java.util.Set;
import org.assertj.core.api.AbstractCharSequenceAssert;
import org.assertj.core.api.AbstractObjectArrayAssert;
import org.assertj.core.api.Assertions;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
import org.eclipse.swt.graphics.Point;
import org.eclipse.xtend2.lib.StringConcatenation;
import org.eclipse.xtext.xbase.lib.Conversions;
import org.eclipse.xtext.xbase.lib.InputOutput;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
import org.mockito.stubbing.OngoingStubbing;

@SuppressWarnings("all")
public class SwaggerContentAssistProcessorTest {
private final SwaggerSchema schema = new SwaggerSchema();

private IDocument document;

private IContentAssistProcessor processor;

private ITextViewer viewer;

@Before
public void setUp() {
SwaggerDocument _swaggerDocument = new SwaggerDocument();
this.document = _swaggerDocument;
SwaggerContentAssistProcessor _swaggerContentAssistProcessor = new SwaggerContentAssistProcessor();
this.processor = _swaggerContentAssistProcessor;
ITextViewer _mock = Mockito.<ITextViewer>mock(ITextViewer.class);
this.viewer = _mock;
}

@Test
public void shouldProvideAllKeywordsWhenDocIsEmpty() throws BadLocationException {
StringConcatenation _builder = new StringConcatenation();
final String yaml = _builder.toString();
final int offset = 0;
IDocument _document = this.viewer.getDocument();
OngoingStubbing<IDocument> _when = Mockito.<IDocument>when(_document);
_when.thenReturn(this.document);
Point _selectedRange = this.viewer.getSelectedRange();
OngoingStubbing<Point> _when_1 = Mockito.<Point>when(_selectedRange);
Point _point = new Point(0, 0);
_when_1.thenReturn(_point);
this.document.set(yaml);
final ICompletionProposal[] proposals = this.processor.computeCompletionProposals(this.viewer, offset);
AbstractObjectArrayAssert<?, ICompletionProposal> _assertThat = Assertions.<ICompletionProposal>assertThat(proposals);
Set<String> _keywords = this.schema.getKeywords();
int _length = ((Object[])Conversions.unwrapArray(_keywords, Object.class)).length;
_assertThat.hasSize(_length);
}

@Test
public void shouldProvideEndOfWord() {
StringConcatenation _builder = new StringConcatenation();
_builder.append("swa");
final String yaml = _builder.toString();
final int offset = 3;
IDocument _document = this.viewer.getDocument();
OngoingStubbing<IDocument> _when = Mockito.<IDocument>when(_document);
_when.thenReturn(this.document);
Point _selectedRange = this.viewer.getSelectedRange();
OngoingStubbing<Point> _when_1 = Mockito.<Point>when(_selectedRange);
Point _point = new Point(0, 0);
_when_1.thenReturn(_point);
this.document.set(yaml);
final ICompletionProposal[] proposals = this.processor.computeCompletionProposals(this.viewer, offset);
AbstractObjectArrayAssert<?, ICompletionProposal> _assertThat = Assertions.<ICompletionProposal>assertThat(proposals);
_assertThat.hasSize(1);
final ICompletionProposal proposal = proposals[0];
proposal.apply(this.document);
String _get = this.document.get();
AbstractCharSequenceAssert<?, String> _assertThat_1 = Assertions.assertThat(_get);
_assertThat_1.isEqualTo("swagger");
}

@Test
public void test() {
SwaggerCompletionProposal _swaggerCompletionProposal = new SwaggerCompletionProposal();
SwaggerProposal.ObjectProposal _get = _swaggerCompletionProposal.get();
final SwaggerProposal.ObjectProposal proposal = ((SwaggerProposal.ObjectProposal) _get);
Map<String, SwaggerProposal> _properties = proposal.getProperties();
final SwaggerProposal value = _properties.get("swagger");
InputOutput.<SwaggerProposal>println(value);
Assert.assertNotNull(value);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
package com.reprezen.swagedit.tests;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.reprezen.swagedit.editor.SwaggerDocument;
import io.swagger.util.Yaml;
import java.util.List;
import org.assertj.core.api.AbstractCharSequenceAssert;
import org.assertj.core.api.AbstractListAssert;
import org.assertj.core.api.Assertions;
import org.eclipse.xtend2.lib.StringConcatenation;
import org.eclipse.xtext.xbase.lib.Exceptions;
import org.eclipse.xtext.xbase.lib.InputOutput;
import org.junit.Test;
import org.yaml.snakeyaml.events.Event;
import org.yaml.snakeyaml.events.ScalarEvent;

@SuppressWarnings("all")
public class SwaggerDocumentTest {
private final SwaggerDocument document = new SwaggerDocument();

@Test
public void testGetCorrectListOfEvents() {
StringConcatenation _builder = new StringConcatenation();
_builder.append("key: \'value\'");
_builder.newLine();
final String yaml = _builder.toString();
this.document.set(yaml);
final List<Event> events = this.document.getEvent(0);
AbstractListAssert<?, ? extends List<? extends Event>, Event> _assertThat = Assertions.<Event>assertThat(events);
_assertThat.hasSize(2);
Event _get = events.get(0);
final ScalarEvent e1 = ((ScalarEvent) _get);
Event _get_1 = events.get(1);
final ScalarEvent e2 = ((ScalarEvent) _get_1);
String _value = e1.getValue();
AbstractCharSequenceAssert<?, String> _assertThat_1 = Assertions.assertThat(_value);
_assertThat_1.isEqualTo("key");
String _value_1 = e2.getValue();
AbstractCharSequenceAssert<?, String> _assertThat_2 = Assertions.assertThat(_value_1);
_assertThat_2.isEqualTo("value");
}

@Test
public void test() {
StringConcatenation _builder = new StringConcatenation();
_builder.append("info:");
_builder.newLine();
_builder.append(" ");
_builder.append("description: \"Tax Blaster\"");
_builder.newLine();
_builder.append(" ");
_builder.append("version: \"1.0.0\"");
_builder.newLine();
final String yaml = _builder.toString();
this.document.set(yaml);
final List<Event> events = this.document.getEvent(1);
AbstractListAssert<?, ? extends List<? extends Event>, Event> _assertThat = Assertions.<Event>assertThat(events);
_assertThat.hasSize(2);
Event _get = events.get(0);
final ScalarEvent e1 = ((ScalarEvent) _get);
Event _get_1 = events.get(1);
final ScalarEvent e2 = ((ScalarEvent) _get_1);
String _value = e1.getValue();
AbstractCharSequenceAssert<?, String> _assertThat_1 = Assertions.assertThat(_value);
_assertThat_1.isEqualTo("description");
String _value_1 = e2.getValue();
AbstractCharSequenceAssert<?, String> _assertThat_2 = Assertions.assertThat(_value_1);
_assertThat_2.isEqualTo("Tax Blaster");
}

@Test
public void testGetRootMapping() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("info:");
_builder.newLine();
_builder.append(" ");
_builder.append("description: \"\"");
_builder.newLine();
_builder.append("tags:");
_builder.newLine();
_builder.append(" ");
_builder.append("- foo: \"\"");
_builder.newLine();
_builder.append(" ");
_builder.append("- bar: \"\"");
_builder.newLine();
final String yaml = _builder.toString();
this.document.set(yaml);
final List<String> path = this.document.getPath(1);
InputOutput.<List<String>>println(path);
List<String> _path = this.document.getPath(3);
InputOutput.<List<String>>println(_path);
ObjectMapper _mapper = Yaml.mapper();
final JsonNode node = _mapper.readTree(yaml);
InputOutput.<JsonNode>println(node);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
}
Loading

0 comments on commit 8aaaed9

Please sign in to comment.