Search code examples
javaintellij-ideacoding-stylerest-assuredjgiven

How to configure Intellij idea code formatting to according my example


I have butiful code in my tests

public void createEntity(String jsonString) {   
    response = getBaseRequestWithCurrentCookie()
            .given().
                    body(jsonString).
                    contentType(ContentType.JSON)
            .when().
                    post()
            .then().
                    log().ifError().
                    extract().response();
}

But how to configure intellij Idea code style(for Java) so that it doesn't align it ?

public void createEntity(String jsonString) {
    response = getBaseRequestWithCurrentCookie()
            .given().
            body(jsonString).
            contentType(ContentType.JSON)
            .when().
            post()
            .then().
            log().ifError().
            extract().response();
}


Solution

    1. Add builder method names to Settings (Preferences on macOS) | Editor | Code Style | Java | Wrapping and Braces | Chained method calls | Builder methods
    2. Enable Settings (Preferences on macOS) | Editor | Code Style | Java | Wrapping and Braces | Chained method calls | Keep builder methods indents option:

    enter image description here