@Before public void setupOrg() { //get the system property of the UUID to use. If one is not set, use the defualt String uuidString = System.getProperty( "org.id", "80a42760-b699-11e3-a5e2-0800200c9a66" ); scope = new ApplicationScopeImpl( IdGenerator.createId( UUID.fromString( uuidString ), "test" ) ); numWorkers = Integer.parseInt( System.getProperty( "numWorkers", "100" ) ); writeLimit = Integer.parseInt( System.getProperty( "writeLimit", "10000" ) ); readCount = Integer.parseInt( System.getProperty( "readCount", "20000" ) ); }
@Override public Health getEntityStoreHealth() { // could use any collection scope here, does not matter EntityCollectionManager ecm = managerCache.getEntityCollectionManager( new ApplicationScopeImpl( new SimpleId( CpNamingUtils.MANAGEMENT_APPLICATION_ID, "application" ) ) ); return ecm.getHealth(); }
@Before public void before(){ appId = new SimpleId(UUID.randomUUID(), "application" ); IndexLocationStrategy strategy = new TestIndexIdentifier(cassandraFig,fig,new ApplicationScopeImpl(appId)); entityIndex = eif.createEntityIndex( strategy ); }
@Before public void setup(){ appId = new SimpleId(UUID.randomUUID(), "application" ); IndexLocationStrategy strategy = new TestIndexIdentifier(cassandraFig,fig,new ApplicationScopeImpl(appId)); entityIndex = eif.createEntityIndex( strategy ); }
@Before public void setup() { graphFig = mock( GraphFig.class ); when( graphFig.getShardAuditWorkerCount() ).thenReturn( 10 ); when( graphFig.getShardAuditWorkerQueueSize() ).thenReturn( 1000 ); listeningExecutorService = MoreExecutors.listeningDecorator( TaskExecutorFactory .createTaskExecutor( "GraphTaskExecutor", graphFig.getShardAuditWorkerCount(), graphFig.getShardAuditWorkerQueueSize(), TaskExecutorFactory.RejectionAction.ABORT ) ); asyncTaskExecutor = mock( AsyncTaskExecutor.class ); when( asyncTaskExecutor.getExecutorService() ).thenReturn( listeningExecutorService ); this.scope = new ApplicationScopeImpl( IdGenerator.createId( "application" ) ); }
@Test(expected = IllegalArgumentException.class) public void noShards() { final ApplicationScope scope = new ApplicationScopeImpl( IdGenerator.createId( "application" ) ); final DirectedEdgeMeta directedEdgeMeta = DirectedEdgeMeta.fromSourceNode( IdGenerator.createId( "source" ), "test" ); final ShardGroupCompaction shardGroupCompaction = mock( ShardGroupCompaction.class ); final long delta = 10000; final Iterator<Shard> noShards = Collections.<Shard>emptyList().iterator(); //should blow up, our iterator is empty new ShardEntryGroupIterator( noShards, delta, shardGroupCompaction, scope, directedEdgeMeta ); }
@Test( expected = NullPointerException.class ) public void loadListParamVersion() throws ConnectionException { logEntryStrategy .load( new ApplicationScopeImpl( new SimpleId( "organization" ) ), new SimpleId( "test" ), null, 1 ); }
@Test(expected = NullPointerException.class) public void deleteParamEntityId() throws ConnectionException { serializationStrategy.delete( new ApplicationScopeImpl( new SimpleId( "organization" ) ), null, UUIDGenerator.newTimeUUID() ); }
@Test(expected = NullPointerException.class) public void loadParamEntityId() throws ConnectionException { serializationStrategy .load( new ApplicationScopeImpl(new SimpleId( "organization" ) ), null, UUIDGenerator.newTimeUUID() ); }
@Override public void call( final Subscriber<? super ConnectionScope> subscriber ) { final ApplicationScope applicationScope = new ApplicationScopeImpl( createId( "application" ) ); final Edge edge = CpNamingUtils.createConnectionEdge( createId( "source" ), "test", createId( "target" ) ); final ConnectionScope scope = new ConnectionScope( applicationScope, edge ); subscriber.onStart(); for ( int i = 0; i < count; i++ ) { subscriber.onNext( scope ); } subscriber.onCompleted(); } }
@Test(expected = NullPointerException.class) public void loadListParamEntityId() throws ConnectionException { serializationStrategy .loadDescendingHistory( new ApplicationScopeImpl( new SimpleId( "organization" ) ), null, UUIDGenerator.newTimeUUID(), 1 ); }
@Test(expected = NullPointerException.class) public void loadListParamVersion() throws ConnectionException { serializationStrategy .loadDescendingHistory( new ApplicationScopeImpl( new SimpleId( "organization" ) ), new SimpleId( "test" ), null, 1 ); }
@Test public void validInput() { ApplicationScopeImpl context = new ApplicationScopeImpl(new SimpleId( "organization" )); EntityCollectionManager entityCollectionManager = entityCollectionManagerFactory.createCollectionManager( context ); assertNotNull( "A collection manager must be returned", entityCollectionManager ); }
@Test( expected = NullPointerException.class ) public void loadListParamEntityId() throws ConnectionException { logEntryStrategy .load( new ApplicationScopeImpl( new SimpleId( "organization" ) ), null, UUIDGenerator.newTimeUUID(), 1 ); }
@Test(expected = NullPointerException.class) public void deleteParamVersion() throws ConnectionException { serializationStrategy .delete( new ApplicationScopeImpl( new SimpleId( "organization" )), new SimpleId( "test" ), null ); }
@Test public void healthTest() { ApplicationScope context = new ApplicationScopeImpl( new SimpleId( "organization" ) ); final EntityCollectionManager manager = factory.createCollectionManager( context ); assertEquals( Health.GREEN, manager.getHealth() ); }
@Test(expected = IllegalArgumentException.class) public void loadListParamSize() throws ConnectionException { serializationStrategy.loadDescendingHistory( new ApplicationScopeImpl( new SimpleId( "organization" ) ), new SimpleId( "test" ), UUIDGenerator.newTimeUUID(), 0 ); }
@Test( expected = UnsupportedOperationException.class ) public void loadAscendingHistory() throws ConnectionException { final Id applicationId = new SimpleId( "application" ); final String name = "test"; ApplicationScope context = new ApplicationScopeImpl( applicationId ); final Id entityId = new SimpleId( UUIDGenerator.newTimeUUID(), name ); final UUID version1 = UUIDGenerator.newTimeUUID(); serializationStrategy.loadAscendingHistory( context, entityId, version1, 20 ); }
@Test public void testEntityType() { final ApplicationScopeImpl applicationScope = new ApplicationScopeImpl( new SimpleId( "application" ) ); final Id id = new SimpleId( "id" ); final String output = IndexingUtils.getType( applicationScope, id ); final String expected = "appId(" + applicationScope.getApplication().getUuid() + ",application).entityType(" + id.getType() + ")"; assertEquals( output, expected ); } }
@Test public void write() { ApplicationScope context = new ApplicationScopeImpl( new SimpleId( "organization" ) ); Entity newEntity = new Entity( new SimpleId( "test" ) ); EntityCollectionManager manager = factory.createCollectionManager( context ); Observable<Entity> observable = manager.write( newEntity, null ); Entity returned = observable.toBlocking().lastOrDefault( null ); assertNotNull( "Returned has a uuid", returned.getId() ); assertNotNull( "Version exists", returned.getVersion() ); }