tests/arq/src/test/java/org/jboss/test/arquillian/ce/common/TodoList.java
/**
     * Inserts an item in the todo example service.
     *
     * @param url         The url for the service
     * @param summary     The summary to be inserted in the todo list
     * @param description The description of the item
     * @throws Exception
     */
Inserts an item in the todo example service.
@param url         The url for the service
@param summary     The summary to be inserted in the todo list
@param description The description of the item
@throws Exception
Inserts an item in the todo example service . @param url The url for the service @param summary The summary to be inserted in the todo list @param description The description of the item @throws Exception
public static void insertItem(String url, String summary, String description) throws Exception {
        RestAssured.useRelaxedHTTPSValidation();
        Map<String, String> params = new HashMap<>();
        params.put("summary", summary);
        params.put("description", description);
        AtomicReference<Response> responseRef = new AtomicReference<>();
        await().atMost(20, TimeUnit.SECONDS).pollInterval(5, TimeUnit.SECONDS).until(() -> {
            try {
                Response r = given().formParams(params).post(url);
                if (r.getStatusCode() == 302) {
                    responseRef.set(r);
                    return true;
                }
                return false;
            } catch (Exception e) {
                return false;
            }
        });
        Response response = responseRef.get();
        if (response == null) {
            throw new Exception("Could not get response!");
        }
        Assert.assertEquals("Got an invalid response code. Body: " + response.print(), 302,
                response.getStatusCode());
        Assert.assertTrue("Got an invalid 'Location' header: " + response.header("Location"),
                response.header("Location").endsWith("/index.html"));
        checkItem(url, summary, description);
    }
public static void insertItem ( String url , String summary , String description ) throws Exception { RestAssured . useRelaxedHTTPSValidation ( ) ; Map < String , String > params = new HashMap < > ( ) ; params . put ( "summary" , summary ) ; params . put ( "description" , description ) ; AtomicReference < Response > responseRef = new AtomicReference < > ( ) ; await ( ) . atMost ( 20 , TimeUnit . SECONDS ) . pollInterval ( 5 , TimeUnit . SECONDS ) . until ( ( ) -> { try { Response r = given ( ) . formParams ( params ) . post ( url ) ; if ( r . getStatusCode ( ) == 302 ) { responseRef . set ( r ) ; return true ; } return false ; } catch ( Exception e ) { return false ; } } ) ; Response response = responseRef . get ( ) ; if ( response == null ) { throw new Exception ( "Could not get response!" ) ; } Assert . assertEquals ( "Got an invalid response code. Body: " + response . print ( ) , 302 , response . getStatusCode ( ) ) ; Assert . assertTrue ( "Got an invalid 'Location' header: " + response . header ( "Location" ) , response . header ( "Location" ) . endsWith ( "/index.html" ) ) ; checkItem ( url , summary , description ) ; }
Inserts an item in the todo example service.
Inserts an item in the todo example service .