Skip to content

Commit

Permalink
Adding unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-martin committed Apr 2, 2015
1 parent ea1baee commit 9acccdb
Show file tree
Hide file tree
Showing 10 changed files with 206 additions and 5 deletions.
13 changes: 13 additions & 0 deletions src/test/java/com/stackify/api/AppIdentityTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,18 @@ public void testBuilder() {
Assert.assertEquals(deviceAlias, appIdentity.getDeviceAlias());

Assert.assertNotNull(appIdentity.toString());

AppIdentity appIdentityCopy = appIdentity.toBuilder().build();

Assert.assertNotNull(appIdentityCopy);

Assert.assertEquals(deviceId, appIdentityCopy.getDeviceId());
Assert.assertEquals(deviceAppId, appIdentityCopy.getDeviceAppId());
Assert.assertEquals(appNameId, appIdentityCopy.getAppNameId());
Assert.assertEquals(envId, appIdentityCopy.getEnvId());
Assert.assertEquals(env, appIdentityCopy.getEnv());
Assert.assertEquals(appName, appIdentityCopy.getAppName());
Assert.assertEquals(appEnvId, appIdentityCopy.getAppEnvId());
Assert.assertEquals(deviceAlias, appIdentityCopy.getDeviceAlias());
}
}
10 changes: 10 additions & 0 deletions src/test/java/com/stackify/api/EnvironmentDetailTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,15 @@ public void testBuilder() {
Assert.assertEquals(appLocation, environment.getAppLocation());
Assert.assertEquals(configuredAppName, environment.getConfiguredAppName());
Assert.assertEquals(configuredEnvironmentName, environment.getConfiguredEnvironmentName());

EnvironmentDetail environmentCopy = environment.toBuilder().build();

Assert.assertNotNull(environmentCopy);

Assert.assertEquals(deviceName, environmentCopy.getDeviceName());
Assert.assertEquals(appName, environmentCopy.getAppName());
Assert.assertEquals(appLocation, environmentCopy.getAppLocation());
Assert.assertEquals(configuredAppName, environmentCopy.getConfiguredAppName());
Assert.assertEquals(configuredEnvironmentName, environmentCopy.getConfiguredEnvironmentName());
}
}
15 changes: 12 additions & 3 deletions src/test/java/com/stackify/api/ErrorItemTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@
import org.junit.Assert;
import org.junit.Test;

import com.stackify.api.ErrorItem;
import com.stackify.api.TraceFrame;

/**
* ErrorItem JUnit Test
*
Expand Down Expand Up @@ -68,5 +65,17 @@ public void testBuilder() {
Assert.assertEquals(cause, errorDetail.getInnerError());
Assert.assertEquals(errorTypeCode, errorDetail.getErrorTypeCode());
Assert.assertEquals(data, errorDetail.getData());

ErrorItem errorDetailCopy = errorDetail.toBuilder().build();

Assert.assertNotNull(errorDetailCopy);

Assert.assertEquals(message, errorDetailCopy.getMessage());
Assert.assertEquals(className, errorDetailCopy.getErrorType());
Assert.assertEquals(methodName, errorDetailCopy.getSourceMethod());
Assert.assertEquals(stackTrace, errorDetailCopy.getStackTrace());
Assert.assertEquals(cause, errorDetailCopy.getInnerError());
Assert.assertEquals(errorTypeCode, errorDetailCopy.getErrorTypeCode());
Assert.assertEquals(data, errorDetailCopy.getData());
}
}
17 changes: 17 additions & 0 deletions src/test/java/com/stackify/api/LogMsgGroupTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,22 @@ public void testBuilder() {
Assert.assertEquals(logger, logMsgGroup.getLogger());
Assert.assertEquals(platform, logMsgGroup.getPlatform());
Assert.assertEquals(msgs, logMsgGroup.getMsgs());

LogMsgGroup logMsgGroupCopy = logMsgGroup.toBuilder().build();

Assert.assertNotNull(logMsgGroupCopy);

Assert.assertEquals(cdId, logMsgGroupCopy.getCdId());
Assert.assertEquals(cdAppId, logMsgGroupCopy.getCdAppId());
Assert.assertEquals(appNameId, logMsgGroupCopy.getAppNameId());
Assert.assertEquals(appEnvId, logMsgGroupCopy.getAppEnvId());
Assert.assertEquals(envId, logMsgGroupCopy.getEnvId());
Assert.assertEquals(env, logMsgGroupCopy.getEnv());
Assert.assertEquals(serverName, logMsgGroupCopy.getServerName());
Assert.assertEquals(appName, logMsgGroupCopy.getAppName());
Assert.assertEquals(appLoc, logMsgGroupCopy.getAppLoc());
Assert.assertEquals(logger, logMsgGroupCopy.getLogger());
Assert.assertEquals(platform, logMsgGroupCopy.getPlatform());
Assert.assertEquals(msgs, logMsgGroupCopy.getMsgs());
}
}
14 changes: 14 additions & 0 deletions src/test/java/com/stackify/api/LogMsgTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,19 @@ public void testBuilder() {
Assert.assertEquals(transId, logMsg.getTransId());
Assert.assertEquals(srcMethod, logMsg.getSrcMethod());
Assert.assertEquals(srcLine, logMsg.getSrcLine());

LogMsg logMsgCopy = logMsg.toBuilder().build();

Assert.assertNotNull(logMsgCopy);

Assert.assertEquals(msg, logMsgCopy.getMsg());
Assert.assertEquals(data, logMsgCopy.getData());
Assert.assertEquals(ex, logMsgCopy.getEx());
Assert.assertEquals(th, logMsgCopy.getTh());
Assert.assertEquals(epochMs, logMsgCopy.getEpochMs());
Assert.assertEquals(level, logMsgCopy.getLevel());
Assert.assertEquals(transId, logMsgCopy.getTransId());
Assert.assertEquals(srcMethod, logMsgCopy.getSrcMethod());
Assert.assertEquals(srcLine, logMsgCopy.getSrcLine());
}
}
12 changes: 12 additions & 0 deletions src/test/java/com/stackify/api/StackifyErrorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,17 @@ public void testBuilder() {
Assert.assertEquals(serverVariables, stackifyError.getServerVariables());
Assert.assertEquals(customerName, stackifyError.getCustomerName());
Assert.assertEquals(userName, stackifyError.getUserName());

StackifyError stackifyErrorCopy = stackifyError.toBuilder().build();

Assert.assertNotNull(stackifyErrorCopy);

Assert.assertEquals(environment, stackifyErrorCopy.getEnvironmentDetail());
Assert.assertEquals(timeStamp, stackifyErrorCopy.getOccurredEpochMillis());
Assert.assertEquals(errorDetail, stackifyErrorCopy.getError());
Assert.assertEquals(webRequestDetail, stackifyErrorCopy.getWebRequestDetail());
Assert.assertEquals(serverVariables, stackifyErrorCopy.getServerVariables());
Assert.assertEquals(customerName, stackifyErrorCopy.getCustomerName());
Assert.assertEquals(userName, stackifyErrorCopy.getUserName());
}
}
8 changes: 8 additions & 0 deletions src/test/java/com/stackify/api/TraceFrameTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,13 @@ public void testBuilder() {
Assert.assertEquals(fileName, stackFrame.getCodeFileName());
Assert.assertEquals(lineNumber, stackFrame.getLineNum());
Assert.assertEquals(methodName, stackFrame.getMethod());

TraceFrame stackFrameCopy = stackFrame.toBuilder().build();

Assert.assertNotNull(stackFrameCopy);

Assert.assertEquals(fileName, stackFrameCopy.getCodeFileName());
Assert.assertEquals(lineNumber, stackFrameCopy.getLineNum());
Assert.assertEquals(methodName, stackFrameCopy.getMethod());
}
}
22 changes: 20 additions & 2 deletions src/test/java/com/stackify/api/WebRequestDetailTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
import org.junit.Assert;
import org.junit.Test;

import com.stackify.api.WebRequestDetail;

/**
* WebRequestDetail JUnit Test
*
Expand Down Expand Up @@ -86,5 +84,25 @@ public void testBuilder() {
Assert.assertEquals(mvcAction, webRequest.getMvcAction());
Assert.assertEquals(mvcController, webRequest.getMvcController());
Assert.assertEquals(mvcArea, webRequest.getMvcArea());

WebRequestDetail webRequestCopy = webRequest.toBuilder().build();

Assert.assertNotNull(webRequestCopy);

Assert.assertEquals(userIpAddress, webRequestCopy.getUserIpAddress());
Assert.assertEquals(httpMethod, webRequestCopy.getHttpMethod());
Assert.assertEquals(requestProtocol, webRequestCopy.getRequestProtocol());
Assert.assertEquals(requestUrl, webRequestCopy.getRequestUrl());
Assert.assertEquals(requestUrlRoot, webRequestCopy.getRequestUrlRoot());
Assert.assertEquals(referralUrl, webRequestCopy.getReferralUrl());
Assert.assertEquals(headers, webRequestCopy.getHeaders());
Assert.assertEquals(cookies, webRequestCopy.getCookies());
Assert.assertEquals(queryString, webRequestCopy.getQueryString());
Assert.assertEquals(postData, webRequestCopy.getPostData());
Assert.assertEquals(sessionData, webRequestCopy.getSessionData());
Assert.assertEquals(postDataRaw, webRequestCopy.getPostDataRaw());
Assert.assertEquals(mvcAction, webRequestCopy.getMvcAction());
Assert.assertEquals(mvcController, webRequestCopy.getMvcController());
Assert.assertEquals(mvcArea, webRequestCopy.getMvcArea());
}
}
43 changes: 43 additions & 0 deletions src/test/java/com/stackify/api/common/util/CharStreamsTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright 2015 Stackify
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.stackify.api.common.util;

import java.io.IOException;
import java.io.StringReader;

import org.junit.Assert;
import org.junit.Test;

/**
* CharStreams JUnit Test
* @author Eric Martin
*/
public class CharStreamsTest {

/**
* testToString
* @throws IOException
*/
@Test
public void testToString() throws IOException {
String helloWorld = "Hello World!";
StringReader reader = new StringReader(helloWorld);

String string = CharStreams.toString(reader);

Assert.assertEquals(helloWorld, string);
}
}
57 changes: 57 additions & 0 deletions src/test/java/com/stackify/api/common/util/PreconditionsTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright 2014 Stackify
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.stackify.api.common.util;

import org.junit.Test;

/**
* Preconditions JUnit Test
* @author Eric Martin
*/
public class PreconditionsTest {

/**
* testCheckNotNull
*/
@Test
public void testCheckNotNull() {
Preconditions.checkNotNull("x");
}

/**
* testCheckNotNullWithNull
*/
@Test(expected = NullPointerException.class)
public void testCheckNotNullWithNull() {
Preconditions.checkNotNull(null);
}

/**
* testCheckArgument
*/
@Test
public void testCheckArgument() {
Preconditions.checkArgument(true);
}

/**
* testCheckArgumentFalse
*/
@Test(expected = IllegalArgumentException.class)
public void testCheckArgumentFalse() {
Preconditions.checkArgument(false);
}
}

0 comments on commit 9acccdb

Please sign in to comment.