ErrorHalRepresentationFactory { public ErrorHalRepresentation halRepresentationForErrorMessage(String errorMessage) { return ErrorHalRepresentation.builder() .withProfile(errorProfile) .withErrorMessage(errorMessage) .build(); } @Autowired  ErrorHalRepresentationFactory(
            ResourceBundleMessageSource edisonValidationMessageSource,
            ObjectMapper objectMapper,
            @Value("${edison.validation.error-profile:http://spec.otto.de/profiles/error}") String errorProfile); ErrorHalRepresentation halRepresentationForErrorMessage(String errorMessage); ErrorHalRepresentation halRepresentationForValidationErrors(Errors validationResult);  }
@Test public void shouldBuildRepresentationForErrorMessage() { String someErrorProfile = "someErrorProfile"; String someErrorMessage = "someErrorMessage"; final ErrorHalRepresentationFactory factory = new ErrorHalRepresentationFactory(messageSource, new ObjectMapper(), someErrorProfile); ErrorHalRepresentation errorHalRepresentation = factory.halRepresentationForErrorMessage(someErrorMessage); assertThat(errorHalRepresentation.getErrors().isEmpty(), is(true)); assertThat(errorHalRepresentation.getErrorMessage(), is(someErrorMessage)); assertThat(errorHalRepresentation.getLinks().getLinkBy("profile").isPresent(), is(true)); assertThat(errorHalRepresentation.getLinks().getLinkBy("profile").get().getHref(), is(someErrorProfile)); }