/** * Serialize the DTO legal object deferred from its mockery as a json {@code String}. * @see DTO.Behaviour */ @Override public Object legal(Metadata<DTOJson> metadata) { JolyglotGenerics jolyglot = jolyglot(metadata); Object seed = dtoMockery.legal(DTOMetadata(metadata)); return jolyglot.toJson(seed); }
@Test public void When_Call_Legal_Then_Get_Legal() throws NoSuchMethodException { Method method = Providers.class.getDeclaredMethod("DTO"); DTO annotation = method.getAnnotation(DTO.class); Type type = method.getGenericReturnType(); Object[] args = {DTOArgsPass.class.getName()}; Metadata<DTO> metadata = new Metadata<>(Providers.class, method, args, annotation, type); Mock mock = (Mock) dtoMockery.legal(metadata); assertThat(mock.s1, is(DTOArgsPass.class.getName())); }
@Test public void When_Pass_Validation_Then_Do_Not_Throw_Assertion_Error() throws NoSuchMethodException { Method method = Providers.class.getDeclaredMethod("DTO"); DTO annotation = method.getAnnotation(DTO.class); Type type = method.getGenericReturnType(); Object[] args = {DTOArgsPass.class.getName()}; Metadata<DTO> metadata = new Metadata<>(Providers.class, method, args, annotation, type); Mock mock = (Mock) dtoMockery.legal(metadata); dtoMockery.validate(metadata, mock); }