List of usage examples for java.util EnumSet allOf
public static <E extends Enum<E>> EnumSet<E> allOf(Class<E> elementType)
From source file:org.silverpeas.migration.jcr.service.repository.DocumentRepositoryTest.java
/** * Test of listAttachmentsByInstanceIdAndDocumentType method, of class DocumentRepository. *///from w w w . j ava 2 s .c o m @Test public void listAttachmentsByInstanceIdAndDocumentType() throws Exception { new JcrDocumentRepositoryTest() { @Override public void run(final Session session) throws Exception { Set<String> createdIds = new HashSet<String>(); // No WYSIWYG content exists List<String> wysiwygFIdLangFilenames = extractForeignIdLanguageFilenames(getDocumentRepository() .listAttachmentsByInstanceIdAndDocumentType(session, instanceId, wysiwyg)); assertThat(wysiwygFIdLangFilenames, notNullValue()); assertThat(wysiwygFIdLangFilenames, hasSize(0)); // Creating an FR "attachment" content. String createdUuid = createAttachmentForTest( defaultDocumentBuilder("fId_1").setDocumentType(attachment), defaultFRContentBuilder(), "fId_1_fr").getId(); createdIds.add(createdUuid); SimpleDocument enDocument = getDocumentById(createdUuid, "en"); assertThat(enDocument, notNullValue()); assertThat(enDocument.getAttachment(), nullValue()); SimpleDocument frDocument = getDocumentById(createdUuid, "fr"); assertThat(frDocument, notNullValue()); assertThat(frDocument.getAttachment(), notNullValue()); assertThat(frDocument.getDocumentType(), is(attachment)); wysiwygFIdLangFilenames = extractForeignIdLanguageFilenames(getDocumentRepository() .listAttachmentsByInstanceIdAndDocumentType(session, instanceId, attachment)); assertThat(wysiwygFIdLangFilenames, hasSize(1)); assertThat(wysiwygFIdLangFilenames, contains("fId_1|fr|test.odp")); // Updating attachment with EN content. setEnData(frDocument); updateAttachmentForTest(frDocument, "en", "fId_1_en"); createdIds.add(frDocument.getId()); // Vrifying the attachment exists into both of tested languages. enDocument = getDocumentById(createdUuid, "en"); assertThat(enDocument, notNullValue()); assertThat(enDocument.getAttachment(), notNullValue()); assertThat(enDocument.getDocumentType(), is(attachment)); checkEnglishSimpleDocument(enDocument); frDocument = getDocumentById(createdUuid, "fr"); assertThat(frDocument, notNullValue()); assertThat(frDocument.getAttachment(), notNullValue()); assertThat(frDocument.getDocumentType(), is(attachment)); checkFrenchSimpleDocument(frDocument); // No WYSIWYG : that is what it is expected wysiwygFIdLangFilenames = extractForeignIdLanguageFilenames(getDocumentRepository() .listAttachmentsByInstanceIdAndDocumentType(session, instanceId, wysiwyg)); assertThat(wysiwygFIdLangFilenames, hasSize(0)); wysiwygFIdLangFilenames = extractForeignIdLanguageFilenames(getDocumentRepository() .listAttachmentsByInstanceIdAndDocumentType(session, instanceId, attachment)); assertThat(wysiwygFIdLangFilenames, hasSize(2)); assertThat(wysiwygFIdLangFilenames, containsInAnyOrder("fId_1|fr|test.odp", "fId_1|en|test.odp")); // Adding several documents, but no WYSIWYG Set<DocumentType> documentTypes = EnumSet.allOf(DocumentType.class); documentTypes.remove(DocumentType.wysiwyg); int id = 2; for (DocumentType documentType : documentTypes) { createdIds.add(createAttachmentForTest( defaultDocumentBuilder("fId_" + id).setDocumentType(documentType), defaultFRContentBuilder().setFilename("fId_" + id + "_wysiwyg_en.txt"), "fId_" + id + "_fr").getId()); id++; } // No WYSIWYG : that is what it is expected wysiwygFIdLangFilenames = extractForeignIdLanguageFilenames(getDocumentRepository() .listAttachmentsByInstanceIdAndDocumentType(session, instanceId, wysiwyg)); assertThat(wysiwygFIdLangFilenames, hasSize(0)); // Number of expected created documents int nbDocuments = 1 + (DocumentType.values().length - 1); assertThat(createdIds.size(), is(nbDocuments)); // Adding the first WYSIWYG EN content SimpleDocument createdDocument = createAttachmentForTest( defaultDocumentBuilder("fId_26").setDocumentType(wysiwyg), defaultENContentBuilder(), "fId_26_en"); createdIds.add(createdDocument.getId()); // One wrong WYSIWYG base name wysiwygFIdLangFilenames = extractForeignIdLanguageFilenames(getDocumentRepository() .listAttachmentsByInstanceIdAndDocumentType(session, instanceId, wysiwyg)); assertThat(wysiwygFIdLangFilenames, hasSize(1)); assertThat(wysiwygFIdLangFilenames, contains("fId_26|en|test.pdf")); // Updating wysiwyg file name createdDocument.setFilename("fId_26_wysiwyg_en.txt"); updateAttachmentForTest(createdDocument); // One WYSIWYG base name wysiwygFIdLangFilenames = extractForeignIdLanguageFilenames(getDocumentRepository() .listAttachmentsByInstanceIdAndDocumentType(session, instanceId, wysiwyg)); assertThat(wysiwygFIdLangFilenames, hasSize(1)); assertThat(wysiwygFIdLangFilenames, contains("fId_26|en|fId_26_wysiwyg_en.txt")); // Adding the FR content to the first WYSIWYG document enDocument = getDocumentById(createdDocument.getId(), "en"); setFrData(enDocument); enDocument.setFilename("fId_26_wysiwyg_fr.txt"); updateAttachmentForTest(enDocument, "fr", "fId_26_fr"); createdIds.add(enDocument.getId()); // One WYSIWYG on one Component wysiwygFIdLangFilenames = extractForeignIdLanguageFilenames(getDocumentRepository() .listAttachmentsByInstanceIdAndDocumentType(session, instanceId, wysiwyg)); assertThat(wysiwygFIdLangFilenames, hasSize(2)); assertThat(wysiwygFIdLangFilenames, containsInAnyOrder("fId_26|fr|fId_26_wysiwyg_fr.txt", "fId_26|en|fId_26_wysiwyg_en.txt")); // Adding the second WYSIWYG document (on same component) SimpleDocument secondCreatedDocument = createAttachmentForTest( defaultDocumentBuilder("fId_27").setDocumentType(wysiwyg), defaultFRContentBuilder().setFilename("fId_27_wysiwyg_fr.txt"), "fId_27_fr"); createdIds.add(secondCreatedDocument.getId()); // Two WYSIWYG on one Component wysiwygFIdLangFilenames = extractForeignIdLanguageFilenames(getDocumentRepository() .listAttachmentsByInstanceIdAndDocumentType(session, instanceId, wysiwyg)); assertThat(wysiwygFIdLangFilenames, hasSize(3)); assertThat(wysiwygFIdLangFilenames, containsInAnyOrder("fId_26|fr|fId_26_wysiwyg_fr.txt", "fId_26|en|fId_26_wysiwyg_en.txt", "fId_27|fr|fId_27_wysiwyg_fr.txt")); // Updating wysiwyg file name setEnData(secondCreatedDocument); secondCreatedDocument.setFilename(secondCreatedDocument.getFilename()); updateAttachmentForTest(secondCreatedDocument, "en", "fId_27_en"); // Two WYSIWYG (each one in two languages) on one Component wysiwygFIdLangFilenames = extractForeignIdLanguageFilenames(getDocumentRepository() .listAttachmentsByInstanceIdAndDocumentType(session, instanceId, wysiwyg)); assertThat(wysiwygFIdLangFilenames, hasSize(4)); assertThat(wysiwygFIdLangFilenames, containsInAnyOrder("fId_26|fr|fId_26_wysiwyg_fr.txt", "fId_26|en|fId_26_wysiwyg_en.txt", "fId_27|fr|fId_27_wysiwyg_fr.txt", "fId_27|en|fId_27_wysiwyg_fr.txt")); assertThat(createdIds, hasSize(nbDocuments + 2)); } }.execute(); }
From source file:org.apache.accumulo.test.proxy.SimpleProxyBase.java
@Test public void attachIteratorsWithScans() throws Exception { if (client.tableExists(creds, "slow")) { client.deleteTable(creds, "slow"); }//ww w. j a va2s . c o m // create a table that's very slow, so we can look for scans client.createTable(creds, "slow", true, TimeType.MILLIS); IteratorSetting setting = new IteratorSetting(100, "slow", SlowIterator.class.getName(), Collections.singletonMap("sleepTime", "250")); client.attachIterator(creds, "slow", setting, EnumSet.allOf(IteratorScope.class)); // Should take 10 seconds to read every record for (int i = 0; i < 40; i++) { client.updateAndFlush(creds, "slow", mutation("row" + i, "cf", "cq", "value")); } // scan Thread t = new Thread() { @Override public void run() { String scanner; TestProxyClient proxyClient2 = null; try { if (isKerberosEnabled()) { UserGroupInformation.loginUserFromKeytab(clientPrincipal, clientKeytab.getAbsolutePath()); proxyClient2 = new TestProxyClient(hostname, proxyPort, factory, proxyPrimary, UserGroupInformation.getCurrentUser()); } else { proxyClient2 = new TestProxyClient(hostname, proxyPort, factory); } Client client2 = proxyClient2.proxy(); scanner = client2.createScanner(creds, "slow", null); client2.nextK(scanner, 10); client2.closeScanner(scanner); } catch (Exception e) { throw new RuntimeException(e); } finally { if (null != proxyClient2) { proxyClient2.close(); } } } }; t.start(); // look for the scan many times List<ActiveScan> scans = new ArrayList<ActiveScan>(); for (int i = 0; i < 100 && scans.isEmpty(); i++) { for (String tserver : client.getTabletServers(creds)) { List<ActiveScan> scansForServer = client.getActiveScans(creds, tserver); for (ActiveScan scan : scansForServer) { if (clientPrincipal.equals(scan.getUser())) { scans.add(scan); } } if (!scans.isEmpty()) break; sleepUninterruptibly(100, TimeUnit.MILLISECONDS); } } t.join(); assertFalse("Expected to find scans, but found none", scans.isEmpty()); boolean found = false; Map<String, String> map = null; for (int i = 0; i < scans.size() && !found; i++) { ActiveScan scan = scans.get(i); if (clientPrincipal.equals(scan.getUser())) { assertTrue(ScanState.RUNNING.equals(scan.getState()) || ScanState.QUEUED.equals(scan.getState())); assertEquals(ScanType.SINGLE, scan.getType()); assertEquals("slow", scan.getTable()); map = client.tableIdMap(creds); assertEquals(map.get("slow"), scan.getExtent().tableId); assertTrue(scan.getExtent().endRow == null); assertTrue(scan.getExtent().prevEndRow == null); found = true; } } assertTrue("Could not find a scan against the 'slow' table", found); }
From source file:org.spongepowered.common.mixin.core.world.MixinWorld.java
/** * @author bloodmc - November 15th, 2015 * * @reason Rewritten to pass the source block position. *//*w w w. j a va 2s.co m*/ @SuppressWarnings("rawtypes") @Overwrite public void notifyNeighborsOfStateExcept(BlockPos pos, Block blockType, EnumFacing skipSide) { if (this.isRemote || !isValid(pos)) { return; } EnumSet directions = EnumSet.allOf(EnumFacing.class); directions.remove(skipSide); final CauseTracker causeTracker = this.getCauseTracker(); if (!causeTracker.isCapturingBlocks()) { for (Object obj : directions) { EnumFacing facing = (EnumFacing) obj; causeTracker.notifyBlockOfStateChange(pos.offset(facing), blockType, pos); } return; } NotifyNeighborBlockEvent event = SpongeCommonEventFactory.callNotifyNeighborEvent(this, pos, directions); if (event.isCancelled()) { return; } for (EnumFacing facing : EnumFacing.values()) { if (event.getNeighbors().keySet() .contains(DirectionFacingProvider.getInstance().getKey(facing).get())) { causeTracker.notifyBlockOfStateChange(pos.offset(facing), blockType, pos); } } }
From source file:org.apache.accumulo.test.proxy.SimpleProxyBase.java
@Test public void attachIteratorWithCompactions() throws Exception { if (client.tableExists(creds, "slow")) { client.deleteTable(creds, "slow"); }/*from www.ja v a 2 s.com*/ // create a table that's very slow, so we can look for compactions client.createTable(creds, "slow", true, TimeType.MILLIS); IteratorSetting setting = new IteratorSetting(100, "slow", SlowIterator.class.getName(), Collections.singletonMap("sleepTime", "250")); client.attachIterator(creds, "slow", setting, EnumSet.allOf(IteratorScope.class)); // Should take 10 seconds to read every record for (int i = 0; i < 40; i++) { client.updateAndFlush(creds, "slow", mutation("row" + i, "cf", "cq", "value")); } Map<String, String> map = client.tableIdMap(creds); // start a compaction Thread t = new Thread() { @Override public void run() { TestProxyClient proxyClient2 = null; try { if (isKerberosEnabled()) { UserGroupInformation.loginUserFromKeytab(clientPrincipal, clientKeytab.getAbsolutePath()); proxyClient2 = new TestProxyClient(hostname, proxyPort, factory, proxyPrimary, UserGroupInformation.getCurrentUser()); } else { proxyClient2 = new TestProxyClient(hostname, proxyPort, factory); } Client client2 = proxyClient2.proxy(); client2.compactTable(creds, "slow", null, null, null, true, true, null); } catch (Exception e) { throw new RuntimeException(e); } finally { if (null != proxyClient2) { proxyClient2.close(); } } } }; t.start(); final String desiredTableId = map.get("slow"); // Make sure we can find the slow table assertNotNull(desiredTableId); // try to catch it in the act List<ActiveCompaction> compactions = new ArrayList<ActiveCompaction>(); for (int i = 0; i < 100 && compactions.isEmpty(); i++) { // Iterate over the tservers for (String tserver : client.getTabletServers(creds)) { // And get the compactions on each List<ActiveCompaction> compactionsOnServer = client.getActiveCompactions(creds, tserver); for (ActiveCompaction compact : compactionsOnServer) { // There might be other compactions occurring (e.g. on METADATA) in which // case we want to prune out those that aren't for our slow table if (desiredTableId.equals(compact.getExtent().tableId)) { compactions.add(compact); } } // If we found a compaction for the table we wanted, so we can stop looking if (!compactions.isEmpty()) break; } sleepUninterruptibly(10, TimeUnit.MILLISECONDS); } t.join(); // verify the compaction information assertFalse(compactions.isEmpty()); for (ActiveCompaction c : compactions) { if (desiredTableId.equals(c.getExtent().tableId)) { assertTrue(c.inputFiles.isEmpty()); assertEquals(CompactionType.MINOR, c.getType()); assertEquals(CompactionReason.USER, c.getReason()); assertEquals("", c.localityGroup); assertTrue(c.outputFile.contains("default_tablet")); return; } } fail("Expection to find running compaction for table 'slow' but did not find one"); }
From source file:org.kuali.kfs.module.tem.document.TravelDocumentBase.java
/** * @see org.kuali.kfs.module.tem.document.TravelDocument#getNonReimbursableTotal() *//*www. j ava 2 s . co m*/ @Override public KualiDecimal getNonReimbursableTotal() { KualiDecimal total = KualiDecimal.ZERO; for (ExpenseType expense : EnumSet.allOf(ExpenseType.class)) { total = getTravelExpenseService().getExpenseServiceByType(expense).getNonReimbursableExpenseTotal(this) .add(total); } return total; }
From source file:org.kuali.kfs.module.tem.document.TravelDocumentBase.java
/** * This method returns total expense amount minus the non-reimbursable * * @return// ww w. jav a 2s. com */ @Override public KualiDecimal getApprovedAmount() { KualiDecimal total = KualiDecimal.ZERO; for (ExpenseType expense : EnumSet.allOf(ExpenseType.class)) { total = getTravelExpenseService().getExpenseServiceByType(expense).getAllExpenseTotal(this, false) .add(total); } return total; }
From source file:org.apache.solr.handler.component.StatsComponentTest.java
public void testIndividualStatLocalParams() throws Exception { final String kpre = ExpectedStat.KPRE; assertU(adoc("id", "1", "a_f", "2.3", "b_f", "9.7", "a_i", "9", "foo_t", "how now brown cow")); assertU(commit());//from www . j ava 2s .com SolrCore core = h.getCore(); SchemaField field = core.getLatestSchema().getField("a_i"); HllOptions hllOpts = HllOptions.parseHllOptions(params("cardinality", "true"), field); HLL hll = hllOpts.newHLL(); HashFunction hasher = hllOpts.getHasher(); AVLTreeDigest tdigest = new AVLTreeDigest(100); // some quick sanity check assertions... // trivial check that we only get the exact 2 we ask for assertQ("ask for and get only 2 stats", req("q", "*:*", "stats", "true", "stats.field", "{!key=k mean=true min=true}a_i"), kpre + "double[@name='mean'][.='9.0']", kpre + "double[@name='min'][.='9.0']", "count(" + kpre + "*)=2"); // for stats that are true/false, sanity check false does it's job assertQ("min=true & max=false: only min should come back", req("q", "*:*", "stats", "true", "stats.field", "{!key=k max=false min=true}a_i"), kpre + "double[@name='min'][.='9.0']", "count(" + kpre + "*)=1"); assertQ("min=false: localparam stat means ignore default set, " + "but since only local param is false no stats should be returned", req("q", "*:*", "stats", "true", "stats.field", "{!key=k min=false}a_i") // section of stats for this field should exist ... , XPRE + "lst[@name='stats_fields']/lst[@name='k']" // ...but be empty , "count(" + kpre + "*)=0"); double sum = 0; double sumOfSquares = 0; final int count = 20; for (int i = 0; i < count; i++) { int a_i = i % 10; assertU(adoc("id", String.valueOf(i), "a_f", "2.3", "b_f", "9.7", "a_i", String.valueOf(a_i), "foo_t", "how now brown cow")); tdigest.add(a_i); hll.addRaw(hasher.hashInt(a_i).asLong()); sum += a_i; sumOfSquares += (a_i) * (a_i); } double stddev = Math.sqrt(((count * sumOfSquares) - (sum * sum)) / (20 * (count - 1.0D))); assertU(commit()); ByteBuffer tdigestBuf = ByteBuffer.allocate(tdigest.smallByteSize()); tdigest.asSmallBytes(tdigestBuf); byte[] hllBytes = hll.toBytes(); EnumSet<Stat> allStats = EnumSet.allOf(Stat.class); final List<ExpectedStat> expected = new ArrayList<ExpectedStat>(allStats.size()); ExpectedStat.createSimple(Stat.min, "true", "double", "0.0"); ExpectedStat.createSimple(Stat.max, "true", "double", "9.0"); ExpectedStat.createSimple(Stat.missing, "true", "long", "0"); ExpectedStat.createSimple(Stat.sum, "true", "double", String.valueOf(sum)); ExpectedStat.createSimple(Stat.count, "true", "long", String.valueOf(count)); ExpectedStat.createSimple(Stat.mean, "true", "double", String.valueOf(sum / count)); ExpectedStat.createSimple(Stat.sumOfSquares, "true", "double", String.valueOf(sumOfSquares)); ExpectedStat.createSimple(Stat.stddev, "true", "double", String.valueOf(stddev)); final String distinctValsXpath = "count(" + kpre + "arr[@name='distinctValues']/*)=10"; ExpectedStat.create(Stat.distinctValues, "true", Collections.singletonList(distinctValsXpath), Collections.singletonList(distinctValsXpath)); ExpectedStat.createSimple(Stat.countDistinct, "true", "long", "10"); final String percentileShardXpath = kpre + "str[@name='percentiles'][.='" + Base64.byteArrayToBase64(tdigestBuf.array(), 0, tdigestBuf.array().length) + "']"; final String p90 = "" + tdigest.quantile(0.90D); final String p99 = "" + tdigest.quantile(0.99D); ExpectedStat.create(Stat.percentiles, "'90, 99'", Collections.singletonList(percentileShardXpath), Arrays.asList("count(" + kpre + "lst[@name='percentiles']/*)=2", kpre + "lst[@name='percentiles']/double[@name='90.0'][.=" + p90 + "]", kpre + "lst[@name='percentiles']/double[@name='99.0'][.=" + p99 + "]")); final String cardinalityShardXpath = kpre + "str[@name='cardinality'][.='" + Base64.byteArrayToBase64(hllBytes, 0, hllBytes.length) + "']"; final String cardinalityXpath = kpre + "long[@name='cardinality'][.='10']"; ExpectedStat.create(Stat.cardinality, "true", Collections.singletonList(cardinalityShardXpath), Collections.singletonList(cardinalityXpath)); // canary in the coal mine assertEquals("num of ExpectedStat doesn't match all known stats; " + "enum was updated w/o updating test?", ExpectedStat.ALL.size(), allStats.size()); // whitebox test: explicitly ask for isShard=true with each individual stat for (ExpectedStat expect : ExpectedStat.ALL.values()) { Stat stat = expect.stat; StringBuilder exclude = new StringBuilder(); List<String> testXpaths = new ArrayList<String>(5 + expect.perShardXpaths.size()); testXpaths.addAll(expect.perShardXpaths); int numKeysExpected = 0; EnumSet<Stat> distribDeps = stat.getDistribDeps(); for (Stat perShardDep : distribDeps) { numKeysExpected++; // even if we go out of our way to exclude the dependent stats, // the shard should return them since they are a dependency for the requested stat if (!stat.equals(perShardDep)) { // NOTE: this only works because all the cases where there are distribDeps // beyond a self dependency are simple true/false options exclude.append(perShardDep + "=false "); } } // we don't want to find anything we aren't expecting testXpaths.add("count(" + kpre + "*)=" + numKeysExpected); assertQ("ask for only " + stat + ", with isShard=true, and expect only deps: " + distribDeps, req("q", "*:*", "isShard", "true", "stats", "true", "stats.field", "{!key=k " + exclude + stat + "=" + expect.input + "}a_i"), testXpaths.toArray(new String[testXpaths.size()])); } // test all the possible combinations (of all possible sizes) of stats params for (int numParams = 1; numParams <= allStats.size(); numParams++) { for (EnumSet<Stat> set : new StatSetCombinations(numParams, allStats)) { // EnumSets use natural ordering, we want to randomize the order of the params List<Stat> combo = new ArrayList<Stat>(set); Collections.shuffle(combo, random()); StringBuilder paras = new StringBuilder("{!key=k "); List<String> testXpaths = new ArrayList<String>(numParams + 5); int numKeysExpected = 0; for (Stat stat : combo) { ExpectedStat expect = ExpectedStat.ALL.get(stat); paras.append(stat + "=" + expect.input + " "); numKeysExpected++; testXpaths.addAll(expect.finalXpaths); } paras.append("}a_i"); // we don't want to find anything we aren't expecting testXpaths.add("count(" + kpre + "*)=" + numKeysExpected); assertQ("ask for and get only: " + combo, req("q", "*:*", "stats", "true", "stats.field", paras.toString()), testXpaths.toArray(new String[testXpaths.size()])); } } }
From source file:org.apache.hadoop.yarn.server.resourcemanager.TestClientRMService.java
@Test public void testRMStartWithDecommissionedNode() throws Exception { String excludeFile = "excludeFile"; createExcludeFile(excludeFile);/*from w w w . jav a 2s. com*/ YarnConfiguration conf = new YarnConfiguration(); conf.set(YarnConfiguration.RM_NODES_EXCLUDE_FILE_PATH, excludeFile); MockRM rm = new MockRM(conf) { protected ClientRMService createClientRMService() { return new ClientRMService(this.rmContext, scheduler, this.rmAppManager, this.applicationACLsManager, this.queueACLsManager, this.getRMContext().getRMDelegationTokenSecretManager()); } ; }; rm.start(); YarnRPC rpc = YarnRPC.create(conf); InetSocketAddress rmAddress = rm.getClientRMService().getBindAddress(); LOG.info("Connecting to ResourceManager at " + rmAddress); ApplicationClientProtocol client = (ApplicationClientProtocol) rpc.getProxy(ApplicationClientProtocol.class, rmAddress, conf); // Make call GetClusterNodesRequest request = GetClusterNodesRequest.newInstance(EnumSet.allOf(NodeState.class)); List<NodeReport> nodeReports = client.getClusterNodes(request).getNodeReports(); Assert.assertEquals(1, nodeReports.size()); rm.stop(); rpc.stopProxy(client, conf); new File(excludeFile).delete(); }
From source file:org.apache.accumulo.test.proxy.SimpleProxyBase.java
@Test public void iteratorFunctionality() throws Exception { // iterators//from w ww . ja v a2 s . com HashMap<String, String> options = new HashMap<String, String>(); options.put("type", "STRING"); options.put("columns", "cf"); IteratorSetting setting = new IteratorSetting(10, tableName, SummingCombiner.class.getName(), options); client.attachIterator(creds, tableName, setting, EnumSet.allOf(IteratorScope.class)); for (int i = 0; i < 10; i++) { client.updateAndFlush(creds, tableName, mutation("row1", "cf", "cq", "1")); } // 10 updates of "1" in the value w/ SummingCombiner should return value of "10" assertScan(new String[][] { { "row1", "cf", "cq", "10" } }, tableName); try { client.checkIteratorConflicts(creds, tableName, setting, EnumSet.allOf(IteratorScope.class)); fail("checkIteratorConflicts did not throw an exception"); } catch (Exception ex) { // Expected } client.deleteRows(creds, tableName, null, null); client.removeIterator(creds, tableName, "test", EnumSet.allOf(IteratorScope.class)); String expected[][] = new String[10][]; for (int i = 0; i < 10; i++) { client.updateAndFlush(creds, tableName, mutation("row" + i, "cf", "cq", "" + i)); expected[i] = new String[] { "row" + i, "cf", "cq", "" + i }; client.flushTable(creds, tableName, null, null, true); } assertScan(expected, tableName); }
From source file:com.vmware.identity.idm.server.config.directory.DirectoryConfigStore.java
private boolean validateExternalProviderNameConflict(String tenantName, IIdentityStoreData idsDataToAdd) throws Exception { Collection<IIdentityStoreData> providers = getProviders(tenantName, EnumSet.allOf(DomainType.class), true); // check with existing name/alias from existing providers for (IIdentityStoreData provider : providers) { String providerName = provider.getName(); assert (null != providerName); if (isDomainNameSame(idsDataToAdd, providerName) || isDomainAliasSame(idsDataToAdd, providerName)) { return false; }//from w w w . j ava2 s .c o m String providerAlias = provider.getExtendedIdentityStoreData().getAlias(); if (providerAlias != null && ((isDomainNameSame(idsDataToAdd, providerAlias)) || (isDomainAliasSame(idsDataToAdd, providerAlias)))) { return false; } } return true; }