List of usage examples for java.util HashSet add
public boolean add(E e)
From source file:keywhiz.service.resources.admin.SecretsResourceTest.java
@Test public void canDelete() { when(secretController.getSecretById(0xdeadbeef)).thenReturn(Optional.of(secret)); HashSet<Group> groups = new HashSet<>(); groups.add(new Group(0, "group1", "", NOW, null, NOW, null, null)); groups.add(new Group(0, "group2", "", NOW, null, NOW, null, null)); when(aclDAO.getGroupsFor(secret)).thenReturn(groups); Response response = resource.deleteSecret(user, new LongParam(Long.toString(0xdeadbeef))); verify(secretDAO).deleteSecretsByName("name"); assertThat(response.getStatus()).isEqualTo(204); }
From source file:index.partition.ZCurvePartitioner.java
public Set<Integer> overlapPartitions(GeoLocation[] boundaries) { HashSet<Integer> matchedGrpIds = new HashSet<Integer>(); int groupId0 = overlapPartition(boundaries[0].getLatitudeInDegrees(), boundaries[0].getLongitudeInDegrees()); matchedGrpIds.add(groupId0); int groupId1 = overlapPartition(boundaries[0].getLatitudeInDegrees(), boundaries[1].getLongitudeInDegrees()); matchedGrpIds.add(groupId1);//from www .j av a 2s. c o m int groupId2 = overlapPartition(boundaries[1].getLatitudeInDegrees(), boundaries[0].getLongitudeInDegrees()); matchedGrpIds.add(groupId2); int groupId3 = overlapPartition(boundaries[1].getLatitudeInDegrees(), boundaries[1].getLongitudeInDegrees()); matchedGrpIds.add(groupId3); return matchedGrpIds; }
From source file:com.fredhopper.connector.config.DefaultIndexConfigService.java
private HashSet<Locale> getLocales(final FredhopperIndexConfigModel indexConfigModel) { final Collection<String> localesList = indexConfigModel.getLocales(); final HashSet<Locale> locales = new HashSet<>(); for (final String localeString : localesList) { final String[] loc = Utilities.parseLocaleCodes(localeString); final Locale locale = new Locale(loc[0], loc[1], loc[2]); locales.add(locale); }/*from w w w .j a v a 2s. co m*/ return locales; }
From source file:org.jboss.additional.testsuite.jdkall.present.management.api.web.ListenerTestCase.java
private Set<String> getListenersByType(String type) throws Exception { ModelNode op = createOpNode("subsystem=undertow/server=default-server", "read-children-names"); op.get("child-type").set(type); ModelNode result = executeOperation(op); List<ModelNode> connectors = result.asList(); HashSet<String> connNames = new HashSet<>(); for (ModelNode n : connectors) { connNames.add(n.asString()); }// www. j a va 2 s.c om return connNames; }
From source file:com.catify.processengine.core.data.services.ProcessInstanceMediatorServiceTest.java
@Test public void testFindActiveFlowNodeInstances() { HashSet<FlowNodeInstance> flowNodeInstances = new HashSet<FlowNodeInstance>(); FlowNodeInstance flowNodeInstance = new FlowNodeInstance("TESTSTATE", 0, 0); flowNodeInstances.add(flowNodeInstance); when(flowNodeInstanceRepositoryService.findFlowNodeInstancesAtCurrentLevelByState("uniqueFlowNodeId", "testInstanceId", NodeInstaceStates.ACTIVE_STATE)).thenReturn(flowNodeInstances); assertEquals(flowNodeInstances, processInstanceMediatorServiceMockInjected .findActiveFlowNodeInstances("uniqueFlowNodeId", "testInstanceId")); }
From source file:com.tesora.dve.sql.util.PEDDL.java
@Override public void destroy(ConnectionResource mr) throws Throwable { if (mr == null) return;/*from w ww.java 2 s . co m*/ TaggedLineInfo tli = new TaggedLineInfo(-1, null, -1, LineTag.DDL); // drop all the dbs for (DatabaseDDL dbddl : getDatabases()) mr.execute(tli, dbddl.getDropStatement()); HashSet<String> pgnames = new HashSet<String>(); for (StorageGroupDDL sgddl : persGroups) pgnames.add(sgddl.getName()); ResourceResponse rr = mr.fetch("show containers"); List<ResultRow> results = rr.getResults(); for (ResultRow row : results) { ResultColumn rc = row.getResultColumn(1); String contName = (String) rc.getColumnValue(); mr.execute(tli, "drop container " + contName); } // now we have to find ranges that use our persistent group rr = mr.fetch("show ranges"); results = rr.getResults(); for (ResultRow row : results) { ResultColumn rangeNameColumn = row.getResultColumn(1); ResultColumn storageGroupColumn = row.getResultColumn(2); String rangeName = rangeNameColumn.getColumnValue().getClass().isArray() ? new String((byte[]) rangeNameColumn.getColumnValue()) : (String) rangeNameColumn.getColumnValue(); String groupName = storageGroupColumn.getColumnValue().getClass().isArray() ? new String((byte[]) storageGroupColumn.getColumnValue()) : (String) storageGroupColumn.getColumnValue(); if (pgnames.contains(groupName.trim())) { try { mr.execute(tli, "drop range " + rangeName + " persistent group " + groupName.trim()); } catch (PEException e) { if (!throwDropRangeInUseException && (StringUtils.containsIgnoreCase(e.getMessage(), "Unable to drop range") && StringUtils.containsIgnoreCase(e.getMessage(), "because used by table"))) { // eat the exception } else { throw e; } } } } // now we can drop the persistent group, which apparently also drops the persistent sites for (StorageGroupDDL sgddl : persGroups) { sgddl.destroy(mr); } }
From source file:org.busko.routemanager.web.TestDataController.java
private void initGtfsAgencyData() { HashSet<String> agencyIds = new HashSet<String>(); for (Agency agency : Agency.findAllAgencys()) { agencyIds.add(agency.getAgencyId()); }/*w w w .j av a2 s .co m*/ if (!agencyIds.contains("GoBus")) { Agency agency = new Agency("GoBus", "Dunedin City GoBus", "http://www.orc.govt.nz/Information-and-Services/Buses/Bus-Information/", "Pacific/Auckland", "+643 474 0287", "en", "10"); agency.setLive(true); agency.persist(); } if (!agencyIds.contains("Connectabus")) { Agency agency = new Agency("Connectabus", "Connectabus", "http://connectabus.com/", "Pacific/Auckland", "+643 441 4471", "en", "11"); agency.setLive(true); agency.persist(); } if (!agencyIds.contains("InvercargillCity")) { Agency agency = new Agency("InvercargillCity", "Invercargill City Council", "http://www.icc.govt.nz/ServicesA-Z/Buses.aspx", "Pacific/Auckland", "+643 218 7108", "en", "12"); agency.setLive(true); agency.persist(); } if (!agencyIds.contains("TheBlenheimBus")) { Agency agency = new Agency("TheBlenheimBus", "The Blenheim Bus", "http://www.marlborough.govt.nz/Services/Parking-Roads-and-Transport/Blenheim-Bus-Service.aspx", "Pacific/Auckland", "+643 520 7400", "en", "20"); agency.setLive(true); agency.persist(); } if (!agencyIds.contains("theBayBus")) { Agency agency = new Agency("theBayBus", "BayBus", "http://www.baybus.co.nz/", "Pacific/Auckland", "+643 864 4669", "en", "21"); agency.persist(); } if (!agencyIds.contains("NelsonBus")) { Agency agency = new Agency("NelsonBus", "Nelson Bus", "http://www.nelsoncitycouncil.co.nz/nbus/", "Pacific/Auckland", "+643 546 0200", "en", "22"); agency.persist(); } if (!agencyIds.contains("Tranzit")) { Agency agency = new Agency("Tranzit", "Tranzit", "http://www.newplymouthnz.com/OurDistrict/Transport/NewPlymouthBusServices.htm", "Pacific/Auckland", "+646 759 6060", "en", "23"); agency.persist(); } if (!agencyIds.contains("Citylink")) { Agency agency = new Agency("CityLink", "CityLink Whangarei", "http://www.nrc.govt.nz/transport/getting-around/whangarei-bus-service/", "Pacific/Auckland", "+649 470 1200", "en", "24"); agency.persist(); } // if (!agencyIds.contains("Intercity")) { // Agency agency = new Agency(); // agency.setAgencyId("Intercity"); // agency.setAgencyName("Intercity Coachlines"); // agency.setAgencyUrl("http://www.intercity.co.nz/cheap-north-island-buses/bus-auckland-to-tauranga/"); // agency.setAgencyTimezone("Pacific/Auckland"); // agency.setAgencyPhone("+649 583 5780"); // agency.setAgencyLang("en"); // agency.setUniqueEncoding("24"); // agency.persist(); // } if (!agencyIds.contains("NakedBus")) { Agency agency = new Agency("NakedBus", "Naked Bus", "http://nakedbus.com/nz/bus/", "Pacific/Auckland", "0900 62533", "en", "99"); agency.setLive(true); agency.persist(); } }
From source file:de.dfki.km.perspecting.obie.experiments.ProperNameExperiment.java
/** * Test method for/*from w w w . ja v a2 s . c om*/ * {@link de.dfki.km.perspecting.obie.dixi.service.SimpleScobieService#extractInformationFromURL(java.lang.String, java.lang.String)} * . */ @Test public void testExtractInformationFromURL() { try { StringBuffer b = new StringBuffer(); for (int i = 0; i < 1; i++) { Document document = pipeline.createDocument( FileUtils.toFile(new URL("http://en.wikipedia.org/wiki/Special:Random")), new URI("http://en.wikipedia.org/wiki/Special:Random"), MediaType.HTML, "SELECT * WHERE {?s ?p ?o}", Language.EN); Evaluator evaluator = new Evaluator(pipeline); for (int step = 0; pipeline.hasNext(step) && step <= 5; step = pipeline.execute(step, document)) { System.out.println(step); } HashSet<String> wordsOfPhrases = new HashSet<String>(); HashSet<String> wordsOfDocument = new HashSet<String>(); for (Token token : document.getTokens()) { wordsOfDocument.add(token.toString()); } int count = 0; for (TokenSequence<String> np : document.getNounPhrases()) { String[] words = np.toString().split("[\\s]+"); count += words.length; wordsOfPhrases.addAll(Arrays.asList(words)); } b.append(document.getTokens().size() + "\t" + document.getNounPhrases().size() + "\t" + count + "\t" + wordsOfPhrases.size() + "\t" + wordsOfDocument.size() + "\n"); } System.out.println("tok in doc\tnp in doc\ttok in nps\tdistinct tok in nps\tdistinct tok in doc"); System.out.println(b); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:de.hybris.platform.commercefacades.customergroups.impl.DefaultCustomerGroupFacade.java
@Override public void addUserToCustomerGroup(final String customerGroupId, final String userId) { Assert.notNull(customerGroupId);/*from www . j a v a 2s .co m*/ Assert.notNull(userId); final UserModel user = getUserById(userId); final UserGroupModel group = getCustomerGroupById(customerGroupId); final Set<PrincipalModel> members = group.getMembers(); final HashSet<PrincipalModel> modifiedMembers = new HashSet<PrincipalModel>(members); modifiedMembers.add(user); group.setMembers(modifiedMembers); getModelService().save(group); getModelService().refresh(user); }
From source file:fi.helsinki.lib.simplerest.CollectionsResource.java
@Put public Representation put(Representation dummy) { HashSet<Method> allowed = new HashSet(); allowed.add(Method.GET); allowed.add(Method.POST);//www . j a v a 2s. c o m setAllowedMethods(allowed); return error(null, "Collections resource does not allow PUT method.", Status.CLIENT_ERROR_METHOD_NOT_ALLOWED); }