@SuppressWarnings("deprecation") // TODO #11 kill uses of deprecations @Test public void insertNewForIntern() { SoaActivationDocument internOld = this.insertAndGet("intern"); SoaActivationDocument externOld = this.insertAndGet("extern"); SoaActivationDocument internNew = this.insertAndGet("intern"); new TermsOfUseResolver(TeztBeanSimpleFactory.getAdmin()).deactivateAgreementsFor(internNew); List<SoaActivationDocument> all_sads = FamDaoProxy.soaDao().getAllSoaActivation(); assertTrue(all_sads.size() >= 3); boolean[] foundAll = {false, false, false}; for (SoaActivationDocument sad : all_sads) { if (sad.getId().equals(internOld.getId())) { // intern is still active foundAll[0] = true; assertFalse(sad.isActive()); assertTrue(sad.getDeactivatedOn() > sad.getActivatedOn()); } if (sad.getId().equals(externOld.getId())) { // extern is not active anymore foundAll[1] = true; assertTrue(sad.isActive()); } if (sad.getId().equals(internNew.getId())) { // new one is active foundAll[2] = true; assertTrue(sad.isActive()); } } // found everything assertTrue(foundAll[0]); assertTrue(foundAll[1]); assertTrue(foundAll[2]); }
public List<SoaActivationPageDocument> getSoasForUser(User user) { // TODO #13 do not use FamCouchDBDao#getAll List<SoaActivationDocument> soas = this.getAllSoaActivation(); List<SoaActivationPageDocument> result = null; for (SoaActivationDocument soa : soas) { if (soa.isActive() && soa.getRoleId().equals(user.getRoleId())) { result = soa.getSoaActivePages(); break; } } return result; }
/** {@inheritDoc}} */ @Override public List<SoaActivationDocument> getSoaActivationDocumentsForDeactivation( SoaActivationDocument newSoaActivationDocument) { // TODO #13 do not use FamCouchDBDao#getAll List<SoaActivationDocument> result = new ArrayList<SoaActivationDocument>(); List<SoaActivationDocument> all_sads = this.getAllSoaActivation(); for (SoaActivationDocument sad : all_sads) { if (sad.getRoleId().equals(newSoaActivationDocument.getRoleId())) { if (sad.isActive() && !sad.getId().equals(newSoaActivationDocument.getId())) { result.add(sad); } } } return result; }