diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..3e0fb27 --- /dev/null +++ b/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7d17d40 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +/bin/ + +buildOrig.xml diff --git a/.project b/.project new file mode 100644 index 0000000..8d1a8e8 --- /dev/null +++ b/.project @@ -0,0 +1,17 @@ + + + TravisExercise + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..c24d69e --- /dev/null +++ b/.travis.yml @@ -0,0 +1,4 @@ +language: java +jdk: oraclejdk7 + +script: ant test diff --git a/build.xml b/build.xml index e288a4b..4284233 100644 --- a/build.xml +++ b/build.xml @@ -1,17 +1,91 @@ - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/build/discount/Demo.class b/build/discount/Demo.class new file mode 100644 index 0000000..f54be29 Binary files /dev/null and b/build/discount/Demo.class differ diff --git a/build/discount/DiscountStrategy.class b/build/discount/DiscountStrategy.class new file mode 100644 index 0000000..cf456c9 Binary files /dev/null and b/build/discount/DiscountStrategy.class differ diff --git a/build/discount/Order.class b/build/discount/Order.class new file mode 100644 index 0000000..dea636e Binary files /dev/null and b/build/discount/Order.class differ diff --git a/build/discount/PercentDiscountStrategy.class b/build/discount/PercentDiscountStrategy.class new file mode 100644 index 0000000..2ea6523 Binary files /dev/null and b/build/discount/PercentDiscountStrategy.class differ diff --git a/build/discount/RandomDiscountStrategy.class b/build/discount/RandomDiscountStrategy.class new file mode 100644 index 0000000..6329cb7 Binary files /dev/null and b/build/discount/RandomDiscountStrategy.class differ diff --git a/build/discount/StoreCreditDiscountStrategy.class b/build/discount/StoreCreditDiscountStrategy.class new file mode 100644 index 0000000..6ba7b9b Binary files /dev/null and b/build/discount/StoreCreditDiscountStrategy.class differ diff --git a/build/test/OrderTestPercentDiscount.class b/build/test/OrderTestPercentDiscount.class new file mode 100644 index 0000000..660fdbf Binary files /dev/null and b/build/test/OrderTestPercentDiscount.class differ diff --git a/build/test/OrderTestRandomDiscount.class b/build/test/OrderTestRandomDiscount.class new file mode 100644 index 0000000..6b0381c Binary files /dev/null and b/build/test/OrderTestRandomDiscount.class differ diff --git a/build/test/OrderTestStoreCreditDiscount.class b/build/test/OrderTestStoreCreditDiscount.class new file mode 100644 index 0000000..56a4e3d Binary files /dev/null and b/build/test/OrderTestStoreCreditDiscount.class differ diff --git a/buildOrig.xml b/buildOrig.xml new file mode 100644 index 0000000..6ad651b --- /dev/null +++ b/buildOrig.xml @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/junit/TEST-test.OrderTestPercentDiscount.xml b/junit/TEST-test.OrderTestPercentDiscount.xml new file mode 100644 index 0000000..c038a0c --- /dev/null +++ b/junit/TEST-test.OrderTestPercentDiscount.xml @@ -0,0 +1,144 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + junit.framework.AssertionFailedError: expected:<444.0> but was:<4884.0> + at test.OrderTestPercentDiscount.percentageDiscountTest6(Unknown Source) + + + + junit.framework.AssertionFailedError: expected:<0.0> but was:<-3996.0> + at test.OrderTestPercentDiscount.percentageDiscountTest7(Unknown Source) + + + + + + + diff --git a/junit/TEST-test.OrderTestRandomDiscount.xml b/junit/TEST-test.OrderTestRandomDiscount.xml new file mode 100644 index 0000000..902aa26 --- /dev/null +++ b/junit/TEST-test.OrderTestRandomDiscount.xml @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/junit/TEST-test.OrderTestStoreCreditDiscount.xml b/junit/TEST-test.OrderTestStoreCreditDiscount.xml new file mode 100644 index 0000000..666becf --- /dev/null +++ b/junit/TEST-test.OrderTestStoreCreditDiscount.xml @@ -0,0 +1,144 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + junit.framework.AssertionFailedError: expected:<444.0> but was:<1444.0> + at test.OrderTestStoreCreditDiscount.creditDiscountTest6(Unknown Source) + + + + junit.framework.AssertionFailedError: expected:<0.0> but was:<-556.0> + at test.OrderTestStoreCreditDiscount.creditDiscountTest7(Unknown Source) + + + + + + + diff --git a/junit/TESTS-TestSuites.xml b/junit/TESTS-TestSuites.xml new file mode 100644 index 0000000..d2d9f27 --- /dev/null +++ b/junit/TESTS-TestSuites.xml @@ -0,0 +1,804 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + junit.framework.AssertionFailedError: expected:<444.0> but was:<4884.0> + at test.OrderTestPercentDiscount.percentageDiscountTest6(Unknown Source) + + + + + + junit.framework.AssertionFailedError: expected:<0.0> but was:<-3996.0> + at test.OrderTestPercentDiscount.percentageDiscountTest7(Unknown Source) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + junit.framework.AssertionFailedError: expected:<444.0> but was:<1444.0> + at test.OrderTestStoreCreditDiscount.creditDiscountTest6(Unknown Source) + + + + + + junit.framework.AssertionFailedError: expected:<0.0> but was:<-556.0> + at test.OrderTestStoreCreditDiscount.creditDiscountTest7(Unknown Source) + + + + + + + + + + + + + + diff --git a/junit/all-tests.html b/junit/all-tests.html new file mode 100644 index 0000000..735a224 --- /dev/null +++ b/junit/all-tests.html @@ -0,0 +1,103 @@ + + + +Unit Test Results: All Tests + + + +

Unit Test Results.

+ + + + +
Designed for use with JUnit and Ant.
+
+

All Tests

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ClassNameStatusTypeTime(s)
OrderTestPercentDiscountpercentageDiscountTest10Success0.001
OrderTestPercentDiscountpercentageDiscountTest11Success0.000
OrderTestPercentDiscountpercentageDiscountTest1Success0.000
OrderTestPercentDiscountpercentageDiscountTest2Success0.000
OrderTestPercentDiscountpercentageDiscountTest3Success0.001
OrderTestPercentDiscountpercentageDiscountTest4Success0.000
OrderTestPercentDiscountpercentageDiscountTest5Success0.000
OrderTestPercentDiscountpercentageDiscountTest6Failureexpected:<444.0> but was:<4884.0>
+
+junit.framework.AssertionFailedError: expected:<444.0> but was:<4884.0>
at test.OrderTestPercentDiscount.percentageDiscountTest6(Unknown Source)
+
0.003
OrderTestPercentDiscountpercentageDiscountTest7Failureexpected:<0.0> but was:<-3996.0>
+
+junit.framework.AssertionFailedError: expected:<0.0> but was:<-3996.0>
at test.OrderTestPercentDiscount.percentageDiscountTest7(Unknown Source)
+
0.000
OrderTestPercentDiscountpercentageDiscountTest8Success0.000
OrderTestPercentDiscountpercentageDiscountTest9Success0.000
OrderTestRandomDiscountrandomDiscountTest1Success0.003
OrderTestStoreCreditDiscountcreditDiscountTest10Success0.001
OrderTestStoreCreditDiscountcreditDiscountTest11Success0.000
OrderTestStoreCreditDiscountcreditDiscountTest1Success0.000
OrderTestStoreCreditDiscountcreditDiscountTest2Success0.000
OrderTestStoreCreditDiscountcreditDiscountTest3Success0.000
OrderTestStoreCreditDiscountcreditDiscountTest4Success0.000
OrderTestStoreCreditDiscountcreditDiscountTest5Success0.000
OrderTestStoreCreditDiscountcreditDiscountTest6Failureexpected:<444.0> but was:<1444.0>
+
+junit.framework.AssertionFailedError: expected:<444.0> but was:<1444.0>
at test.OrderTestStoreCreditDiscount.creditDiscountTest6(Unknown Source)
+
0.004
OrderTestStoreCreditDiscountcreditDiscountTest7Failureexpected:<0.0> but was:<-556.0>
+
+junit.framework.AssertionFailedError: expected:<0.0> but was:<-556.0>
aat test.OrderTestStoreCreditDiscount.creditDiscountTest7(Unknown Source)
+
0.001
OrderTestStoreCreditDiscountcreditDiscountTest8Success0.000
OrderTestStoreCreditDiscountcreditDiscountTest9Success0.000
+ + diff --git a/junit/allclasses-frame.html b/junit/allclasses-frame.html new file mode 100644 index 0000000..1a855b0 --- /dev/null +++ b/junit/allclasses-frame.html @@ -0,0 +1,21 @@ + + + +All Unit Test Classes + + + +

Classes

+ + + + + + + + + + +
OrderTestPercentDiscount
OrderTestRandomDiscount
OrderTestStoreCreditDiscount
+ + diff --git a/junit/alltests-errors.html b/junit/alltests-errors.html new file mode 100644 index 0000000..deb8291 --- /dev/null +++ b/junit/alltests-errors.html @@ -0,0 +1,22 @@ + + + +Unit Test Results: All Errors + + + +

Unit Test Results.

+ + + + +
Designed for use with JUnit and Ant.
+
+

All Errors

+ + + + +
ClassNameStatusTypeTime(s)
+ + diff --git a/junit/alltests-fails.html b/junit/alltests-fails.html new file mode 100644 index 0000000..1a2e324 --- /dev/null +++ b/junit/alltests-fails.html @@ -0,0 +1,46 @@ + + + +Unit Test Results: All Failures + + + +

Unit Test Results.

+ + + + +
Designed for use with JUnit and Ant.
+
+

All Failures

+ + + + + + + + + + + + + + + + +
ClassNameStatusTypeTime(s)
OrderTestPercentDiscountpercentageDiscountTest6Failureexpected:<444.0> but was:<4884.0>
+
+junit.framework.AssertionFailedError: expected:<444.0> but was:<4884.0>
at test.OrderTestPercentDiscount.percentageDiscountTest6(Unknown Source)
+
0.003
OrderTestPercentDiscountpercentageDiscountTest7Failureexpected:<0.0> but was:<-3996.0>
+
+junit.framework.AssertionFailedError: expected:<0.0> but was:<-3996.0>
at test.OrderTestPercentDiscount.percentageDiscountTest7(Unknown Source)
+
0.000
OrderTestStoreCreditDiscountcreditDiscountTest6Failureexpected:<444.0> but was:<1444.0>
+
+junit.framework.AssertionFailedError: expected:<444.0> but was:<1444.0>
at test.OrderTestStoreCreditDiscount.creditDiscountTest6(Unknown Source)
+
0.004
OrderTestStoreCreditDiscountcreditDiscountTest7Failureexpected:<0.0> but was:<-556.0>
+
+junit.framework.AssertionFailedError: expected:<0.0> but was:<-556.0>
aat test.OrderTestStoreCreditDiscount.creditDiscountTest7(Unknown Source)
+
0.001
+ + diff --git a/junit/alltests-skipped.html b/junit/alltests-skipped.html new file mode 100644 index 0000000..a08afc5 --- /dev/null +++ b/junit/alltests-skipped.html @@ -0,0 +1,22 @@ + + + +Unit Test Results: All Skipped + + + +

Unit Test Results.

+ + + + +
Designed for use with JUnit and Ant.
+
+

All Skipped

+ + + + +
ClassNameStatusTypeTime(s)
+ + diff --git a/junit/index.html b/junit/index.html new file mode 100644 index 0000000..4163d4e --- /dev/null +++ b/junit/index.html @@ -0,0 +1,19 @@ + + + +Unit Test Results. + + + + + + + + +<h2>Frame Alert</h2> +<p> + This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. + </p> + + + diff --git a/junit/overview-frame.html b/junit/overview-frame.html new file mode 100644 index 0000000..b5c2450 --- /dev/null +++ b/junit/overview-frame.html @@ -0,0 +1,18 @@ + + + +All Unit Test Packages + + + +

+Home +

+

Packages

+ + + + +
test
+ + diff --git a/junit/overview-summary.html b/junit/overview-summary.html new file mode 100644 index 0000000..852e284 --- /dev/null +++ b/junit/overview-summary.html @@ -0,0 +1,41 @@ + + + +Unit Test Results: Summary + + + +

Unit Test Results.

+ + + + +
Designed for use with JUnit and Ant.
+
+

Summary

+ + + + + + + +
TestsFailuresErrorsSkippedSuccess rateTime
2340082.61%0.160
+ + + + +
+ Note: failures are anticipated and checked for with assertions while errors are unanticipated. +
+

Packages

+ + + + + + + +
NameTestsErrorsFailuresSkippedTime(s)Time StampHost
test230400.1602015-11-19T04:44:41Aperture
+ + diff --git a/junit/stylesheet.css b/junit/stylesheet.css new file mode 100644 index 0000000..c371da6 --- /dev/null +++ b/junit/stylesheet.css @@ -0,0 +1,48 @@ + +body { + font:normal 68% verdana,arial,helvetica; + color:#000000; +} +table tr td, table tr th { + font-size: 68%; +} +table.details tr th{ + font-weight: bold; + text-align:left; + background:#a6caf0; +} +table.details tr td{ + background:#eeeee0; +} + +p { + line-height:1.5em; + margin-top:0.5em; margin-bottom:1.0em; +} +h1 { + margin: 0px 0px 5px; font: 165% verdana,arial,helvetica +} +h2 { + margin-top: 1em; margin-bottom: 0.5em; font: bold 125% verdana,arial,helvetica +} +h3 { + margin-bottom: 0.5em; font: bold 115% verdana,arial,helvetica +} +h4 { + margin-bottom: 0.5em; font: bold 100% verdana,arial,helvetica +} +h5 { + margin-bottom: 0.5em; font: bold 100% verdana,arial,helvetica +} +h6 { + margin-bottom: 0.5em; font: bold 100% verdana,arial,helvetica +} +.Error { + font-weight:bold; color:red; +} +.Failure { + font-weight:bold; color:purple; +} +.Properties { + text-align:right; +} diff --git a/junit/test/0_OrderTestPercentDiscount-fails.html b/junit/test/0_OrderTestPercentDiscount-fails.html new file mode 100644 index 0000000..9b9edf5 --- /dev/null +++ b/junit/test/0_OrderTestPercentDiscount-fails.html @@ -0,0 +1,318 @@ + + + +Unit Test Results: test.OrderTestPercentDiscount + + + + +

Unit Test Results.

+ + + + +
Designed for use with JUnit and Ant.
+
+

Class test.OrderTestPercentDiscount

+ + + + + + + +
NameTestsErrorsFailuresSkippedTime(s)Time StampHost
OrderTestPercentDiscount110200.0562015-11-19T04:44:41Aperture
+

Failures

+ + + + + + + + + + +
NameStatusTypeTime(s)
percentageDiscountTest6Failureexpected:<444.0> but was:<4884.0>
+
+junit.framework.AssertionFailedError: expected:<444.0> but was:<4884.0>
at test.OrderTestPercentDiscount.percentageDiscountTest6(Unknown Source)
+
0.003
percentageDiscountTest7Failureexpected:<0.0> but was:<-3996.0>
+
+junit.framework.AssertionFailedError: expected:<0.0> but was:<-3996.0>
at test.OrderTestPercentDiscount.percentageDiscountTest7(Unknown Source)
+
0.000
+
+ + Properties » + +
+ + diff --git a/junit/test/0_OrderTestPercentDiscount.html b/junit/test/0_OrderTestPercentDiscount.html new file mode 100644 index 0000000..e307010 --- /dev/null +++ b/junit/test/0_OrderTestPercentDiscount.html @@ -0,0 +1,345 @@ + + + +Unit Test Results: test.OrderTestPercentDiscount + + + + +

Unit Test Results.

+ + + + +
Designed for use with JUnit and Ant.
+
+

Class test.OrderTestPercentDiscount

+ + + + + + + +
NameTestsErrorsFailuresSkippedTime(s)Time StampHost
OrderTestPercentDiscount110200.0562015-11-19T04:44:41Aperture
+

Tests

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameStatusTypeTime(s)
percentageDiscountTest10Success0.001
percentageDiscountTest11Success0.000
percentageDiscountTest1Success0.000
percentageDiscountTest2Success0.000
percentageDiscountTest3Success0.001
percentageDiscountTest4Success0.000
percentageDiscountTest5Success0.000
percentageDiscountTest6Failureexpected:<444.0> but was:<4884.0>
+
+junit.framework.AssertionFailedError: expected:<444.0> but was:<4884.0>
at test.OrderTestPercentDiscount.percentageDiscountTest6(Unknown Source)
+
0.003
percentageDiscountTest7Failureexpected:<0.0> but was:<-3996.0>
+
+junit.framework.AssertionFailedError: expected:<0.0> but was:<-3996.0>
at test.OrderTestPercentDiscount.percentageDiscountTest7(Unknown Source)
+
0.000
percentageDiscountTest8Success0.000
percentageDiscountTest9Success0.000
+
+ + Properties » + +
+ + diff --git a/junit/test/1_OrderTestRandomDiscount.html b/junit/test/1_OrderTestRandomDiscount.html new file mode 100644 index 0000000..ca436d8 --- /dev/null +++ b/junit/test/1_OrderTestRandomDiscount.html @@ -0,0 +1,309 @@ + + + +Unit Test Results: test.OrderTestRandomDiscount + + + + +

Unit Test Results.

+ + + + +
Designed for use with JUnit and Ant.
+
+

Class test.OrderTestRandomDiscount

+ + + + + + + +
NameTestsErrorsFailuresSkippedTime(s)Time StampHost
OrderTestRandomDiscount10000.0472015-11-19T04:44:41Aperture
+

Tests

+ + + + + + + +
NameStatusTypeTime(s)
randomDiscountTest1Success0.003
+
+ + Properties » + +
+ + diff --git a/junit/test/2_OrderTestStoreCreditDiscount-fails.html b/junit/test/2_OrderTestStoreCreditDiscount-fails.html new file mode 100644 index 0000000..f1d1732 --- /dev/null +++ b/junit/test/2_OrderTestStoreCreditDiscount-fails.html @@ -0,0 +1,318 @@ + + + +Unit Test Results: test.OrderTestStoreCreditDiscount + + + + +

Unit Test Results.

+ + + + +
Designed for use with JUnit and Ant.
+
+

Class test.OrderTestStoreCreditDiscount

+ + + + + + + +
NameTestsErrorsFailuresSkippedTime(s)Time StampHost
OrderTestStoreCreditDiscount110200.0572015-11-19T04:44:41Aperture
+

Failures

+ + + + + + + + + + +
NameStatusTypeTime(s)
creditDiscountTest6Failureexpected:<444.0> but was:<1444.0>
+
+junit.framework.AssertionFailedError: expected:<444.0> but was:<1444.0>
at test.OrderTestStoreCreditDiscount.creditDiscountTest6(Unknown Source)
+
0.004
creditDiscountTest7Failureexpected:<0.0> but was:<-556.0>
+
+junit.framework.AssertionFailedError: expected:<0.0> but was:<-556.0>
aat test.OrderTestStoreCreditDiscount.creditDiscountTest7(Unknown Source)
+
0.001
+
+ + Properties » + +
+ + diff --git a/junit/test/2_OrderTestStoreCreditDiscount.html b/junit/test/2_OrderTestStoreCreditDiscount.html new file mode 100644 index 0000000..7ff7122 --- /dev/null +++ b/junit/test/2_OrderTestStoreCreditDiscount.html @@ -0,0 +1,345 @@ + + + +Unit Test Results: test.OrderTestStoreCreditDiscount + + + + +

Unit Test Results.

+ + + + +
Designed for use with JUnit and Ant.
+
+

Class test.OrderTestStoreCreditDiscount

+ + + + + + + +
NameTestsErrorsFailuresSkippedTime(s)Time StampHost
OrderTestStoreCreditDiscount110200.0572015-11-19T04:44:41Aperture
+

Tests

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameStatusTypeTime(s)
creditDiscountTest10Success0.001
creditDiscountTest11Success0.000
creditDiscountTest1Success0.000
creditDiscountTest2Success0.000
creditDiscountTest3Success0.000
creditDiscountTest4Success0.000
creditDiscountTest5Success0.000
creditDiscountTest6Failureexpected:<444.0> but was:<1444.0>
+
+junit.framework.AssertionFailedError: expected:<444.0> but was:<1444.0>
at test.OrderTestStoreCreditDiscount.creditDiscountTest6(Unknown Source)
+
0.004
creditDiscountTest7Failureexpected:<0.0> but was:<-556.0>
+
+junit.framework.AssertionFailedError: expected:<0.0> but was:<-556.0>
aat test.OrderTestStoreCreditDiscount.creditDiscountTest7(Unknown Source)
+
0.001
creditDiscountTest8Success0.000
creditDiscountTest9Success0.000
+
+ + Properties » + +
+ + diff --git a/junit/test/package-frame.html b/junit/test/package-frame.html new file mode 100644 index 0000000..11bf7a1 --- /dev/null +++ b/junit/test/package-frame.html @@ -0,0 +1,30 @@ + + + +Unit Test Classes: test + + + + + + + +
+

+test +

+
+

Classes

+ + + + + + + + + + +
OrderTestPercentDiscount
OrderTestRandomDiscount
OrderTestStoreCreditDiscount
+ + diff --git a/junit/test/package-summary.html b/junit/test/package-summary.html new file mode 100644 index 0000000..55dc4e8 --- /dev/null +++ b/junit/test/package-summary.html @@ -0,0 +1,33 @@ + + + + + + +

Unit Test Results.

+ + + + +
Designed for use with JUnit and Ant.
+
+

Package test

+

Classes

+

+ + + + + + + + + + + + + +
NameTestsErrorsFailuresSkippedTime(s)Time StampHost
OrderTestPercentDiscount110200.0562015-11-19T04:44:41Aperture
OrderTestRandomDiscount10000.0472015-11-19T04:44:41Aperture
OrderTestStoreCreditDiscount110200.0572015-11-19T04:44:41Aperture
+

+ + diff --git a/lib/org.hamcrest.core_1.3.0.v201303031735.jar b/lib/org.hamcrest.core_1.3.0.v201303031735.jar new file mode 100644 index 0000000..52ab887 Binary files /dev/null and b/lib/org.hamcrest.core_1.3.0.v201303031735.jar differ diff --git a/lib/org.junit_4.11.0.v201303080030/META-INF/ECLIPSE_.RSA b/lib/org.junit_4.11.0.v201303080030/META-INF/ECLIPSE_.RSA new file mode 100644 index 0000000..5b9c142 Binary files /dev/null and b/lib/org.junit_4.11.0.v201303080030/META-INF/ECLIPSE_.RSA differ diff --git a/lib/org.junit_4.11.0.v201303080030/META-INF/ECLIPSE_.SF b/lib/org.junit_4.11.0.v201303080030/META-INF/ECLIPSE_.SF new file mode 100644 index 0000000..7f3a674 --- /dev/null +++ b/lib/org.junit_4.11.0.v201303080030/META-INF/ECLIPSE_.SF @@ -0,0 +1,20 @@ +Signature-Version: 1.0 +SHA1-Digest-Manifest: XbMhnLiG/PEbrt1Q2qTeo0M09WI= +Created-By: 1.6.0 (IBM Corporation) +SHA1-Digest-Manifest-Main-Attributes: 582to8693/RL9PKIGoffUN78Z64= + +Name: META-INF/eclipse.inf +SHA1-Digest: aM8odIt7KSTgo2Ap3NjnGa3gOAA= + +Name: junit.jar +SHA1-Digest: AklhjBArZV3erzCpodhYFGAimYU= + +Name: about.html +SHA1-Digest: iDs1zGnmPe0ZcAaEXJ2XXV746c0= + +Name: about_files/cpl-v10.html +SHA1-Digest: MIzNDpOYPvPiuf1zBtCLIJle7hg= + +Name: plugin.properties +SHA1-Digest: taVYPQQQV1reH2BG7t4lzEqgFl4= + diff --git a/lib/org.junit_4.11.0.v201303080030/META-INF/MANIFEST.MF b/lib/org.junit_4.11.0.v201303080030/META-INF/MANIFEST.MF new file mode 100644 index 0000000..8422f2a --- /dev/null +++ b/lib/org.junit_4.11.0.v201303080030/META-INF/MANIFEST.MF @@ -0,0 +1,49 @@ +Manifest-Version: 1.0 +Bundle-ClassPath: junit.jar +Bundle-Vendor: %providerName +Bundle-Localization: plugin +Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-Name: %pluginName +Bundle-SymbolicName: org.junit +Eclipse-SourceReferences: scm:cvs:pserver:dev.eclipse.org:/cvsroot/too + ls:org.eclipse.orbit/org.junit;tag=v201303080030 +Require-Bundle: org.hamcrest.core;bundle-version="1.3.0";visibility:=r + eexport +Export-Package: junit.extensions;version="4.11.0",junit.framework;vers + ion="4.11.0",junit.runner;version="4.11.0",junit.textui;version="4.11 + .0",org.junit;version="4.11.0",org.junit.experimental;version="4.11.0 + ",org.junit.experimental.categories;version="4.11.0",org.junit.experi + mental.max;version="4.11.0",org.junit.experimental.results;version="4 + .11.0",org.junit.experimental.runners;version="4.11.0",org.junit.expe + rimental.theories;version="4.11.0",org.junit.experimental.theories.in + ternal;version="4.11.0";x-internal:=true,org.junit.experimental.theor + ies.suppliers;version="4.11.0",org.junit.internal;version="4.11.0";x- + internal:=true,org.junit.internal.builders;version="4.11.0";x-interna + l:=true,org.junit.internal.matchers;version="4.11.0";x-internal:=true + ,org.junit.internal.requests;version="4.11.0";x-internal:=true,org.ju + nit.internal.runners;version="4.11.0";x-internal:=true,org.junit.inte + rnal.runners.model;version="4.11.0";x-internal:=true,org.junit.intern + al.runners.rules;version="4.11.0";x-internal:=true,org.junit.internal + .runners.statements;version="4.11.0";x-internal:=true,org.junit.match + ers;version="4.11.0",org.junit.rules;version="4.11.0",org.junit.runne + r;version="4.11.0",org.junit.runner.manipulation;version="4.11.0",org + .junit.runner.notification;version="4.11.0",org.junit.runners;version + ="4.11.0",org.junit.runners.model;version="4.11.0" +Bundle-Version: 4.11.0.v201303080030 +Bundle-ManifestVersion: 2 + +Name: META-INF/eclipse.inf +SHA1-Digest: M1yh6ypEH7aiF3JiaBs2vAuNi54= + +Name: junit.jar +SHA1-Digest: TgMbth3wkGmusr/7QBnnpQNKTuA= + +Name: about_files/cpl-v10.html +SHA1-Digest: REygXYi+T14Sj1v8XnnKycNjpN4= + +Name: about.html +SHA1-Digest: F5ZUX2plZ9O5TBIpgYrJRF5UuwY= + +Name: plugin.properties +SHA1-Digest: FtpZNVpeT7dDthHa+hExu4zdya4= + diff --git a/lib/org.junit_4.11.0.v201303080030/META-INF/eclipse.inf b/lib/org.junit_4.11.0.v201303080030/META-INF/eclipse.inf new file mode 100644 index 0000000..6c1d31a --- /dev/null +++ b/lib/org.junit_4.11.0.v201303080030/META-INF/eclipse.inf @@ -0,0 +1,4 @@ +#Processed using Jarprocessor +jarprocessor.exclude.children = true +pack200.args = -E4 +pack200.conditioned = true diff --git a/lib/org.junit_4.11.0.v201303080030/about.html b/lib/org.junit_4.11.0.v201303080030/about.html new file mode 100644 index 0000000..d670f04 --- /dev/null +++ b/lib/org.junit_4.11.0.v201303080030/about.html @@ -0,0 +1,50 @@ + + + + +About + + +

About This Content

+ +

February 4, 2013

+

License

+ +

The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise +indicated below, the Content is provided to you under the terms and conditions of the +Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available +at http://www.eclipse.org/legal/epl-v10.html. +For purposes of the EPL, "Program" will mean the Content.

+ +

If you did not receive this Content directly from the Eclipse Foundation, the Content is +being redistributed by another party ("Redistributor") and different terms and conditions may +apply to your use of any object code in the Content. Check the Redistributor's license that was +provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise +indicated below, the terms and conditions of the EPL still apply to any source code in the Content +and such source code may be obtained at http://www.eclipse.org.

+ + +

Third Party Content

+

The Content includes items that have been sourced from third parties as set out below. If you +did not receive this Content directly from the Eclipse Foundation, the following is provided +for informational purposes only, and you should look to the Redistributor's license for +terms and conditions of use.

+
+ +

The Content includes items that have been sourced from third parties as follows:

+ +

JUnit 4.11

+ +

The plug-in is accompanied by software developed by JUnit.org. The JUnit 4.11 code included with the plug-in includes no modifications. +Your use of JUnit 4.11 in both source and binary code form contained in the plug-in is subject to the terms and conditions of the +Common Public License Version 1.0 ("CPL"). A copy of the CPL is available at http://www.eclipse.org/legal/cpl-v10.html. +The binary code is located in junit.jar and the source code is located in source-bundle or in the org.junit.source bundle. +
The original source and binaries are available from http://search.maven.org/#search|gav|1|g%3A%22junit%22%20AND%20a%3A%22junit%22, namely: +
http://search.maven.org/remotecontent?filepath=junit/junit/4.11/junit-4.11-sources.jar +
http://search.maven.org/remotecontent?filepath=junit/junit/4.11/junit-4.11.jar +

+ +
+ + \ No newline at end of file diff --git a/lib/org.junit_4.11.0.v201303080030/about_files/cpl-v10.html b/lib/org.junit_4.11.0.v201303080030/about_files/cpl-v10.html new file mode 100644 index 0000000..36aa208 --- /dev/null +++ b/lib/org.junit_4.11.0.v201303080030/about_files/cpl-v10.html @@ -0,0 +1,125 @@ + + + +Common Public License - v 1.0 + + + + + + +

Common Public License - v 1.0 +

+

THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. +

+

1. DEFINITIONS +

"Contribution" means: + +

+ + + + + + + + + + +

+

"Contributor" means any person or entity that distributes the Program. +

+

"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program. +

+

"Program" means the Contributions distributed in accordance with this Agreement. +

+

"Recipient" means anyone who receives the Program under this Agreement, including all Contributors. +

+

2. GRANT OF RIGHTS + +

+ + + + + + + + + + + + + + + + + + + + + + +

3. REQUIREMENTS +

A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that: + +

+ + + + + + + + + + + + + + + + + + + +

When the Program is made available in source code form: + +

+ + + + +

+

Contributors may not remove or alter any copyright notices contained within the Program. +

+

Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution. +

+

4. COMMERCIAL DISTRIBUTION +

Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense. +

+

For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages. +

+

5. NO WARRANTY +

EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations. +

+

6. DISCLAIMER OF LIABILITY +

EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +

+

7. GENERAL +

If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable. +

+

If Recipient institutes patent litigation against a Contributor with respect to a patent applicable to software (including a cross-claim or counterclaim in a lawsuit), then any patent licenses granted by that Contributor to such Recipient under this Agreement shall terminate as of the date such litigation is filed. In addition, if Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed. +

+

All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive. +

+

Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. IBM is the initial Agreement Steward. IBM may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved. +

+

This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation. +

+

+ + + + \ No newline at end of file diff --git a/lib/org.junit_4.11.0.v201303080030/junit.jar b/lib/org.junit_4.11.0.v201303080030/junit.jar new file mode 100644 index 0000000..aaf7444 Binary files /dev/null and b/lib/org.junit_4.11.0.v201303080030/junit.jar differ diff --git a/lib/org.junit_4.11.0.v201303080030/plugin.properties b/lib/org.junit_4.11.0.v201303080030/plugin.properties new file mode 100644 index 0000000..be66d4c --- /dev/null +++ b/lib/org.junit_4.11.0.v201303080030/plugin.properties @@ -0,0 +1,12 @@ +############################################################################### +# Copyright (c) 2012 IBM Corporation and others. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# Contributors: +# IBM Corporation - initial API and implementation +############################################################################### +pluginName=JUnit Testing Framework +providerName=Eclipse Orbit diff --git a/src/Demo.java b/src/discount/Demo.java similarity index 97% rename from src/Demo.java rename to src/discount/Demo.java index e9f2b4c..1fd7479 100644 --- a/src/Demo.java +++ b/src/discount/Demo.java @@ -1,3 +1,4 @@ +package discount; public class Demo { public static void main(String argv[]) { diff --git a/src/DiscountStrategy.java b/src/discount/DiscountStrategy.java similarity index 81% rename from src/DiscountStrategy.java rename to src/discount/DiscountStrategy.java index 0989131..47306cf 100644 --- a/src/DiscountStrategy.java +++ b/src/discount/DiscountStrategy.java @@ -1,3 +1,4 @@ +package discount; public interface DiscountStrategy { public float applyDiscount(Order order); } diff --git a/src/Order.java b/src/discount/Order.java similarity index 93% rename from src/Order.java rename to src/discount/Order.java index 585adb5..6f766c3 100644 --- a/src/Order.java +++ b/src/discount/Order.java @@ -1,3 +1,4 @@ +package discount; public class Order { private String name; private float price; diff --git a/src/PercentDiscountStrategy.java b/src/discount/PercentDiscountStrategy.java similarity index 93% rename from src/PercentDiscountStrategy.java rename to src/discount/PercentDiscountStrategy.java index 8741c40..505f11b 100644 --- a/src/PercentDiscountStrategy.java +++ b/src/discount/PercentDiscountStrategy.java @@ -1,3 +1,4 @@ +package discount; public class PercentDiscountStrategy implements DiscountStrategy { diff --git a/src/RandomDiscountStrategy.java b/src/discount/RandomDiscountStrategy.java similarity index 94% rename from src/RandomDiscountStrategy.java rename to src/discount/RandomDiscountStrategy.java index fe2769a..fec13ab 100644 --- a/src/RandomDiscountStrategy.java +++ b/src/discount/RandomDiscountStrategy.java @@ -1,3 +1,4 @@ +package discount; import java.util.Random; public class RandomDiscountStrategy diff --git a/src/StoreCreditDiscountStrategy.java b/src/discount/StoreCreditDiscountStrategy.java similarity index 93% rename from src/StoreCreditDiscountStrategy.java rename to src/discount/StoreCreditDiscountStrategy.java index 25c0c4c..1a8717b 100644 --- a/src/StoreCreditDiscountStrategy.java +++ b/src/discount/StoreCreditDiscountStrategy.java @@ -1,3 +1,4 @@ +package discount; public class StoreCreditDiscountStrategy implements DiscountStrategy { diff --git a/src/test/OrderTestPercentDiscount.java b/src/test/OrderTestPercentDiscount.java new file mode 100644 index 0000000..3df8c43 --- /dev/null +++ b/src/test/OrderTestPercentDiscount.java @@ -0,0 +1,158 @@ +package test; + +import static org.junit.Assert.*; + +import org.junit.Test; + +import discount.DiscountStrategy; +import discount.Order; +import discount.PercentDiscountStrategy; + +public class OrderTestPercentDiscount { + + + + + //test range of discount percentages + + @Test + public void percentageDiscountTest1() { + Order order = new Order("Shane", 444.0f); + float amt = 0; + + DiscountStrategy strategy = new PercentDiscountStrategy(amt); + float discounted = strategy.applyDiscount(order); + + //assert equals with 0.01 tolerance + assertEquals(444,discounted,0.01); + } + + @Test + public void percentageDiscountTest2() { + Order order = new Order("Shane", 444.0f); + float amt = 25; + + DiscountStrategy strategy = new PercentDiscountStrategy(amt); + float discounted = strategy.applyDiscount(order); + + //assert equals with 0.01 tolerance + assertEquals(333,discounted,0.01); + } + + @Test + public void percentageDiscountTest3() { + Order order = new Order("Shane", 444.0f); + float amt = 50; + + DiscountStrategy strategy = new PercentDiscountStrategy(amt); + float discounted = strategy.applyDiscount(order); + + //assert equals with 0.01 tolerance + assertEquals(222,discounted,0.01); + } + + @Test + public void percentageDiscountTest4() { + Order order = new Order("Shane", 444.0f); + float amt = 75; + + DiscountStrategy strategy = new PercentDiscountStrategy(amt); + float discounted = strategy.applyDiscount(order); + + //assert equals with 0.01 tolerance + assertEquals(111,discounted,0.01); + } + + @Test + public void percentageDiscountTest5() { + Order order = new Order("Shane", 444.0f); + float amt = 100; + + DiscountStrategy strategy = new PercentDiscountStrategy(amt); + float discounted = strategy.applyDiscount(order); + + //assert equals with 0.01 tolerance + assertEquals(0,discounted,0.01); + } + + + + //Test that discount is bounded by 0% and 100% + + @Test + public void percentageDiscountTest6() { + Order order = new Order("Shane", 444.0f); + float amt = -1000; + + DiscountStrategy strategy = new PercentDiscountStrategy(amt); + float discounted = strategy.applyDiscount(order); + + //assert equals with 0.01 tolerance + assertEquals(444,discounted,0.01); + } + + @Test + public void percentageDiscountTest7() { + Order order = new Order("Shane", 444.0f); + float amt = 1000; + + DiscountStrategy strategy = new PercentDiscountStrategy(amt); + float discounted = strategy.applyDiscount(order); + + //assert equals with 0.01 tolerance + assertEquals(0,discounted,0.01); + } + + + + //Test accuracy of percentage discount + + @Test + public void percentageDiscountTest8() { + Order order = new Order("Shane", 100.0f); + float amt = 0.01f; + + DiscountStrategy strategy = new PercentDiscountStrategy(amt); + float discounted = strategy.applyDiscount(order); + + //assert equals with 0.01 tolerance + assertEquals(99.99,discounted,0.01); + } + + @Test + public void percentageDiscountTest9() { + Order order = new Order("Shane", 100.0f); + float amt = 33.33f; + + DiscountStrategy strategy = new PercentDiscountStrategy(amt); + float discounted = strategy.applyDiscount(order); + + //assert equals with 0.01 tolerance + assertEquals(66.67,discounted,0.01); + } + + @Test + public void percentageDiscountTest10() { + Order order = new Order("Shane", 100.0f); + float amt = 66.66f; + + DiscountStrategy strategy = new PercentDiscountStrategy(amt); + float discounted = strategy.applyDiscount(order); + + //assert equals with 0.01 tolerance + assertEquals(33.34,discounted,0.01); + } + + @Test + public void percentageDiscountTest11() { + Order order = new Order("Shane", 100.0f); + float amt = 99.99f; + + DiscountStrategy strategy = new PercentDiscountStrategy(amt); + float discounted = strategy.applyDiscount(order); + + //assert equals with 0.01 tolerance + assertEquals(0.01,discounted,0.01); + } + +} diff --git a/src/test/OrderTestRandomDiscount.java b/src/test/OrderTestRandomDiscount.java new file mode 100644 index 0000000..4159203 --- /dev/null +++ b/src/test/OrderTestRandomDiscount.java @@ -0,0 +1,41 @@ +package test; + +import static org.junit.Assert.*; + +import org.junit.Test; + +import discount.DiscountStrategy; +import discount.Order; +import discount.RandomDiscountStrategy; + +public class OrderTestRandomDiscount { + + + //test that the random discount does not apply discounts of less than 0% or greater than 100% + + @Test + public void randomDiscountTest1() { + + double percentageOfTimesWithinBounds = 0; + int repeat = 1000; + int withinBounds = 0; + + for (int i = 0; i= 0 || discounted <= 444) { + withinBounds++; + } + } + + percentageOfTimesWithinBounds = (withinBounds/repeat)*100; + + + //assert equals with 0.01 tolerance + assertEquals(100,percentageOfTimesWithinBounds,0); + } + +} diff --git a/src/test/OrderTestStoreCreditDiscount.java b/src/test/OrderTestStoreCreditDiscount.java new file mode 100644 index 0000000..ffda4cd --- /dev/null +++ b/src/test/OrderTestStoreCreditDiscount.java @@ -0,0 +1,157 @@ +package test; + +import static org.junit.Assert.*; + +import org.junit.Test; + +import discount.DiscountStrategy; +import discount.Order; +import discount.StoreCreditDiscountStrategy; + +public class OrderTestStoreCreditDiscount { + + + + //test range of credit discounts + + @Test + public void creditDiscountTest1() { + Order order = new Order("Shane", 444.0f); + float amt = 0; + + DiscountStrategy strategy = new StoreCreditDiscountStrategy(amt); + float discounted = strategy.applyDiscount(order); + + //assert equals with 0.01 tolerance + assertEquals(444,discounted,0.01); + } + + @Test + public void creditDiscountTest2() { + Order order = new Order("Shane", 444.0f); + float amt = 111; + + DiscountStrategy strategy = new StoreCreditDiscountStrategy(amt); + float discounted = strategy.applyDiscount(order); + + //assert equals with 0.01 tolerance + assertEquals(333,discounted,0.01); + } + + @Test + public void creditDiscountTest3() { + Order order = new Order("Shane", 444.0f); + float amt = 222; + + DiscountStrategy strategy = new StoreCreditDiscountStrategy(amt); + float discounted = strategy.applyDiscount(order); + + //assert equals with 0.01 tolerance + assertEquals(222,discounted,0.01); + } + + @Test + public void creditDiscountTest4() { + Order order = new Order("Shane", 444.0f); + float amt = 333; + + DiscountStrategy strategy = new StoreCreditDiscountStrategy(amt); + float discounted = strategy.applyDiscount(order); + + //assert equals with 0.01 tolerance + assertEquals(111,discounted,0.01); + } + + @Test + public void creditDiscountTest5() { + Order order = new Order("Shane", 444.0f); + float amt = 444; + + DiscountStrategy strategy = new StoreCreditDiscountStrategy(amt); + float discounted = strategy.applyDiscount(order); + + //assert equals with 0.01 tolerance + assertEquals(0,discounted,0.01); + } + + + + //Test that discount is bounded by 0 and the order price + + @Test + public void creditDiscountTest6() { + Order order = new Order("Shane", 444.0f); + float amt = -1000; + + DiscountStrategy strategy = new StoreCreditDiscountStrategy(amt); + float discounted = strategy.applyDiscount(order); + + //assert equals with 0.01 tolerance + assertEquals(444,discounted,0.01); + } + + @Test + public void creditDiscountTest7() { + Order order = new Order("Shane", 444.0f); + float amt = 1000; + + DiscountStrategy strategy = new StoreCreditDiscountStrategy(amt); + float discounted = strategy.applyDiscount(order); + + //assert equals with 0.01 tolerance + assertEquals(0,discounted,0.01); + } + + + + //Test accuracy of credit discount + + @Test + public void creditDiscountTest8() { + Order order = new Order("Shane", 100.0f); + float amt = 0.01f; + + DiscountStrategy strategy = new StoreCreditDiscountStrategy(amt); + float discounted = strategy.applyDiscount(order); + + //assert equals with 0.01 tolerance + assertEquals(99.99,discounted,0.01); + } + + @Test + public void creditDiscountTest9() { + Order order = new Order("Shane", 100.0f); + float amt = 33.33f; + + DiscountStrategy strategy = new StoreCreditDiscountStrategy(amt); + float discounted = strategy.applyDiscount(order); + + //assert equals with 0.01 tolerance + assertEquals(66.67,discounted,0.01); + } + + @Test + public void creditDiscountTest10() { + Order order = new Order("Shane", 100.0f); + float amt = 66.66f; + + DiscountStrategy strategy = new StoreCreditDiscountStrategy(amt); + float discounted = strategy.applyDiscount(order); + + //assert equals with 0.01 tolerance + assertEquals(33.34,discounted,0.01); + } + + @Test + public void creditDiscountTest11() { + Order order = new Order("Shane", 100.0f); + float amt = 99.99f; + + DiscountStrategy strategy = new StoreCreditDiscountStrategy(amt); + float discounted = strategy.applyDiscount(order); + + //assert equals with 0.01 tolerance + assertEquals(0.01,discounted,0.01); + } + +}