TransactionTokenContextImpl implements TransactionTokenContext { @Deprecated public void cancelReservation() { reserveCommand = defaultCommand; } TransactionTokenContextImpl(final TransactionTokenInfo tokenInfo,
            TransactionToken receivedToken); TransactionTokenInfo getTokenInfo(); @Deprecated @Override void createToken(); @Deprecated @Override void removeToken(); @Deprecated void cancelReservation(); ReserveCommand getReserveCommand(); @Override TransactionToken getReceivedToken();  }
@Test @SuppressWarnings("deprecation") public void TestCancelReservation01() throws IllegalArgumentException, IllegalAccessException { TransactionTokenInfo beginTransactionToken = new TransactionTokenInfo("testTokenAttribute1", TransactionTokenType.BEGIN); TransactionToken receivedToken = new TransactionToken("aaa"); TransactionTokenContextImpl contextImpl = new TransactionTokenContextImpl(beginTransactionToken, receivedToken); ReserveCommand expectedCommand = ReserveCommand.CREATE_TOKEN; contextImpl.cancelReservation(); Field field = ReflectionUtils.findField( TransactionTokenContextImpl.class, "defaultCommand"); ReflectionUtils.makeAccessible(field); ReserveCommand resultCommand = (ReserveCommand) field.get(contextImpl); assertThat(resultCommand, is(expectedCommand)); }
@Test @SuppressWarnings("deprecation") public void TestCancelReservation02() throws IllegalArgumentException, IllegalAccessException { TransactionTokenInfo beginTransactionToken = new TransactionTokenInfo("testTokenAttribute1", TransactionTokenType.BEGIN); TransactionToken receivedToken = new TransactionToken("aaa", "key", "value"); ReserveCommand expectedCommand = ReserveCommand.UPDATE_TOKEN; TransactionTokenContextImpl contextImpl = new TransactionTokenContextImpl(beginTransactionToken, receivedToken); contextImpl.cancelReservation(); Field field = ReflectionUtils.findField( TransactionTokenContextImpl.class, "defaultCommand"); ReflectionUtils.makeAccessible(field); ReserveCommand resultCommand = (ReserveCommand) field.get(contextImpl); assertThat(resultCommand, is(expectedCommand)); }
@Test @SuppressWarnings("deprecation") public void TestCancelReservation03() throws IllegalArgumentException, IllegalAccessException { TransactionTokenInfo inTransactionToken = new TransactionTokenInfo("testTokenAttribute2", TransactionTokenType.IN); TransactionToken receivedToken = new TransactionToken("bbb"); ReserveCommand expectedCommand = ReserveCommand.CREATE_TOKEN; TransactionTokenContextImpl contextImpl = new TransactionTokenContextImpl(inTransactionToken, receivedToken); contextImpl.cancelReservation(); Field field = ReflectionUtils.findField( TransactionTokenContextImpl.class, "defaultCommand"); ReflectionUtils.makeAccessible(field); ReserveCommand resultCommand = (ReserveCommand) field.get(contextImpl); assertThat(resultCommand, is(expectedCommand)); }
@Test @SuppressWarnings("deprecation") public void TestCancelReservation04() throws IllegalArgumentException, IllegalAccessException { TransactionTokenInfo inTransactionToken = new TransactionTokenInfo("testTokenAttribute2", TransactionTokenType.IN); TransactionToken receivedToken = new TransactionToken("bbb", "key", "value"); ReserveCommand expectedCommand = ReserveCommand.UPDATE_TOKEN; TransactionTokenContextImpl contextImpl = new TransactionTokenContextImpl(inTransactionToken, receivedToken); contextImpl.cancelReservation(); Field field = ReflectionUtils.findField( TransactionTokenContextImpl.class, "defaultCommand"); ReflectionUtils.makeAccessible(field); ReserveCommand resultCommand = (ReserveCommand) field.get(contextImpl); assertThat(resultCommand, is(expectedCommand)); }
@Test @SuppressWarnings("deprecation") public void TestCancelReservation05() throws IllegalArgumentException, IllegalAccessException { TransactionTokenInfo endTransactionToken = new TransactionTokenInfo("testTokenAttribute3", TransactionTokenType.END); TransactionToken receivedToken = new TransactionToken("ccc"); ReserveCommand expectedCommand = ReserveCommand.NONE; TransactionTokenContextImpl contextImpl = new TransactionTokenContextImpl(endTransactionToken, receivedToken); contextImpl.cancelReservation(); Field field = ReflectionUtils.findField( TransactionTokenContextImpl.class, "defaultCommand"); ReflectionUtils.makeAccessible(field); ReserveCommand resultCommand = (ReserveCommand) field.get(contextImpl); assertThat(resultCommand, is(expectedCommand)); }
@Test @SuppressWarnings("deprecation") public void TestCancelReservation06() throws IllegalArgumentException, IllegalAccessException { TransactionTokenInfo endTransactionToken = new TransactionTokenInfo("testTokenAttribute3", TransactionTokenType.END); TransactionToken receivedToken = new TransactionToken("ccc", "key", "value"); ReserveCommand expectedCommand = ReserveCommand.REMOVE_TOKEN; TransactionTokenContextImpl contextImpl = new TransactionTokenContextImpl(endTransactionToken, receivedToken); contextImpl.cancelReservation(); Field field = ReflectionUtils.findField( TransactionTokenContextImpl.class, "defaultCommand"); ReflectionUtils.makeAccessible(field); ReserveCommand resultCommand = (ReserveCommand) field.get(contextImpl); assertThat(resultCommand, is(expectedCommand)); }