public Match(SwingTalker talker) { this.talker = talker; gameLength = GameLength.TWENTY_ONE; matchLength = MatchLength.ONE; style = Style.LED; leftTeam.setName(new Speech("Home Team")); leftTeam.setColor(TeamColor.LED_RED); rightTeam.setName(new Speech("Away Team")); rightTeam.setColor(TeamColor.LED_CYAN); }
private Team getTeam(String teamString) { Team t = new Team(); String[] record = teamString.trim().split("\\|"); String nameAndRank = record[0].split("=")[0].trim(); String teamDetails = record[0].split("=")[1].trim(); String[] temp = nameAndRank.split(" +"); String[] temp1 = teamDetails.replaceAll("\\s+", " ").split(" "); String tempName = ""; for (int i = 1; i < temp.length; i++) { tempName = tempName + temp[i] + " "; } tempName = tempName.replaceAll("\\s+$", ""); String tempRating = temp1[0]; String tempWins = temp1[1]; String tempLoss = temp1[2]; t.setName(tempName); t.setRanking(Integer.parseInt(temp[0])); t.setRating(Float.parseFloat(tempRating)); t.setWin(Integer.parseInt(tempWins)); t.setLoss(Integer.parseInt(tempLoss)); return t; }
private Team createTeam(Client client) { Team team = new Team(); team.setName("Test Team" + RandomStringUtils.randomAlphanumeric(18)); team.setDescription("Test Team description"); team.setActive(true); team.setClient(client); team.setSalesForceAccount(new TeamSalesForce(RandomStringUtils.randomAlphanumeric(18))); teamService.create(team); return team; }
/** * Tests that the token filters applied to <code>Team</code> are successfully created and used. * Refer to <code>Team</code> to see the exact definitions. * * @throws Exception in case the test fails */ @Test public void testAnalyzerDef() throws Exception { // create the test instance Team team = new Team(); team.setDescription( "This is a D\u00E0scription"); // \u00E0 == � - ISOLatin1AccentFilterFactory should strip of // diacritic team.setLocation("Atlanta"); team.setName("ATL team"); // persist and index the test object FullTextSession fts = Search.getFullTextSession(openSession()); Transaction tx = fts.beginTransaction(); fts.persist(team); tx.commit(); fts.clear(); // execute several search to show that the right tokenizers were applies tx = fts.beginTransaction(); TermQuery query = new TermQuery(new Term("description", "D\u00E0scription")); assertEquals( "iso latin filter should work. � should be a now", 0, fts.createFullTextQuery(query).list().size()); query = new TermQuery(new Term("description", "is")); assertEquals( "stop word filter should work. is should be removed", 0, fts.createFullTextQuery(query).list().size()); query = new TermQuery(new Term("description", "dascript")); assertEquals( "snowball stemmer should work. 'dascription' should be stemmed to 'dascript'", 1, fts.createFullTextQuery(query).list().size()); // cleanup fts.delete(fts.createFullTextQuery(query).list().get(0)); tx.commit(); fts.close(); }