/** * Get the application scope from the given uuid * * @param applicationId The applicationId */ public static ApplicationScope getApplicationScope( UUID applicationId ) { // We can always generate a scope, it doesn't matter if the application exists yet or not. return new ApplicationScopeImpl( generateApplicationId( applicationId ) ); }
@Test public void correctValues() { final SimpleId ownerId = new SimpleId( "test" ); ApplicationScopeImpl context = new ApplicationScopeImpl(ownerId ); assertEquals( ownerId, context.getApplication() ); }
@Test( expected = NullPointerException.class ) public void orgIdrequired() { new ApplicationScopeImpl( null); }
@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 ); } }
@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" ) ); }
@Test public void testCreateContextName() throws Exception { final ApplicationScopeImpl applicationScope = new ApplicationScopeImpl( new SimpleId( "application" ) ); final SearchEdgeImpl searchEdge = new SearchEdgeImpl( new SimpleId( "source" ), "users", SearchEdge.NodeType.TARGET ); final String output = IndexingUtils.createContextName( applicationScope, searchEdge ); final String expected = "appId(" + applicationScope.getApplication().getUuid() + ",application).nodeId(" + searchEdge.getNodeId() .getUuid() + "," + searchEdge.getNodeId().getType() + ").edgeName(users)"; assertEquals( output, expected ); }
@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(); }
@Test public void testAppIdFromDocumentId() { final ApplicationScopeImpl applicationScope = new ApplicationScopeImpl( new SimpleId( "application" ) ); final Id id = new SimpleId( "id" ); final UUID version = UUIDGenerator.newTimeUUID(); final SearchEdgeImpl searchEdge = new SearchEdgeImpl( new SimpleId( "source" ), "users", SearchEdge.NodeType.TARGET ); final String output = IndexingUtils.createIndexDocId( applicationScope, id, version, searchEdge ); final String expected = "appId(" + applicationScope.getApplication().getUuid() + ",application).entityId(" + id.getUuid() + "," + id .getType() + ").version(" + version + ").nodeId(" + searchEdge.getNodeId().getUuid() + "," + searchEdge .getNodeId().getType() + ").edgeName(users).nodeType(TARGET)"; assertEquals( output, expected ); //now parse it final CandidateResult parsedId = parseIndexDocId( output ); assertEquals(version, parsedId.getVersion()); assertEquals(id, parsedId.getId()); final UUID appId = parseAppIdFromIndexDocId(output); assertEquals(appId,applicationScope.getApplication().getUuid()); }
@Before public void before(){ appId = new SimpleId(UUID.randomUUID(), "application" ); IndexLocationStrategy strategy = new TestIndexIdentifier(cassandraFig,fig,new ApplicationScopeImpl(appId)); entityIndex = eif.createEntityIndex( strategy ); }
@Test public void testDocumentIdPipes() { final ApplicationScopeImpl applicationScope = new ApplicationScopeImpl( new SimpleId( "application" ) ); final Id id = new SimpleId( "id" ); final UUID version = UUIDGenerator.newTimeUUID(); final SearchEdgeImpl searchEdge = new SearchEdgeImpl( new SimpleId( "source" ), "zzzcollzzz|users", SearchEdge.NodeType.TARGET ); final String output = IndexingUtils.createIndexDocId( applicationScope, id, version, searchEdge ); final String expected = "appId(" + applicationScope.getApplication().getUuid() + ",application).entityId(" + id.getUuid() + "," + id .getType() + ").version(" + version + ").nodeId(" + searchEdge.getNodeId().getUuid() + "," + searchEdge .getNodeId().getType() + ").edgeName(zzzcollzzz|users).nodeType(TARGET)"; assertEquals( output, expected ); //now parse it final CandidateResult parsedId = parseIndexDocId( output ); assertEquals(version, parsedId.getVersion()); assertEquals(id, parsedId.getId()); }
@Before public void setup(){ appId = new SimpleId(UUID.randomUUID(), "application" ); IndexLocationStrategy strategy = new TestIndexIdentifier(cassandraFig,fig,new ApplicationScopeImpl(appId)); entityIndex = eif.createEntityIndex( strategy ); }
@Test public void testDocumentId() { final ApplicationScopeImpl applicationScope = new ApplicationScopeImpl( new SimpleId( "application" ) ); final Id id = new SimpleId( "id" ); final UUID version = UUIDGenerator.newTimeUUID(); final SearchEdgeImpl searchEdge = new SearchEdgeImpl( new SimpleId( "source" ), "users", SearchEdge.NodeType.TARGET ); final String output = IndexingUtils.createIndexDocId( applicationScope, id, version, searchEdge ); final String expected = "appId(" + applicationScope.getApplication().getUuid() + ",application).entityId(" + id.getUuid() + "," + id .getType() + ").version(" + version + ").nodeId(" + searchEdge.getNodeId().getUuid() + "," + searchEdge .getNodeId().getType() + ").edgeName(users).nodeType(TARGET)"; assertEquals( output, expected ); //now parse it final CandidateResult parsedId = parseIndexDocId( output ); assertEquals(version, parsedId.getVersion()); assertEquals(id, parsedId.getId()); }
@Before public void setup(){ appId = new SimpleId(UUID.randomUUID(), "application" ); IndexLocationStrategy strategy =new TestIndexIdentifier(cassandraFig,fig,new ApplicationScopeImpl(appId)); entityIndex = eif.createEntityIndex( strategy ); }
/** * Fetch our application id */ private UUID fetchApplicationId( final String applicationName ) { UUID value = null; EntityCollectionManager ecm = managerCache.getEntityCollectionManager( new ApplicationScopeImpl( new SimpleId( CpNamingUtils.MANAGEMENT_APPLICATION_ID, Schema.TYPE_APPLICATION ) ) ); try { if ( managementEnityManager.getApplication() == null ) { return null; } } catch ( Exception e ) { logger.error("Error looking up management app", e); } // look up application_info ID for application using unique "name" field final Observable<Id> idObs = ecm.getIdField( CpNamingUtils.APPLICATION_INFO, new StringField(Schema.PROPERTY_NAME, applicationName)); Id id = idObs.toBlocking().lastOrDefault(null); if ( id != null ) { value = id.getUuid(); } else { if (logger.isDebugEnabled()) { logger.debug( "Could not load value for key {} ", applicationName ); } } return value; }
@Before public void setup() { this.scope = new ApplicationScopeImpl( createId( "application" ) ); }
@Before public void mockApp() { this.scope = new ApplicationScopeImpl( createId( "application" ) ); }
@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 loadParamVersion() throws ConnectionException { logEntryStrategy.load( new ApplicationScopeImpl( new SimpleId( "organization" ) ), Collections.<Id>singleton( new SimpleId( "test" ) ), null ); }
@Test(expected = NullPointerException.class) public void loadParamVersion() throws ConnectionException { serializationStrategy .load( new ApplicationScopeImpl(new SimpleId( "organization" ) ), Collections.<Id>singleton( new SimpleId( "test" )), null ); }