MongoAppSessionRepository extends CrudRepositoryBase<AppSession, String> implements AppSessionRepository { @Override public <S extends AppSession> S add(final S appSession) { Preconditions.checkNotNull(appSession, "Cannot add null AppSession"); Preconditions.checkNotNull(appSession.getId(), "Cannot add AppSession with null ID"); log.info("Insert AppSession {} for {} with User Agent: {} (dated: {})", appSession.getId(), appSession.getPerson() != null ? appSession.getPerson().getId() : null, appSession.getUserAgent(), appSession.getCreationTime() ); final DBObject obj = new ToDBObject().apply(appSession); coll.insert(obj); return appSession; } @Inject  MongoAppSessionRepository(@Value("#{soluvasProps.securityMongoUri}") String mongoUri); @PreDestroy void destroy(); String getMongoUri(); @Override AppSession findOneByActive(String id); @Override S add(final S appSession); @Override S modify(final String id, final S appSession); @Override boolean exists(String id); @Override List<AppSession> findAll(); @Override long count(); @SuppressWarnings("unchecked") @Override S findOne(String id); @Override boolean delete(String id); @Override List<AppSession> findAllByActive(); @Override boolean touch(String id);  }
@Test public void save() { final AppSession appSession = SecurityFactory.eINSTANCE.createAppSession(); appSession.setId("00000000"); appSession.setCreationTime(new DateTime()); appSession.setStatus(AppSessionStatus.ACTIVE); appSession.setIpAddress("127.0.0.1"); appSession.setTimeout(1800000L); appSession.setAccessTime(new DateTime()); appSession.setExpiryTime(new DateTime()); final Object attr1 = new Object(); appSession.getAttributes().put("Wicket:SessionUnbindingListener-berbatik_dev", attr1); final AppSession added = appSessionRepo.add(appSession); assertNotNull(appSession); }