Skip to content

Commit

Permalink
fix formatting settings for Builder pattern style, format changes for…
Browse files Browse the repository at this point in the history
… rest of the files
  • Loading branch information
mnembrini committed Jan 25, 2018
1 parent 8581b23 commit a92eb7d
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 45 deletions.
2 changes: 1 addition & 1 deletion eclipseFormatter.xml
Expand Up @@ -163,7 +163,7 @@
<setting id="org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode" value="enabled"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_method_declaration" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.join_wrapped_lines" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.join_wrapped_lines" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_before_conditional_operator" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases" value="true"/>
Expand Down
12 changes: 7 additions & 5 deletions src/main/java/core/Harvest.java
@@ -1,24 +1,26 @@
package core;

import java.io.IOException;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.gson.Gson;

import api.TimesheetsApi;
import api.UsersApi;
import com.google.gson.Gson;
import core.gson.GsonConfiguration;
import impl.TimesheetsApiImpl;
import impl.UsersApiImpl;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.logging.HttpLoggingInterceptor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
import service.TimeEntryService;
import service.UserService;

import java.io.IOException;

public class Harvest {

private static final Logger log = LoggerFactory.getLogger(Harvest.class);
Expand Down
20 changes: 11 additions & 9 deletions src/main/java/exception/RequestProcessingException.java
@@ -1,27 +1,29 @@
package exception;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.gson.Gson;

import core.gson.GsonConfiguration;
import okhttp3.ResponseBody;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class RequestProcessingException extends HarvestHttpException {


private static final Logger log = LoggerFactory.getLogger(RequestProcessingException.class);

public RequestProcessingException(ResponseBody responseBody) {
super(responseBody, 422, initMessage(responseBody));

}

public static String initMessage(ResponseBody responseBody) {
Gson gson = GsonConfiguration.getConfiguration();

RequestProcessingErrorMessage parsedMessage = gson.fromJson(responseBody.charStream(), RequestProcessingErrorMessage.class);
RequestProcessingErrorMessage parsedMessage = gson.fromJson(responseBody.charStream(),
RequestProcessingErrorMessage.class);

return parsedMessage.getMessage();
}

public RequestProcessingException(ResponseBody responseBody) {
super(responseBody, 422, initMessage(responseBody));

}

}
15 changes: 7 additions & 8 deletions src/test/java/examples/UsersApiExample.java
@@ -1,14 +1,15 @@
package examples;

import core.Harvest;
import domain.User;
import domain.param.UserCreationInfo;
import java.util.List;

import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import util.TestSetupUtil;

import java.util.List;
import core.Harvest;
import domain.User;
import domain.param.UserCreationInfo;
import util.TestSetupUtil;

public class UsersApiExample {

Expand All @@ -27,12 +28,10 @@ public void listUsers() {
}
}


@Test
public void createUser() {

UserCreationInfo userInfo = new UserCreationInfo.Builder("testFirst", "testLast", "test@test.ch")
.build();
UserCreationInfo userInfo = new UserCreationInfo.Builder("testFirst", "testLast", "test@test.ch").build();

User newUser = harvest.users().create(userInfo);

Expand Down
38 changes: 16 additions & 22 deletions src/test/java/impl/UsersApiImplTest.java
@@ -1,23 +1,24 @@
package impl;

import api.UsersApi;
import domain.User;
import domain.param.UserCreationInfo;
import domain.param.UserInfo;
import exception.NotFoundException;
import exception.RequestProcessingException;
import java.util.List;
import java.util.Optional;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import util.TestSetupUtil;

import java.util.List;
import java.util.Optional;

import static org.junit.jupiter.api.Assertions.*;

import api.UsersApi;
import domain.User;
import domain.param.UserCreationInfo;
import domain.param.UserInfo;
import exception.NotFoundException;
import exception.RequestProcessingException;
import util.TestSetupUtil;

class UsersApiImplTest {

private final static Logger log = LoggerFactory.getLogger(UsersApiImplTest.class);
Expand All @@ -35,7 +36,6 @@ class UsersApiImplTest {
private final static String fixUserEmail = "fix.user@gmail.com";
private static User fixUser;


@BeforeAll
public static void beforeAll() {

Expand All @@ -46,7 +46,8 @@ public static void beforeAll() {
log.debug("Fix user exists already, nothing to do");
fixUser = user.get();
} else {
UserCreationInfo creationInfo = new UserCreationInfo.Builder(fixUserFirst, fixUserLast, fixUserEmail).build();
UserCreationInfo creationInfo = new UserCreationInfo.Builder(fixUserFirst, fixUserLast, fixUserEmail)
.build();
fixUser = api.create(creationInfo);
log.debug("Created Fix user");
}
Expand All @@ -63,8 +64,7 @@ void list() {
@Test
void createExistingEmailFails() {
RequestProcessingException exception = Assertions.assertThrows(RequestProcessingException.class, () -> {
UserCreationInfo creationInfo = new UserCreationInfo
.Builder(fixUserFirst, fixUserLast, fixUserEmail)
UserCreationInfo creationInfo = new UserCreationInfo.Builder(fixUserFirst, fixUserLast, fixUserEmail)
.build();

api.create(creationInfo);
Expand All @@ -76,9 +76,7 @@ void createExistingEmailFails() {
@Test
void createAndDeleteUser() {

UserCreationInfo creationInfo = new UserCreationInfo
.Builder(userFirst, userLast, userEmail)
.build();
UserCreationInfo creationInfo = new UserCreationInfo.Builder(userFirst, userLast, userEmail).build();

User user = api.create(creationInfo);

Expand All @@ -89,10 +87,7 @@ void createAndDeleteUser() {
@Test
void createAndDeleteUserById() {


UserCreationInfo creationInfo = new UserCreationInfo
.Builder(userFirst, userLast, userEmail)
.build();
UserCreationInfo creationInfo = new UserCreationInfo.Builder(userFirst, userLast, userEmail).build();

User user = api.create(creationInfo);

Expand Down Expand Up @@ -135,7 +130,6 @@ void testChangeEmail() {

assertEquals(email, user.getEmail());


// restore email

api.update(userId, new UserInfo.Builder().email(fixUserEmail).build());
Expand Down

0 comments on commit a92eb7d

Please sign in to comment.