List of usage examples for junit.framework Assert assertEquals
static public void assertEquals(String message, int expected, int actual)
From source file:com.javiermoreno.springboot.mvc.users.UserManagementServiceImplIT.java
@Test public void checkNewUserIsSavedAndContainsCorrectPasswordHash() { DailyUser user = new DailyUser(); user.setEmail("alice@wonderland.com"); user.setBirthday(/*www . ja v a 2 s . com*/ Date.from(LocalDate.of(1976, Month.DECEMBER, 12).atStartOfDay(ZoneId.systemDefault()).toInstant())); service.registerNewUser(user, "secret", true); Assert.assertNotSame("Id correctly assigned", 0, user.getId()); Assert.assertEquals("Password md5 is correctely encoded.", "5ebe2294ecd0e0f08eab7690d2a6ee69", user.getPassword()); }
From source file:org.openxdata.server.service.impl.UserServiceTest.java
@Test public void getUsers_shouldReturnAllUsers() throws Exception { List<User> users = userService.getUsers(); Assert.assertNotNull(users);//from w w w .j a v a 2 s . co m Assert.assertEquals("There are 5 users", 5, users.size()); }
From source file:com.metamx.common.parsers.JSONParserTest.java
@Test public void testSimpleWithFields() { final Parser<String, Object> jsonParser = new JSONParser(new ObjectMapper(), Lists.newArrayList("two")); final Map<String, Object> jsonMap = jsonParser.parse(json); Assert.assertEquals("jsonMap", ImmutableMap.of("two", ImmutableList.of("bar", "baz")), jsonMap); }
From source file:org.openspaces.eviction.test.ClassSpecificOrderTest.java
@Test public void noneDoesNotEvictTest() throws Exception { logger.info("fill cache with ten times its amount with none order by"); for (int i = 0; i < cacheSize * 10; i++) { gigaSpace.write(new GoldMedal(i)); }/*from www . j a va2 s.c o m*/ logger.info("assert none order does not evict"); Assert.assertEquals("GoldMedals were evicted", cacheSize * 10, gigaSpace.count(new GoldMedal())); logger.info("Test Passed"); }
From source file:net.sf.dynamicreports.test.jasper.AbstractJasperChartTest.java
protected void chartCategoryCountTest(String name, int index, int expectedNumberOfCategories) { Assert.assertEquals("chart category count " + name, expectedNumberOfCategories, getChart(name, index).getCategoryPlot().getDataset().getColumnCount()); }
From source file:com.xpn.xwiki.objects.classes.PropertyClassTest.java
/** Test the {@link PropertyClass#compareTo(PropertyClass)} method. */ public void testCompareTo() { PropertyClass one = new PropertyClass(); PropertyClass two = new PropertyClass(); // Random numbers to be used as property indexes. int n1, n2;/*w ww .j a va2 s . c o m*/ one.setName("first"); two.setName("second"); // Since the test might randomly succeed, run it several times to be safer. for (int i = 0; i < 20; ++i) { n1 = RandomUtils.nextInt(); n2 = RandomUtils.nextInt(); one.setNumber(n1); two.setNumber(n2); if (n1 == n2) { Assert.assertEquals(Math.signum(one.compareTo(two)), -1.0, 0); Assert.assertEquals(Math.signum(two.compareTo(one)), 1.0, 0); } else { Assert.assertEquals(Math.signum(one.compareTo(two)), Math.signum(n1 - n2)); Assert.assertEquals(Math.signum(two.compareTo(one)), Math.signum(n2 - n1)); } } // Also test that the comparison takes into account the name in case the two numbers are identical one.setNumber(42); two.setNumber(42); Assert.assertEquals(Math.signum(one.compareTo(two)), -1.0, 0); Assert.assertEquals(Math.signum(two.compareTo(one)), 1.0, 0); }
From source file:com.ignou.aadhar.util.BankAccountCreatorTest.java
@Test public void testInvalidCreateAccount() { JsonWrapper output = creatorObj.createAccount("1234567890abcdefghijkl"); Assert.assertEquals("Failure response not returned.", "FAILURE", output.get("status")); Assert.assertNull("Account ID returned for invalid UID", output.get("id")); }
From source file:edu.uci.ics.jung.algorithms.scoring.TestPageRank.java
public void testRanker() { graph = new DirectedSparseMultigraph<Integer, Integer>(); for (int i = 0; i < 4; i++) { graph.addVertex(i);//ww w .j av a 2s . co m } addEdge(graph, 0, 1, 1.0); addEdge(graph, 1, 2, 1.0); addEdge(graph, 2, 3, 0.5); addEdge(graph, 3, 1, 1.0); addEdge(graph, 2, 1, 0.5); PageRankWithPriors<Integer, Integer> pr = new PageRank<Integer, Integer>(graph, MapTransformer.getInstance(edgeWeights), 0); pr.evaluate(); Assert.assertEquals(pr.getVertexScore(0), 0.0, pr.getTolerance()); Assert.assertEquals(pr.getVertexScore(1), 0.4, pr.getTolerance()); Assert.assertEquals(pr.getVertexScore(2), 0.4, pr.getTolerance()); Assert.assertEquals(pr.getVertexScore(3), 0.2, pr.getTolerance()); // Assert.assertTrue(NumericalPrecision.equal(((Ranking)ranker.getRankings().get(0)).rankScore,0.4,.001)); // Assert.assertTrue(NumericalPrecision.equal(((Ranking)ranker.getRankings().get(1)).rankScore,0.4,.001)); // Assert.assertTrue(NumericalPrecision.equal(((Ranking)ranker.getRankings().get(2)).rankScore,0.2,.001)); // Assert.assertTrue(NumericalPrecision.equal(((Ranking)ranker.getRankings().get(3)).rankScore,0,.001)); }
From source file:org.openxdata.server.service.impl.UserServiceTest.java
@Test public void saveUser_shouldSaveUser() throws Exception { final String userName = "User Name"; List<User> users = userService.getUsers(); Assert.assertEquals("There are 5 users", 5, users.size()); Assert.assertNull(getUser(userName, users)); User user = new User(userName); user.setCreator(users.get(0));/*from w w w .ja va 2s. c om*/ user.setDateCreated(new Date()); userService.saveUser(user); users = userService.getUsers(); Assert.assertEquals("Added 1 user so now there are 6", 6, userService.getUsers().size()); Assert.assertNotNull(getUser(userName, users)); }
From source file:org.openxdata.server.service.impl.StudyManagerServiceTest.java
@Test public void saveStudy_shouldSaveStudy() throws Exception { final String studyName = "StudyName"; List<StudyDef> studies = studyManagerService.getStudies(); Assert.assertEquals("There are 4 studies", 4, studies.size()); Assert.assertNull(getStudy(studyName, studies)); StudyDef study = new StudyDef(); study.setName(studyName);//ww w . j ava 2 s .c o m study.setCreator(userService.getUsers().get(0)); study.setDateCreated(new Date()); studyManagerService.saveStudy(study); studies = studyManagerService.getStudies(); Assert.assertEquals("Added 1 study, now there are 5", 5, studies.size()); Assert.assertNotNull(getStudy(studyName, studies)); }