}
@SuppressWarnings("unchecked")
@Test
public void storeSessionData() throws IOException {
OutgoingDistributableSessionData data = mock(OutgoingDistributableSessionData.class);
Map<Object, Object> map = mock(Map.class);
@SuppressWarnings("rawtypes")
ArgumentCaptor<CacheInvoker.Operation> capturedOperation = ArgumentCaptor.forClass(CacheInvoker.Operation.class);
String sessionId = "abc";
when(data.getRealId()).thenReturn(sessionId);
// when(this.sessionCache.startBatch()).thenReturn(true);
when(this.invoker.invoke(same(this.cache), capturedOperation.capture())).thenReturn(null);
this.manager.storeSessionData(data);
// verify(this.sessionCache).endBatch(true);
CacheInvoker.Operation<String, Map<Object, Object>, Void> operation = capturedOperation.getValue();
int version = 10;
long timestamp = System.currentTimeMillis();
DistributableSessionMetadata metadata = new DistributableSessionMetadata();
// when(this.sessionCache.startBatch()).thenReturn(true);
when(data.getVersion()).thenReturn(version);
when(map.put(Byte.valueOf((byte) SessionMapEntry.VERSION.ordinal()), version)).thenReturn(null);
when(data.getTimestamp()).thenReturn(timestamp);
when(map.put(Byte.valueOf((byte) SessionMapEntry.TIMESTAMP.ordinal()), timestamp)).thenReturn(null);
when(data.getMetadata()).thenReturn(metadata);
when(map.put(Byte.valueOf((byte) SessionMapEntry.METADATA.ordinal()), metadata)).thenReturn(null);
when(this.cache.putIfAbsent(eq(sessionId), Mockito.<Map<Object, Object>>anyObject())).thenReturn(map);
operation.invoke(this.cache);