@org.junit.Test public void Test() { idMgr = Test1083.getCommMgr().getIdManager(); privateId = idMgr.getThisNetworkNode(); assertNotNull(idMgr); assertNotNull(privateId); IndividualCtxEntity operator = null; try { operator = Test1083.ctxBroker.retrieveCssOperator().get(); LOG.info("[#1859] Id from broker is " + operator.getId().getOperatorId()); LOG.info("[#1859] Id directly from idMgr is " + privateId); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ExecutionException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (CtxException e) { // TODO Auto-generated catch block e.printStackTrace(); } assertNotNull(operator); assertEquals(operator.getId().getOperatorId(), privateId.getBareJid()); LOG.info( "[#1859] Using equals with getOperatorId() - " + operator.getId().getOperatorId().equals(privateId.getBareJid())); }
public RelevantCommunityAnalyser(IIdentity linkedEntity, String linkType) { if (linkType.equals("CSS")) this.linkedCss = linkedEntity; // else // this.linkedDomain = linkedEntity; proximityHistory = new ArrayList<ProximityRecord>(); recordedMetadata = new HashMap<String, String>(); refusals = new ArrayList<ICisProposal>(); try { List<CtxIdentifier> ctxMetadata = userContextBroker.lookup(CtxModelType.ATTRIBUTE, "hasCLM").get(); for (int i = 0; i < ctxMetadata.size(); i++) { CtxAttribute thisMetadata = (CtxAttribute) userContextBroker.retrieve(ctxMetadata.get(i)).get(); String thisMetadataValue = thisMetadata.getStringValue(); recordedMetadata.put( thisMetadataValue.split("---")[0].split("CIS ID: ")[1], thisMetadataValue.split("---")[1]); } } catch (InterruptedException e) { e.printStackTrace(); } catch (ExecutionException e) { e.printStackTrace(); } catch (CtxException e) { e.printStackTrace(); } catch (NullPointerException e) { e.printStackTrace(); } // new ProximityRecordingThread().start(); }
@Before public void setUp() { this.userId = new MyIdentity(IdentityType.CSS, "xcmanager", "societies.local"); CtxEntityIdentifier ctxId = new CtxEntityIdentifier(userId.getJid(), "Person", new Long(1)); this.userCtxEntity = new CtxEntity(ctxId); hasPrivacyPreferences = new CtxAssociation( new CtxAssociationIdentifier( userId.getJid(), CtxTypes.HAS_PRIVACY_PREFERENCES, new Long(3))); CtxEntityIdentifier preferenceEntityId_ppnp1 = new CtxEntityIdentifier(userId.getJid(), CtxTypes.PRIVACY_PREFERENCE, new Long(2)); this.privacyPreferenceEntity = new CtxEntity(preferenceEntityId_ppnp1); this.ppnp_1_CtxAttribute = new CtxAttribute( new CtxAttributeIdentifier( this.privacyPreferenceEntity.getId(), "ppnp_preference_1", new Long(5))); this.registryCtxAttribute = new CtxAttribute( new CtxAttributeIdentifier( userCtxEntity.getId(), CtxTypes.PRIVACY_PREFERENCE_REGISTRY, new Long(1))); Mockito.when(commsManager.getIdManager()).thenReturn(identityManager); privPrefMgr.setCtxBroker(ctxBroker); privPrefMgr.setCommsMgr(commsManager); privPrefMgr.setprivacyDataManagerInternal(privacyDataManager); privPrefMgr.setTrustBroker(trustBroker); privPrefMgr.setMyMessageBox(myMsgBox); try { Mockito.when(ctxBroker.lookup(CtxModelType.ATTRIBUTE, CtxTypes.PRIVACY_PREFERENCE_REGISTRY)) .thenReturn(new AsyncResult<List<CtxIdentifier>>(new ArrayList<CtxIdentifier>())); Mockito.when(ctxBroker.lookup(CtxModelType.ENTITY, CtxTypes.PRIVACY_PREFERENCE)) .thenReturn(new AsyncResult<List<CtxIdentifier>>(new ArrayList<CtxIdentifier>())); Mockito.when(ctxBroker.lookup(CtxModelType.ASSOCIATION, CtxTypes.HAS_PRIVACY_PREFERENCES)) .thenReturn(new AsyncResult<List<CtxIdentifier>>(new ArrayList<CtxIdentifier>())); IndividualCtxEntity weirdPerson = new IndividualCtxEntity(userCtxEntity.getId()); Mockito.when(ctxBroker.retrieveCssOperator()) .thenReturn(new AsyncResult<IndividualCtxEntity>(weirdPerson)); Mockito.when(ctxBroker.createAssociation(CtxTypes.HAS_PRIVACY_PREFERENCES)) .thenReturn(new AsyncResult<CtxAssociation>(this.hasPrivacyPreferences)); Mockito.when(ctxBroker.createEntity(CtxTypes.PRIVACY_PREFERENCE)) .thenReturn(new AsyncResult<CtxEntity>(privacyPreferenceEntity)); Mockito.when(ctxBroker.createAttribute(privacyPreferenceEntity.getId(), "ppnp_preference_1")) .thenReturn(new AsyncResult<CtxAttribute>(ppnp_1_CtxAttribute)); Mockito.when( ctxBroker.createAttribute( userCtxEntity.getId(), CtxTypes.PRIVACY_PREFERENCE_REGISTRY)) .thenReturn(new AsyncResult<CtxAttribute>(registryCtxAttribute)); Mockito.when( myMsgBox.showConfirmDialog( Mockito.anyString(), Mockito.anyString(), Mockito.eq(JOptionPane.YES_NO_OPTION))) .thenReturn(JOptionPane.YES_OPTION); Mockito.when( ctxBroker.updateAttribute( Mockito.eq(ppnp_1_CtxAttribute.getId()), (Serializable) Mockito.anyObject())) .thenReturn(new AsyncResult<CtxAttribute>(ppnp_1_CtxAttribute)); } catch (CtxException e) { // TODO Auto-generated catch block e.printStackTrace(); } privPrefMgr.initialisePrivacyPreferenceManager(); }