}
@SuppressWarnings("unchecked")
private void getSessionDataNoOwner(boolean includeAttributes) throws Exception {
String sessionId = "abc";
IncomingDistributableSessionData data = mock(IncomingDistributableSessionData.class);
@SuppressWarnings("rawtypes")
ArgumentCaptor<CacheInvoker.Operation> capturedOperation = ArgumentCaptor.forClass(CacheInvoker.Operation.class);
when(this.invoker.invoke(same(this.cache), capturedOperation.capture())).thenReturn(data);
IncomingDistributableSessionData result = this.manager.getSessionData(sessionId, null, includeAttributes);
assertSame(data, result);
Map<Object, Object> map = mock(Map.class);
Map<String, Object> attributes = Collections.emptyMap();
Integer version = Integer.valueOf(10);
Long timestamp = Long.valueOf(System.currentTimeMillis());
DistributableSessionMetadata metadata = new DistributableSessionMetadata();
CacheInvoker.Operation<String, Map<Object, Object>, IncomingDistributableSessionData> operation = capturedOperation.getValue();
when(this.cache.get(sessionId)).thenReturn(map);
when(map.get(Byte.valueOf((byte) SessionMapEntry.VERSION.ordinal()))).thenReturn(version);
when(map.get(Byte.valueOf((byte) SessionMapEntry.TIMESTAMP.ordinal()))).thenReturn(timestamp);
when(map.get(Byte.valueOf((byte) SessionMapEntry.METADATA.ordinal()))).thenReturn(metadata);
if (includeAttributes) {
when(this.storage.load(map)).thenReturn(attributes);
}
result = operation.invoke(this.cache);
assertNotNull(result);
assertEquals(version.intValue(), result.getVersion());
assertEquals(timestamp.longValue(), result.getTimestamp());
assertSame(metadata, result.getMetadata());
if (includeAttributes) {
assertSame(attributes, result.getSessionAttributes());
} else {
IllegalStateException exception = null;
Map<String, Object> sessionAttributes = null;
try {
sessionAttributes = result.getSessionAttributes();
} catch (IllegalStateException e) {
exception = e;
}
assertNull(sessionAttributes);