com.ail.insurancetest
Class TestAssessmentSheet

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by com.ail.insurancetest.TestAssessmentSheet
All Implemented Interfaces:
junit.framework.Test

public class TestAssessmentSheet
extends junit.framework.TestCase

The assessment sheet is at the center of the quotation process. It can be thought of as a restricted spreadsheet. Entries can be absulute amounts (Sums) or rates (Percentage). Each entry may depend on a maximum of one other entry, and may contribute to another. Most of what the calculatePremium service does is to run through this table processing it and producing results from it.

Version:
$Revision: 1.3 $

Constructor Summary
TestAssessmentSheet(java.lang.String name)
          Constructs a test case with the given name.
 
Method Summary
static void main(java.lang.String[] args)
          Run this testcase from the command line.
static junit.framework.Test suite()
          Create an instance of this test case as a TestSuite.
 void testAddLineWithoutLock()
          Check that lines can only be added to the sheet if either the sheet is locked to an actor, or the lines already have an origin.
 void testAssessmentSheetDoubleLock()
          Test assessment sheet double lock.
 void testDuplicateLineDetection()
          Check that duplicate lines are detected.
 void testRemoveLinesByActor()
          Test the removal of lines by actor.
 void testSimpleManipulation()
          Test summary methods and simple line additions
 
Methods inherited from class junit.framework.TestCase
countTestCases, getName, run, run, runBare, setName, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TestAssessmentSheet

public TestAssessmentSheet(java.lang.String name)
Constructs a test case with the given name.

Parameters:
name - The tests name
Method Detail

suite

public static junit.framework.Test suite()
Create an instance of this test case as a TestSuite.

Returns:
Test an instance of this test case.

main

public static void main(java.lang.String[] args)
Run this testcase from the command line.

Parameters:
args - No command line args are required.

testSimpleManipulation

public void testSimpleManipulation()
Test summary methods and simple line additions


testAssessmentSheetDoubleLock

public void testAssessmentSheetDoubleLock()
                                   throws java.lang.Exception
Test assessment sheet double lock. Assessment sheets are locked to an actor before lines can be added. This test ensures that two actors can lock the same sheet, but that a sheet can be locked by the same actor more than once.
  1. Create an assessment sheet
  2. Lock the sheet to the actor "me"
  3. Attempt to lock the sheet for the actor "you"
  4. Fail if an IllegalStateException isn't thrown
  5. File if anyother exception is thrown
  6. Lock the sheet as the actor "me" again
  7. Fail if any exceptions af thrown

Throws:
java.lang.Exception

testAddLineWithoutLock

public void testAddLineWithoutLock()
                            throws java.lang.Exception
Check that lines can only be added to the sheet if either the sheet is locked to an actor, or the lines already have an origin.
  1. Create an assessment sheet
  2. Add a line to the sheet (without locking first)
  3. Fail if an IllegalStateException isn't thrown
  4. Fail if any other exception is thrown
  5. Lock the assessment sheet to "me"
  6. Try to add the line again
  7. Fail if any exceptions are thrown
  8. Clear the lock
  9. Create a FixedSum line, and set its origin to "me"
  10. Try to add the line
  11. Fail if any exceptions are thrown

Throws:
java.lang.Exception

testRemoveLinesByActor

public void testRemoveLinesByActor()
Test the removal of lines by actor. An actor can remove all of their lines from an assessment sheet using the removeLinesByOrigin method. This should remove all of that actor's lines, but not touch any of the others.
  1. Create an assessment sheet
  2. Set the locking actor to "me"
  3. Add two lines to the sheet
  4. Check that the sheet has two lines (get the count)
  5. Unlock the sheet, and re-lock as "you"
  6. Add three further lines to the sheet
  7. Check that the sheet has five lines
  8. Unlock hte sheet
  9. use 'removeLInesByOrigin' to remove all of the lines created by "me"
  10. Check that the sheet has three lines
  11. Check that the lines are those added by "you" - by checking their IDs


testDuplicateLineDetection

public void testDuplicateLineDetection()
                                throws java.lang.Exception
Check that duplicate lines are detected. An assessment sheet cannot contain two assessment lines with the same id. This should be detected when an attempt is made to add the second line. This test ensures that that is the case.
  1. Create an assessment sheet
  2. Lock the sheet to actor "me"
  3. Add a line with the id "l1"
  4. Fail if any exceptions are thrown
  5. Attempt to add another line with the id "l1"
  6. Fail if a DuplicateAssessmentSheetLineError isn't thrown
  7. Fail if any other exceptions are thrown.
  8. Fail is no exception is thrown

Throws:
java.lang.Exception