List of usage examples for java.util SortedSet add
boolean add(E e);
From source file:de.skubware.opentraining.test.WgerJSONParserTest.java
public void testParseExerciseTypeXML() throws JSONException, IOException { IDataProvider dataProvider = new DataProvider(getInstrumentation().getTargetContext()); WgerJSONParser parser = new WgerJSONParser(readFile(R.raw.exampel_wger_exercises), readFile(R.raw.exampel_wger_languages), readFile(R.raw.exampel_wger_muscles), readFile(R.raw.exampel_wger_equipment), readFile(R.raw.exampel_wger_licenses), dataProvider); // the parser should return three exercises ExerciseType EXERCISE_ONE_PARSED = null; ExerciseType EXERCISE_TWO_PARSED = null; ExerciseType EXERCISE_THREE_PARSED = null; ArrayList<ExerciseType> exerciseList = parser.getNewExercises(); for (ExerciseType ex : exerciseList) { Log.d(TAG, "WgerJSONParser returned exercise: " + ex.toString()); if (ex.getUnlocalizedName().equals(EXERCISE_NAME_1)) { EXERCISE_ONE_PARSED = ex;// ww w .j ava 2 s. c o m } if (ex.getUnlocalizedName().equals(EXERCISE_NAME_2)) { EXERCISE_TWO_PARSED = ex; } if (ex.getUnlocalizedName().equals(EXERCISE_NAME_3)) { EXERCISE_THREE_PARSED = ex; } } assertNotNull(EXERCISE_ONE_PARSED); assertNotNull(EXERCISE_TWO_PARSED); assertNotNull(EXERCISE_THREE_PARSED); assertEquals(3, exerciseList.size()); // now check if the 3 exercises were parsed correctly SortedSet<Muscle> muscles_1 = new TreeSet<Muscle>(); muscles_1.add(dataProvider.getMuscleByName(MUSCLE_1_1)); muscles_1.add(dataProvider.getMuscleByName(MUSCLE_1_2)); ExerciseType EXERCISE_ONE = new ExerciseType.Builder(EXERCISE_NAME_1, ExerciseSource.SYNCED) .description(DESCRIPTION_1).activatedMuscles(muscles_1).build(); // only equals is not enough as ExerciseType.equals() only compares the name of the exercises assertEquals(EXERCISE_ONE, EXERCISE_ONE_PARSED); assertEquals(EXERCISE_ONE.getDescription(), EXERCISE_ONE_PARSED.getDescription()); assertEquals(EXERCISE_ONE.getActivatedMuscles(), EXERCISE_ONE_PARSED.getActivatedMuscles()); SortedSet<Muscle> muscles_2 = new TreeSet<Muscle>(); muscles_2.add(dataProvider.getMuscleByName(MUSCLE_2_1)); ExerciseType EXERCISE_TWO = new ExerciseType.Builder(EXERCISE_NAME_2, ExerciseSource.SYNCED) .description(DESCRIPTION_2).activatedMuscles(muscles_2).build(); // only equals is not enough as ExerciseType.equals() only compares the name of the exercises assertEquals(EXERCISE_TWO, EXERCISE_TWO_PARSED); assertEquals(EXERCISE_TWO.getDescription(), EXERCISE_TWO_PARSED.getDescription()); assertEquals(EXERCISE_TWO.getActivatedMuscles(), EXERCISE_TWO_PARSED.getActivatedMuscles()); }
From source file:com.jdom.axis.and.allies.view.AndroidStrategy.java
public SortedSet<String> getAvailableGames() { SortedSet<String> available = new TreeSet<String>(); for (File file : context.getFilesDir().listFiles()) { if (file.isFile()) { available.add(file.getName().replaceAll(PROPERTIES_EXTENSION, "")); }/*from www. ja v a 2s. c om*/ } return available; }
From source file:com.gopivotal.cla.web.AbstractSignatoryController.java
protected final SortedSet<Email> verifiedEmails() { SortedSet<Email> verifiedEmails = new TreeSet<>(); for (Email email : this.gitHubClient.getEmails()) { if (email.isVerified()) { verifiedEmails.add(email); }// www.j av a2s . c o m } return verifiedEmails; }
From source file:com.jdom.word.playdough.model.BaseGamePackResolver.java
public SortedSet<String> getGamePackNames() { SortedSet<String> names = new TreeSet<String>(); for (File file : gamePacksDirectory.listFiles()) { if (file.getName().startsWith(GAME_PACK_PREFIX)) { names.add(file.getName()); }/* w ww .j av a 2s . c o m*/ } return names; }
From source file:com.sonatype.security.ldap.AbstractMockLdapConnectorTest.java
protected MockLdapConnector buildMainMockServer(String serverId) { SortedSet<String> groupIds = new TreeSet<String>(); groupIds.add("alpha"); groupIds.add("beta"); groupIds.add("gamma"); SortedSet<LdapUser> users = new TreeSet<LdapUser>(); LdapUser rwalker = new LdapUser(); rwalker.setDn("uid=rwalker,ou=people,o=sonatype"); rwalker.setRealName("Robin E. Walker"); rwalker.setEmail("rwalker@sonatype.com"); rwalker.setMembership(new HashSet<String>()); rwalker.getMembership().addAll(groupIds); // has all groups rwalker.setPassword("rwalker123"); rwalker.setUsername("rwalker"); users.add(rwalker);/* ww w . j a v a 2 s. c o m*/ LdapUser ehearn = new LdapUser(); ehearn.setDn("uid=ehearn,ou=people,o=sonatype"); ehearn.setRealName("Eula Hearn"); ehearn.setEmail("ehearn@sonatype.com"); ehearn.setMembership(new HashSet<String>()); ehearn.getMembership().add("alpha"); ehearn.getMembership().add("gamma"); ehearn.setPassword("ehearn123"); ehearn.setUsername("ehearn"); users.add(ehearn); LdapUser jgoodman = new LdapUser(); jgoodman.setDn("uid=jgoodman,ou=people,o=sonatype"); jgoodman.setRealName("Joseph M. Goodman"); jgoodman.setEmail("jgoodman@sonatype.com"); jgoodman.setMembership(new HashSet<String>()); jgoodman.getMembership().add("alpha"); jgoodman.getMembership().add("beta"); jgoodman.setPassword("jgoodman123"); jgoodman.setUsername("jgoodman"); users.add(jgoodman); return new MockLdapConnector(serverId, users, groupIds); }
From source file:com.espertech.esper.schedule.TestScheduleSpec.java
public void testCompress() { EnumMap<ScheduleUnit, SortedSet<Integer>> unitValues = new EnumMap<ScheduleUnit, SortedSet<Integer>>( ScheduleUnit.class); unitValues = (new ScheduleSpec()).getUnitValues(); // Populate Month with all valid values SortedSet<Integer> monthValues = new TreeSet<Integer>(); for (int i = ScheduleUnit.MONTHS.min(); i <= ScheduleUnit.MONTHS.max(); i++) { monthValues.add(i); }//from w ww.j ava2 s . c o m unitValues.put(ScheduleUnit.MONTHS, monthValues); // Construct spec, test that month was replaced with wildcards ScheduleSpec spec = new ScheduleSpec(unitValues, null, null, null); assertTrue(spec.getUnitValues().get(ScheduleUnit.MONTHS) == null); }
From source file:com.comcast.viper.flume2storm.event.F2SEventFactory.java
/** * @param nbEvents//from w w w . j a v a2s .co m * The number of events to create * @return A {@link SortedSet} of randomly generated {@link F2SEvent} */ public SortedSet<F2SEvent> generateRandomEvents(int nbEvents) { final SortedSet<F2SEvent> result = new TreeSet<F2SEvent>(new F2SEventComparator()); while (result.size() != nbEvents) { result.add(F2SEventFactory.getInstance().createRandomWithHeaders()); } return result; }
From source file:uk.co.unclealex.process.spring.PackageCheckingPostProcessorTest.java
/** * Creates the package checking post processor. * //w ww. j ava2 s.c om * @return the package checking post processor */ protected PackageCheckingPostProcessor createPackageCheckingPostProcessor() { PackageChecker packageChecker = new PackageChecker() { @Override public SortedSet<String> listMissingPackages(Object obj) { SortedSet<String> missingPackages = Sets.newTreeSet(); if (obj instanceof MissingPackages) { missingPackages.add("missing"); } return missingPackages; } @Override public SortedSet<String> listMissingPackages(Class<?> clazz) { return listMissingPackages((Object) clazz); } }; return new PackageCheckingPostProcessor(packageChecker); }
From source file:com.bah.culvert.accumulo.database.AccumuloDatabaseAdapter.java
@Override public void create(String tableName, byte[][] splitKeys, List<CColumn> columns) { try {/*from w w w . ja v a2 s . c o m*/ this.conn.tableOperations().create(tableName); // copy over the split keys into a format that accumulo can understand SortedSet<Text> partitionKeys = new TreeSet<Text>(); for (byte[] split : splitKeys) partitionKeys.add(new Text(split)); // and add the splits this.conn.tableOperations().addSplits(tableName, partitionKeys); } catch (Exception e) { throw Exceptions.asRuntime(e); } }
From source file:com.brotherpowers.cameraview.SizeMap.java
/** * Add a new {@link Size} to this collection. * * @param size The size to add.//from www .jav a 2 s . c o m * @return {@code true} if it is added, {@code false} if it already exists and is not added. */ public boolean add(Size size) { for (AspectRatio ratio : mRatios.keySet()) { if (ratio.matches(size)) { final SortedSet<Size> sizes = mRatios.get(ratio); if (sizes.contains(size)) { return false; } else { sizes.add(size); return true; } } } // None of the existing ratio matches the provided size; add a new key SortedSet<Size> sizes = new TreeSet<>(); sizes.add(size); mRatios.put(AspectRatio.of(size.getWidth(), size.getHeight()), sizes); return true; }