@Override public void validate(Model candidate) throws AssertionError { if (candidate == null) throw new AssertionError("model can not be null"); if (!candidate.getS1().equals(Model.class.getName())) { throw new AssertionError("model.s1 must be equal to " + Model.class.getName()); } } }
@Override public void validate(Model candidate) throws AssertionError { if (candidate == null) throw new AssertionError("model can not be null"); if (!candidate.getS1().equals(Model.class.getName())) { throw new AssertionError("model.s1 must be equal to " + Model.class.getName()); } } }
@Override public void validate(Model candidate) throws AssertionError { if (candidate == null) throw new AssertionError("model can not be null"); if (!candidate.getS1().equals(Model.class.getName())) { throw new AssertionError("model.s1 must be equal to " + Model.class.getName()); } } }
@Override public void validate(List<Model> candidate) throws AssertionError { if (candidate == null) throw new AssertionError("models can not be null"); if (candidate.size() != 1) throw new AssertionError("models must has one entry"); if (!candidate.get(0).getS1().equals(Model.class.getName())) { throw new AssertionError("model.s1 must be equal to " + Model.class.getName()); } } }
@Override public void validate(List<Model> candidate) throws AssertionError { if (candidate == null) throw new AssertionError("models can not be null"); if (candidate.size() != 1) throw new AssertionError("models must has one entry"); if (!candidate.get(0).getS1().equals(Model.class.getName())) { throw new AssertionError("model.s1 must be equal to " + Model.class.getName()); } } }
@Test public void modelsWithParams() { String email = "foo@foo.bar"; List<Model> models = restApi.modelsWithParams(email, null); assertThat(models.size(), is(1)); assertThat(models.get(0).getS1(), is(Model.class.getName())); }
@Test public void modelWithEnum() { String order = "asc"; Model model = restApi.modelWithEnum(order); assertThat(model.getS1(), is(Model.class.getName())); }
@Test public void modelsWithParamsSync() throws IOException { RequestBody requestBody = RequestBody .create(MediaType.parse("text/plain"), "foo@foo.bar"); Response<List<Model>> responseModels = restApi.modelsWithParams(requestBody, null).execute(); assertTrue(responseModels.isSuccessful()); List<Model> models = responseModels.body(); assertThat(models.size(), is(1)); assertThat(models.get(0).getS1(), is(Model.class.getName())); }
@Test public void modelWithParamsSync() throws IOException { RequestBody requestBody = RequestBody .create(MediaType.parse("text/plain"), "{\"s1\":\"io.victoralbertos.mockery.internal.integration.Model\"}"); Response<Model> responseModel = restApi .modelWithParams(requestBody, 0).execute(); assertTrue(responseModel.isSuccessful()); Model model = responseModel.body(); assertThat(model.getS1(), is(Model.class.getName())); }
@Test public void modelsSync() throws IOException { Response<List<Model>> responseModels = restApi.models("[{\"s1\":\"io.victoralbertos.mockery.internal.integration.Model\"}]").execute(); assertTrue(responseModels.isSuccessful()); List<Model> models = responseModels.body(); assertThat(models.size(), is(1)); assertThat(models.get(0).getS1(), is(Model.class.getName())); }
@Test public void modelsWithParam() { String json = "[{\"s1\":\"io.victoralbertos.mockery.internal.integration.Model\"}]"; TestSubscriber<List<Model>> subscriber = new TestSubscriber<>(); restApi.modelsWithParam(json).subscribe(subscriber); subscriber.awaitTerminalEvent(); subscriber.assertNoErrors(); subscriber.assertValueCount(1); List<Model> models = subscriber.getOnNextEvents().get(0); assertThat(models.size(), is(1)); assertThat(models.get(0).getS1(), is(Model.class.getName())); }
@Test public void modelWithParams() { RequestBody requestBody = RequestBody .create(MediaType.parse("text/plain"), "{\"s1\":\"io.victoralbertos.mockery.internal.integration.Model\"}"); TestSubscriber<Model> subscriber = new TestSubscriber<>(); restApi.modelWithParams(requestBody, 0).subscribe(subscriber); subscriber.awaitTerminalEvent(); subscriber.assertNoErrors(); subscriber.assertValueCount(1); Model model = subscriber.getOnNextEvents().get(0); assertThat(model.getS1(), is(Model.class.getName())); }
@Test public void modelsWithParam() { String json = "[{\"s1\":\"io.victoralbertos.mockery.internal.integration.Model\"}]"; TestObserver<List<Model>> subscriber = restApi.modelsWithParam(json).test(); subscriber.awaitTerminalEvent(); subscriber.assertNoErrors(); subscriber.assertValueCount(1); List<Model> models = subscriber.values().get(0); assertThat(models.size(), is(1)); assertThat(models.get(0).getS1(), is(Model.class.getName())); }
@Test public void modelWithParams() { RequestBody requestBody = RequestBody .create(MediaType.parse("text/plain"), "{\"s1\":\"io.victoralbertos.mockery.internal.integration.Model\"}"); TestObserver<Model> subscriber = restApi.modelWithParams(requestBody, 0).test(); subscriber.awaitTerminalEvent(); subscriber.assertNoErrors(); subscriber.assertValueCount(1); Model model = subscriber.values().get(0); assertThat(model.getS1(), is(Model.class.getName())); }
@Test public void modelsWithParamResponse() { String json = "[{\"s1\":\"io.victoralbertos.mockery.internal.integration.Model\"}]"; TestObserver<Response<List<Model>>> subscriber = restApi.modelsWithParamResponse(json).test(); subscriber.awaitTerminalEvent(); subscriber.assertNoErrors(); subscriber.assertValueCount(1); Response<List<Model>> modelsResponse = subscriber.values().get(0); assertTrue(modelsResponse.isSuccessful()); List<Model> models = modelsResponse.body(); assertThat(models.size(), is(1)); assertThat(models.get(0).getS1(), is(Model.class.getName())); }
@Test public void modelWithParamsResponse() { RequestBody requestBody = RequestBody .create(MediaType.parse("text/plain"), "{\"s1\":\"io.victoralbertos.mockery.internal.integration.Model\"}"); TestObserver<Response<Model>> subscriber = restApi.modelWithParamsResponse(requestBody, 0).test(); subscriber.awaitTerminalEvent(); subscriber.assertNoErrors(); subscriber.assertValueCount(1); Response<Model> modelResponse = subscriber.values().get(0); assertTrue(modelResponse.isSuccessful()); Model model = modelResponse.body(); assertThat(model.getS1(), is(Model.class.getName())); }
@Test public void model() { TestSubscriber<Model> subscriber = new TestSubscriber<>(); restApi.model().subscribe(subscriber); subscriber.awaitTerminalEvent(); subscriber.assertNoErrors(); subscriber.assertValueCount(1); Model model = subscriber.getOnNextEvents().get(0); assertThat(model.getS1(), is(Model.class.getName())); }
@Test public void modelResponse() { TestSubscriber<Response<Model>> subscriber = new TestSubscriber<>(); restApi.modelResponse().subscribe(subscriber); subscriber.awaitTerminalEvent(); subscriber.assertNoErrors(); subscriber.assertValueCount(1); Response<Model> modelResponse = subscriber.getOnNextEvents().get(0); assertTrue(modelResponse.isSuccessful()); Model model = modelResponse.body(); assertThat(model.getS1(), is(Model.class.getName())); }
@Test public void model() { TestObserver<Model> subscriber = restApi.model().test(); subscriber.awaitTerminalEvent(); subscriber.assertNoErrors(); subscriber.assertValueCount(1); Model model = subscriber.values().get(0); assertThat(model.getS1(), is(Model.class.getName())); }
@Test public void modelResponse() { TestObserver<Response<Model>> subscriber = restApi.modelResponse().test(); subscriber.awaitTerminalEvent(); subscriber.assertNoErrors(); subscriber.assertValueCount(1); Response<Model> modelResponse = subscriber.values().get(0); assertTrue(modelResponse.isSuccessful()); Model model = modelResponse.body(); assertThat(model.getS1(), is(Model.class.getName())); }