mercoledì 29 novembre 2017

CXF: How to get a json response and test it (as a Set)

    @Test
    public void sample() throws ParseException {

//read response
        Response response = client().path("cardex").path("changes").get();
        Assert.assertNotNull(response);
        Assert.assertTrue(response.getStatus() == 200);

//read response as a set
        Set<CardexDBTO> jsonResponse = new HashSet<>();
        jsonResponse = response.readEntity(new GenericType<Set<CardexDBTO>>() {
        });

//create a set same as the (test)object received
        Set<CardexDBTO> collect = new HashSet<>();
        CardexDBTO cardexResponse = null;
        cardexResponse = new CardexDBTO();
        cardexResponse.setNombre("Mario");
        cardexResponse.setEmail("mario@rossi.it");
        collect.add(cardexResponse);

//iterate and test
        for (CardexDBTO it : collect) {
            for (CardexDBTO it1 : jsonResponse) {
                Assert.assertEquals(it.getNombre(), it1.getNombre());
                Assert.assertEquals(it.getEmail(), it1.getEmail());
            }
        }
    }

Run minikube with podman on Fedora

After install minikube as described in the documentation , set rootless property to true to use Podman without sudo: minikube config set roo...