use of org.eclipse.n4js.tester.events.SessionStartedEvent in project n4js by eclipse.
the class StartSessionResource method createEvent.
@Override
@SuppressWarnings("unchecked")
protected TestEvent createEvent(final String sessionId, final String body) throws ClientResourceException {
final Map<?, ?> values = newHashMap();
try {
if (!isNullOrEmpty(body)) {
values.putAll(mapper.readValue(body, Map.class));
}
} catch (JsonMappingException | JsonParseException e) {
throw new ClientResourceException(SC_UNPROCESSABLE_ENTITY);
} catch (final IOException e) {
throw new ClientResourceException(SC_BAD_REQUEST);
}
final Map<String, String> properties = newHashMap();
if (null != values.get(PROPERTIES)) {
if (!(values.get(PROPERTIES) instanceof Map)) {
throw new ClientResourceException(SC_UNPROCESSABLE_ENTITY);
} else {
((Map<?, ?>) values.get(PROPERTIES)).entrySet().forEach(new Consumer<Entry<?, ?>>() {
@Override
public void accept(final Entry<?, ?> entry) {
properties.put(valueOf(entry.getKey()), valueOf(entry.getValue()));
}
});
}
}
return new SessionStartedEvent(sessionId, properties);
}
use of org.eclipse.n4js.tester.events.SessionStartedEvent in project n4js by eclipse.
the class TestEventQueueTest method testExpectedIsMoreThanActual.
/**
*/
@Test(expected = AssertionError.class)
public void testExpectedIsMoreThanActual() {
final String sessionId = "sessionId";
queue.init(1);
post(new SessionStartedEvent(sessionId));
queue.assertEquals(sessionId, "SessionStartedEvent|SID:sessionId|", "SessionStartedEvent|SID:sessionId|");
}
use of org.eclipse.n4js.tester.events.SessionStartedEvent in project n4js by eclipse.
the class TestEventQueueTest method testAssertFailedNonMatchingTailEvent.
/**
*/
@Test(expected = AssertionError.class)
public void testAssertFailedNonMatchingTailEvent() {
final String sessionId = "sessionId";
queue.init(1);
post(new SessionStartedEvent(sessionId));
queue.assertFailed(sessionId);
}
use of org.eclipse.n4js.tester.events.SessionStartedEvent in project n4js by eclipse.
the class TestEventQueueTest method testHappy.
/**
*/
@Test
public void testHappy() {
final String sessionId = "sessionId";
final String testId = "testId";
queue.init(5);
post(new SessionStartedEvent(sessionId));
post(new TestStartedEvent(sessionId, testId, 0L));
post(new TestPingedEvent(sessionId, testId, 0L));
post(new TestEndedEvent(sessionId, testId, null));
post(new SessionEndedEvent(sessionId));
queue.assertEquals(sessionId, "SessionStartedEvent|SID:sessionId|", "TestStartedEvent|SID:sessionId|TID:testId|", "TestPingedEvent|SID:sessionId|TID:testId|", "TestEndedEvent|SID:sessionId|TID:testId|", "SessionEndedEvent|SID:sessionId|");
}
use of org.eclipse.n4js.tester.events.SessionStartedEvent in project n4js by eclipse.
the class TestEventQueueTest method testExpectedNotEqualsActual.
/**
*/
@Test(expected = AssertionError.class)
public void testExpectedNotEqualsActual() {
final String sessionId = "sessionId";
queue.init(1);
post(new SessionStartedEvent(sessionId));
queue.assertEquals(sessionId, "SessionEndedEvent|SID:sessionId|");
}
Aggregations