Skip to content

Commit

Permalink
organized tests by type
Browse files Browse the repository at this point in the history
  • Loading branch information
ibalosh committed Nov 20, 2017
1 parent b5cd267 commit 4a4db41
Show file tree
Hide file tree
Showing 14 changed files with 63 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
*/
public class BaseApiClient extends HttpClientHandler {

private final String baseUrl;
protected String getEndpointUrl(String endpoint) {
public final String baseUrl;
public String getEndpointUrl(String endpoint) {
return baseUrl + endpoint;
}

Expand All @@ -24,4 +24,7 @@ public BaseApiClient(String baseUrl, MultivaluedHashMap<String,Object> headers,
setSecureConnection(secureConnection);
}

public String getBaseUrl() {
return baseUrl;
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package base;

import com.wildbit.java.postmark.Postmark;
import com.wildbit.java.postmark.client.AccountApiClient;
import com.wildbit.java.postmark.client.ApiClient;
Expand Down
18 changes: 0 additions & 18 deletions src/test/java/client/HttpClientTest.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
package integration;

import base.BaseTest;
import com.wildbit.java.postmark.client.ApiClient;
import com.wildbit.java.postmark.client.Parameters;
import com.wildbit.java.postmark.client.data.model.bounces.Bounce;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
package integration;

import base.BaseTest;
import com.wildbit.java.postmark.Postmark;
import com.wildbit.java.postmark.client.ApiClient;
import com.wildbit.java.postmark.client.data.model.message.Message;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package integration;

import base.BaseTest;
import com.wildbit.java.postmark.client.ApiClient;
import com.wildbit.java.postmark.client.Parameters;
import com.wildbit.java.postmark.client.data.model.messages.*;
import com.wildbit.java.postmark.client.exception.InvalidMessageException;
import com.wildbit.java.postmark.client.exception.PostmarkException;
import org.junit.jupiter.api.Test;

import java.io.IOException;

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

/**
* Created by bash on 11/14/17.
Expand Down Expand Up @@ -57,4 +60,9 @@ void inboundMessageById() throws PostmarkException, IOException {
InboundMessageDetails inboundMessageDetails = client.getInboundMessageDetails(messageId);
assertNotNull(inboundMessageDetails.getFrom());
}

@Test
void exception() throws PostmarkException, IOException {
assertThrows(InvalidMessageException.class, () -> client.getMessages(Parameters.init().build("count", -4).build("offset", 0)));
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
package integration;

import base.BaseTest;
import com.wildbit.java.postmark.client.ApiClient;
import com.wildbit.java.postmark.client.data.model.server.Server;
import com.wildbit.java.postmark.client.exception.PostmarkException;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package integration;

import base.BaseTest;
import com.wildbit.java.postmark.client.AccountApiClient;
import com.wildbit.java.postmark.client.Parameters;
import com.wildbit.java.postmark.client.data.model.server.Server;
import com.wildbit.java.postmark.client.data.model.servers.Servers;
import com.wildbit.java.postmark.client.exception.PostmarkException;
import org.junit.jupiter.api.Test;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
package unit;

import base.BaseTest;
import com.wildbit.java.postmark.Postmark;
import org.junit.jupiter.api.Test;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package client;
package unit.client;

import com.wildbit.java.postmark.Postmark;
import com.wildbit.java.postmark.client.ApiClient;
Expand Down
27 changes: 27 additions & 0 deletions src/test/java/unit/client/HttpClientTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package unit.client;

import com.wildbit.java.postmark.Postmark;
import com.wildbit.java.postmark.client.HttpClient;
import com.wildbit.java.postmark.client.exception.PostmarkException;
import org.junit.jupiter.api.Test;

import javax.ws.rs.core.MultivaluedHashMap;
import java.io.IOException;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;


public class HttpClientTest {

@Test
void execute() throws IOException, PostmarkException {
HttpClient client = new HttpClient(new MultivaluedHashMap<>());
HttpClient.ClientResponse response = client.execute(HttpClient.REQUEST_TYPES.GET, "https://" + Postmark.DEFAULTS.API_URL.value);

assertEquals(response.getCode(),302);
assertNotNull(response.getMessage());

}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package client;
package unit.client;

import com.wildbit.java.postmark.client.Parameters;
import org.junit.jupiter.api.Test;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package client.data;
package unit.client.data;

import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package data;
package unit.data;


import com.wildbit.java.postmark.client.data.DataHandler;
Expand Down

0 comments on commit 4a4db41

Please sign in to comment.