JobIdGenerator implements ILogoutListener, IJobIdGenerator { @Override public UUID generateId( final IPentahoSession session ) { ArgumentNullException.validate( SESSION, session ); final Set<Object> freshSet = Sets.newConcurrentHashSet(); final UUID uuid = UUID.randomUUID(); Set<Object> sessionIds = reservedIds.putIfAbsent( session, freshSet ); if ( sessionIds == null ) { sessionIds = freshSet; } sessionIds.add( uuid ); return uuid; } JobIdGenerator(); @Override void onLogout( final IPentahoSession session ); @Override UUID generateId( final IPentahoSession session ); @Override boolean acquire( final IPentahoSession session, final UUID id ); static final String ID; }
@Test public void generateId() throws Exception { final JobIdGenerator jobIdGenerator = new JobIdGenerator(); final IPentahoSession mock = mock( IPentahoSession.class ); final UUID generateId = jobIdGenerator.generateId( mock ); assertNotNull( generateId ); }
@Test( expected = ArgumentNullException.class ) public void generateIdNullSession() throws Exception { final JobIdGenerator jobIdGenerator = new JobIdGenerator(); jobIdGenerator.generateId( null ); }