Search in sources :

Example 1 with Generator

use of org.graylog2.shared.rest.documentation.generator.Generator in project graylog2-server by Graylog2.

the class GeneratorTest method testGenerateOverview.

@Test
public void testGenerateOverview() throws Exception {
    Generator generator = new Generator("org.graylog2.rest.resources", objectMapper);
    Map<String, Object> result = generator.generateOverview();
    assertEquals(ServerVersion.VERSION.toString(), result.get("apiVersion"));
    assertEquals(Generator.EMULATED_SWAGGER_VERSION, result.get("swaggerVersion"));
    assertNotNull(result.get("apis"));
    assertTrue(((List) result.get("apis")).size() > 0);
}
Also used : List(java.util.List) Generator(org.graylog2.shared.rest.documentation.generator.Generator) Test(org.junit.Test)

Example 2 with Generator

use of org.graylog2.shared.rest.documentation.generator.Generator in project graylog2-server by Graylog2.

the class GeneratorTest method testGenerateForRoute.

@Test
public void testGenerateForRoute() throws Exception {
    Generator generator = new Generator("org.graylog2.rest.resources", objectMapper);
    Map<String, Object> result = generator.generateForRoute("/system", "http://localhost:12900/");
}
Also used : Generator(org.graylog2.shared.rest.documentation.generator.Generator) Test(org.junit.Test)

Example 3 with Generator

use of org.graylog2.shared.rest.documentation.generator.Generator in project graylog2-server by Graylog2.

the class RandomMessageTransport method produceRawMessage.

@Override
protected RawMessage produceRawMessage(MessageInput input) {
    final byte[] payload;
    try {
        final FakeHttpRawMessageGenerator.GeneratorState state = generator.generateState();
        payload = objectMapper.writeValueAsBytes(state);
        final RawMessage raw = new RawMessage(payload);
        sleepUninterruptibly(rateDeviation(sleepMs, maxSleepDeviation, rand), MILLISECONDS);
        return raw;
    } catch (JsonProcessingException e) {
        log.error("Unable to serialize generator state", e);
    }
    return null;
}
Also used : FakeHttpRawMessageGenerator(org.graylog2.inputs.random.generators.FakeHttpRawMessageGenerator) RawMessage(org.graylog2.plugin.journal.RawMessage) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException)

Aggregations

Generator (org.graylog2.shared.rest.documentation.generator.Generator)2 Test (org.junit.Test)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 List (java.util.List)1 FakeHttpRawMessageGenerator (org.graylog2.inputs.random.generators.FakeHttpRawMessageGenerator)1 RawMessage (org.graylog2.plugin.journal.RawMessage)1