Skip to content

Commit 9acccdb

Browse files
committed
Adding unit tests
1 parent ea1baee commit 9acccdb

10 files changed

Lines changed: 206 additions & 5 deletions

src/test/java/com/stackify/api/AppIdentityTest.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,18 @@ public void testBuilder() {
5151
Assert.assertEquals(deviceAlias, appIdentity.getDeviceAlias());
5252

5353
Assert.assertNotNull(appIdentity.toString());
54+
55+
AppIdentity appIdentityCopy = appIdentity.toBuilder().build();
56+
57+
Assert.assertNotNull(appIdentityCopy);
58+
59+
Assert.assertEquals(deviceId, appIdentityCopy.getDeviceId());
60+
Assert.assertEquals(deviceAppId, appIdentityCopy.getDeviceAppId());
61+
Assert.assertEquals(appNameId, appIdentityCopy.getAppNameId());
62+
Assert.assertEquals(envId, appIdentityCopy.getEnvId());
63+
Assert.assertEquals(env, appIdentityCopy.getEnv());
64+
Assert.assertEquals(appName, appIdentityCopy.getAppName());
65+
Assert.assertEquals(appEnvId, appIdentityCopy.getAppEnvId());
66+
Assert.assertEquals(deviceAlias, appIdentityCopy.getDeviceAlias());
5467
}
5568
}

src/test/java/com/stackify/api/EnvironmentDetailTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,15 @@ public void testBuilder() {
5151
Assert.assertEquals(appLocation, environment.getAppLocation());
5252
Assert.assertEquals(configuredAppName, environment.getConfiguredAppName());
5353
Assert.assertEquals(configuredEnvironmentName, environment.getConfiguredEnvironmentName());
54+
55+
EnvironmentDetail environmentCopy = environment.toBuilder().build();
56+
57+
Assert.assertNotNull(environmentCopy);
58+
59+
Assert.assertEquals(deviceName, environmentCopy.getDeviceName());
60+
Assert.assertEquals(appName, environmentCopy.getAppName());
61+
Assert.assertEquals(appLocation, environmentCopy.getAppLocation());
62+
Assert.assertEquals(configuredAppName, environmentCopy.getConfiguredAppName());
63+
Assert.assertEquals(configuredEnvironmentName, environmentCopy.getConfiguredEnvironmentName());
5464
}
5565
}

src/test/java/com/stackify/api/ErrorItemTest.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@
2323
import org.junit.Assert;
2424
import org.junit.Test;
2525

26-
import com.stackify.api.ErrorItem;
27-
import com.stackify.api.TraceFrame;
28-
2926
/**
3027
* ErrorItem JUnit Test
3128
*
@@ -68,5 +65,17 @@ public void testBuilder() {
6865
Assert.assertEquals(cause, errorDetail.getInnerError());
6966
Assert.assertEquals(errorTypeCode, errorDetail.getErrorTypeCode());
7067
Assert.assertEquals(data, errorDetail.getData());
68+
69+
ErrorItem errorDetailCopy = errorDetail.toBuilder().build();
70+
71+
Assert.assertNotNull(errorDetailCopy);
72+
73+
Assert.assertEquals(message, errorDetailCopy.getMessage());
74+
Assert.assertEquals(className, errorDetailCopy.getErrorType());
75+
Assert.assertEquals(methodName, errorDetailCopy.getSourceMethod());
76+
Assert.assertEquals(stackTrace, errorDetailCopy.getStackTrace());
77+
Assert.assertEquals(cause, errorDetailCopy.getInnerError());
78+
Assert.assertEquals(errorTypeCode, errorDetailCopy.getErrorTypeCode());
79+
Assert.assertEquals(data, errorDetailCopy.getData());
7180
}
7281
}

src/test/java/com/stackify/api/LogMsgGroupTest.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,5 +75,22 @@ public void testBuilder() {
7575
Assert.assertEquals(logger, logMsgGroup.getLogger());
7676
Assert.assertEquals(platform, logMsgGroup.getPlatform());
7777
Assert.assertEquals(msgs, logMsgGroup.getMsgs());
78+
79+
LogMsgGroup logMsgGroupCopy = logMsgGroup.toBuilder().build();
80+
81+
Assert.assertNotNull(logMsgGroupCopy);
82+
83+
Assert.assertEquals(cdId, logMsgGroupCopy.getCdId());
84+
Assert.assertEquals(cdAppId, logMsgGroupCopy.getCdAppId());
85+
Assert.assertEquals(appNameId, logMsgGroupCopy.getAppNameId());
86+
Assert.assertEquals(appEnvId, logMsgGroupCopy.getAppEnvId());
87+
Assert.assertEquals(envId, logMsgGroupCopy.getEnvId());
88+
Assert.assertEquals(env, logMsgGroupCopy.getEnv());
89+
Assert.assertEquals(serverName, logMsgGroupCopy.getServerName());
90+
Assert.assertEquals(appName, logMsgGroupCopy.getAppName());
91+
Assert.assertEquals(appLoc, logMsgGroupCopy.getAppLoc());
92+
Assert.assertEquals(logger, logMsgGroupCopy.getLogger());
93+
Assert.assertEquals(platform, logMsgGroupCopy.getPlatform());
94+
Assert.assertEquals(msgs, logMsgGroupCopy.getMsgs());
7895
}
7996
}

src/test/java/com/stackify/api/LogMsgTest.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,19 @@ public void testBuilder() {
6464
Assert.assertEquals(transId, logMsg.getTransId());
6565
Assert.assertEquals(srcMethod, logMsg.getSrcMethod());
6666
Assert.assertEquals(srcLine, logMsg.getSrcLine());
67+
68+
LogMsg logMsgCopy = logMsg.toBuilder().build();
69+
70+
Assert.assertNotNull(logMsgCopy);
71+
72+
Assert.assertEquals(msg, logMsgCopy.getMsg());
73+
Assert.assertEquals(data, logMsgCopy.getData());
74+
Assert.assertEquals(ex, logMsgCopy.getEx());
75+
Assert.assertEquals(th, logMsgCopy.getTh());
76+
Assert.assertEquals(epochMs, logMsgCopy.getEpochMs());
77+
Assert.assertEquals(level, logMsgCopy.getLevel());
78+
Assert.assertEquals(transId, logMsgCopy.getTransId());
79+
Assert.assertEquals(srcMethod, logMsgCopy.getSrcMethod());
80+
Assert.assertEquals(srcLine, logMsgCopy.getSrcLine());
6781
}
6882
}

src/test/java/com/stackify/api/StackifyErrorTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,17 @@ public void testBuilder() {
6161
Assert.assertEquals(serverVariables, stackifyError.getServerVariables());
6262
Assert.assertEquals(customerName, stackifyError.getCustomerName());
6363
Assert.assertEquals(userName, stackifyError.getUserName());
64+
65+
StackifyError stackifyErrorCopy = stackifyError.toBuilder().build();
66+
67+
Assert.assertNotNull(stackifyErrorCopy);
68+
69+
Assert.assertEquals(environment, stackifyErrorCopy.getEnvironmentDetail());
70+
Assert.assertEquals(timeStamp, stackifyErrorCopy.getOccurredEpochMillis());
71+
Assert.assertEquals(errorDetail, stackifyErrorCopy.getError());
72+
Assert.assertEquals(webRequestDetail, stackifyErrorCopy.getWebRequestDetail());
73+
Assert.assertEquals(serverVariables, stackifyErrorCopy.getServerVariables());
74+
Assert.assertEquals(customerName, stackifyErrorCopy.getCustomerName());
75+
Assert.assertEquals(userName, stackifyErrorCopy.getUserName());
6476
}
6577
}

src/test/java/com/stackify/api/TraceFrameTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,13 @@ public void testBuilder() {
4545
Assert.assertEquals(fileName, stackFrame.getCodeFileName());
4646
Assert.assertEquals(lineNumber, stackFrame.getLineNum());
4747
Assert.assertEquals(methodName, stackFrame.getMethod());
48+
49+
TraceFrame stackFrameCopy = stackFrame.toBuilder().build();
50+
51+
Assert.assertNotNull(stackFrameCopy);
52+
53+
Assert.assertEquals(fileName, stackFrameCopy.getCodeFileName());
54+
Assert.assertEquals(lineNumber, stackFrameCopy.getLineNum());
55+
Assert.assertEquals(methodName, stackFrameCopy.getMethod());
4856
}
4957
}

src/test/java/com/stackify/api/WebRequestDetailTest.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
import org.junit.Assert;
2222
import org.junit.Test;
2323

24-
import com.stackify.api.WebRequestDetail;
25-
2624
/**
2725
* WebRequestDetail JUnit Test
2826
*
@@ -86,5 +84,25 @@ public void testBuilder() {
8684
Assert.assertEquals(mvcAction, webRequest.getMvcAction());
8785
Assert.assertEquals(mvcController, webRequest.getMvcController());
8886
Assert.assertEquals(mvcArea, webRequest.getMvcArea());
87+
88+
WebRequestDetail webRequestCopy = webRequest.toBuilder().build();
89+
90+
Assert.assertNotNull(webRequestCopy);
91+
92+
Assert.assertEquals(userIpAddress, webRequestCopy.getUserIpAddress());
93+
Assert.assertEquals(httpMethod, webRequestCopy.getHttpMethod());
94+
Assert.assertEquals(requestProtocol, webRequestCopy.getRequestProtocol());
95+
Assert.assertEquals(requestUrl, webRequestCopy.getRequestUrl());
96+
Assert.assertEquals(requestUrlRoot, webRequestCopy.getRequestUrlRoot());
97+
Assert.assertEquals(referralUrl, webRequestCopy.getReferralUrl());
98+
Assert.assertEquals(headers, webRequestCopy.getHeaders());
99+
Assert.assertEquals(cookies, webRequestCopy.getCookies());
100+
Assert.assertEquals(queryString, webRequestCopy.getQueryString());
101+
Assert.assertEquals(postData, webRequestCopy.getPostData());
102+
Assert.assertEquals(sessionData, webRequestCopy.getSessionData());
103+
Assert.assertEquals(postDataRaw, webRequestCopy.getPostDataRaw());
104+
Assert.assertEquals(mvcAction, webRequestCopy.getMvcAction());
105+
Assert.assertEquals(mvcController, webRequestCopy.getMvcController());
106+
Assert.assertEquals(mvcArea, webRequestCopy.getMvcArea());
89107
}
90108
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright 2015 Stackify
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.stackify.api.common.util;
17+
18+
import java.io.IOException;
19+
import java.io.StringReader;
20+
21+
import org.junit.Assert;
22+
import org.junit.Test;
23+
24+
/**
25+
* CharStreams JUnit Test
26+
* @author Eric Martin
27+
*/
28+
public class CharStreamsTest {
29+
30+
/**
31+
* testToString
32+
* @throws IOException
33+
*/
34+
@Test
35+
public void testToString() throws IOException {
36+
String helloWorld = "Hello World!";
37+
StringReader reader = new StringReader(helloWorld);
38+
39+
String string = CharStreams.toString(reader);
40+
41+
Assert.assertEquals(helloWorld, string);
42+
}
43+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
* Copyright 2014 Stackify
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.stackify.api.common.util;
17+
18+
import org.junit.Test;
19+
20+
/**
21+
* Preconditions JUnit Test
22+
* @author Eric Martin
23+
*/
24+
public class PreconditionsTest {
25+
26+
/**
27+
* testCheckNotNull
28+
*/
29+
@Test
30+
public void testCheckNotNull() {
31+
Preconditions.checkNotNull("x");
32+
}
33+
34+
/**
35+
* testCheckNotNullWithNull
36+
*/
37+
@Test(expected = NullPointerException.class)
38+
public void testCheckNotNullWithNull() {
39+
Preconditions.checkNotNull(null);
40+
}
41+
42+
/**
43+
* testCheckArgument
44+
*/
45+
@Test
46+
public void testCheckArgument() {
47+
Preconditions.checkArgument(true);
48+
}
49+
50+
/**
51+
* testCheckArgumentFalse
52+
*/
53+
@Test(expected = IllegalArgumentException.class)
54+
public void testCheckArgumentFalse() {
55+
Preconditions.checkArgument(false);
56+
}
57+
}

0 commit comments

Comments
 (0)