SplitBy { public SplitByResult evaluate( final TimeGeometricPrimitive a, final TimeGeometricPrimitive b ) { if ( !new AnyInteracts().evaluate( a, b ) ) { return new SplitByResult( a, null, null ); } if ( a instanceof TimeInstant ) { return new SplitByResult( null, a, null ); } if ( b instanceof TimeInstant ) { throw new IllegalArgumentException( "Invalid arguments for SplitBy" ); } final boolean hasBegin = compareBegin( a, b ) < 0; final boolean hasEnd = compareEnd( b, a ) < 0; final TimePeriod begin = hasBegin ? create( begin( a ), begin( b ) ) : null; final TimePosition intersectionBegin = hasBegin ? begin( b ) : begin( a ); final TimePosition intersectionEnd = hasEnd ? end( b ) : end( a ); final TimePeriod end = hasEnd ? create( end( b ), end( a ) ) : null; final TimePeriod intersection = create( intersectionBegin, intersectionEnd ); return new SplitByResult( begin, intersection, end ); }  SplitByResult evaluate( final TimeGeometricPrimitive a, final TimeGeometricPrimitive b );  }
@Test public void evaluateBegunByInstant1() { expectedException.expect( IllegalArgumentException.class ); expectedException.expectMessage( "Invalid arguments for SplitBy" ); splitBy.evaluate( period( "00:00:02", "00:00:05" ), instant( "00:00:02" ) ); }
@Test public void evaluateBegunByInstant2() { expectedException.expect( IllegalArgumentException.class ); expectedException.expectMessage( "Invalid arguments for SplitBy" ); splitBy.evaluate( period( "00:00:02", null ), instant( "00:00:02" ) ); }
@Test public void evaluateTContainsInstant1() { expectedException.expect( IllegalArgumentException.class ); expectedException.expectMessage( "Invalid arguments for SplitBy" ); splitBy.evaluate( period( "00:00:02", "00:00:05" ), instant( "00:00:03" ) ); }
@Test public void evaluateTContainsInstant2() { expectedException.expect( IllegalArgumentException.class ); expectedException.expectMessage( "Invalid arguments for SplitBy" ); splitBy.evaluate( period( "00:00:02", null ), instant( "00:00:03" ) ); }
@Test public void evaluateTContainsInstant3() { expectedException.expect( IllegalArgumentException.class ); expectedException.expectMessage( "Invalid arguments for SplitBy" ); splitBy.evaluate( period( null, "00:00:05" ), instant( "00:00:03" ) ); }
@Test public void evaluateTContainsInstant4() { expectedException.expect( IllegalArgumentException.class ); expectedException.expectMessage( "Invalid arguments for SplitBy" ); splitBy.evaluate( period( null, null ), instant( "00:00:03" ) ); }