JobIdGenerator implements ILogoutListener, IJobIdGenerator { @Override public boolean acquire( final IPentahoSession session, final UUID id ) { ArgumentNullException.validate( SESSION, session ); return reservedIds.getOrDefault( session, Collections.emptySet() ).remove( id ); } 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 acquire() throws Exception { final JobIdGenerator jobIdGenerator = new JobIdGenerator(); final IPentahoSession mock = mock( IPentahoSession.class ); final UUID generateId = jobIdGenerator.generateId( mock ); assertNotNull( generateId ); assertFalse( jobIdGenerator.acquire( mock( IPentahoSession.class ), generateId ) ); assertFalse( jobIdGenerator.acquire( mock, UUID.randomUUID() ) ); assertTrue( jobIdGenerator.acquire( mock, generateId ) ); assertFalse( jobIdGenerator.acquire( mock, generateId ) ); }
@Test( expected = ArgumentNullException.class ) public void acquireNullSession() throws Exception { final JobIdGenerator jobIdGenerator = new JobIdGenerator(); jobIdGenerator.acquire( null, UUID.randomUUID() ); }
@Test public void acquireNullId() throws Exception { final JobIdGenerator jobIdGenerator = new JobIdGenerator(); assertFalse( jobIdGenerator.acquire( mock( IPentahoSession.class ), null ) ); }