DefaultReservedValueService implements ReservedValueService { @Override @Transactional public boolean useReservedValue( TextPattern textPattern, String value ) { return reservedValueStore.useReservedValue( textPattern.getOwnerUid(), value ); } DefaultReservedValueService( TextPatternService textPatternService, ReservedValueStore reservedValueStore,
        SequentialNumberCounterStore sequentialNumberCounterStore ); @Override @Transactional List<ReservedValue> reserve( TextPattern textPattern, int numberOfReservations, Map<String, String> values, Date expires ); @Override @Transactional boolean useReservedValue( TextPattern textPattern, String value ); @Override @Transactional(readOnly = true) boolean isReserved( TextPattern textPattern, String value ); @Override @Transactional void removeExpiredReservations(); @Override @Transactional void deleteReservedValueByUid( String uid );  }
@Test public void testUseReservationWhenReserved() { reservedValueStore.reserveValues( simpleReservedValue, Lists.newArrayList( "FOOBAR" ) ); boolean res = reservedValueService.useReservedValue( simpleTextPattern, "FOOBAR" ); assertTrue( res ); assertEquals( 0, reservedValueStore.getCount() ); }
@Test public void testUseReservationWhenNotReserved() { boolean res = reservedValueService.useReservedValue( simpleTextPattern, "FOOBAR" ); assertFalse( res ); assertEquals( 0, reservedValueStore.getCount() ); }