@Test
public void shouldReturnJobDefinitionIfJobExists() throws Exception {

    // given
    final String jobType = "FooJob";
    final JobDefinition expectedDef = jobDefinition(jobType, "Foo");
    when(jobDefinitionService.getJobDefinition(jobType)).thenReturn(Optional.of(expectedDef));
    // when
    mockMvc.perform(
            get(MANAGEMENT_CONTEXT + "/jobdefinitions/FooJob")
                    .accept("application/json")
    )
            .andExpect(status().is(200))
            .andExpect(content().json("{\n" +
                    "  \"type\": \"FooJob\",\n" +
                    "  \"name\": \"Foo\",\n" +
                    "  \"retries\": 0,\n" +
                    "  \"fixedDelay\": 3600,\n" +
                    "  \"links\": [\n" +
                    "    {\n" +
                    "      \"href\": \"" + MANAGEMENT_CONTEXT + "/jobsdefinitions/FooJob\",\n" +
                    "      \"rel\": \"self\"\n" +
                    "    },\n" +
                    "    {\n" +
                    "      \"href\": \"" + MANAGEMENT_CONTEXT + "/jobdefinitions\",\n" +
                    "      \"rel\": \"collection\"\n" +
                    "    },\n" +
                    "    {\n" +
                    "      \"href\": \"" + MANAGEMENT_CONTEXT + "/jobs/FooJob\",\n" +
                    "      \"rel\": \"http://github.com/otto-de/edison/link-relations/job/trigger\"\n" +
                    "    }\n" +
                    "  ]\n" +
                    "}"));
}