List of usage examples for junit.framework Assert assertFalse
static public void assertFalse(boolean condition)
From source file:com.nomsic.randb.RandbTest.java
@Test public void testMarkUsed() throws RandbException { String name = "TEST"; manager.createBlockGroup(name, 3, Arrays.asList(new Integer[] { 2, 4 }), Arrays.asList(new String[] { "A", "B" })); Cell c1 = manager.getNextCell(name); manager.markAsUsed(name, c1);/*from www .ja va 2 s .c om*/ Cell c2 = manager.getNextCell(name); Assert.assertFalse(c1.getUuid().equals(c2.getUuid())); provider.clearCache(); Cell c1a = manager.getCell(name, c1.getUuid().toString()); Assert.assertTrue(c1a.isUsed()); }
From source file:com.ewcms.publication.freemarker.directive.ChannelListDirectiveTest.java
@Test public void testDebugLoadingChannelChildren() throws Exception { Channel channel = createChannel(1, true); ChannelPublishServiceable service = mock(ChannelPublishServiceable.class); when(service.getChannel(any(Integer.class), any(Integer.class))).thenReturn(channel); List<Channel> children = createChannelChildren(1, 5); when(service.getChannelChildren(any(Integer.class))).thenReturn(children); ChannelListDirective directive = new ChannelListDirective(service); List<Channel> list = directive.loadingChannel(1, 1, false, true, true); Assert.assertFalse(list.isEmpty()); Assert.assertEquals(5, list.size()); }
From source file:de.hybris.platform.basecommerce.util.BaseCommerceBaseTest.java
protected OrderModel getOrderForCode(final String orderCode) { final DefaultGenericDao defaultGenericDao = new DefaultGenericDao(OrderModel._TYPECODE); defaultGenericDao.setFlexibleSearchService(flexibleSearchService); final List<OrderModel> orders = defaultGenericDao .find(Collections.singletonMap(OrderModel.CODE, orderCode)); Assert.assertFalse(orders.isEmpty()); final OrderModel orderModel = orders.get(0); Assert.assertNotNull("Order should have been loaded from database", orderModel); return orderModel; }
From source file:io.cloudslang.lang.runtime.steps.ExecutableStepsTest.java
@Test public void testBoundInputEvent() { List<Input> inputs = Arrays.asList(new Input.InputBuilder("input1", "input1").build(), new Input.InputBuilder("input2", "3").withEncrypted(true).withRequired(true).withOverridable(false) .build());// w w w.j a v a2 s .c o m RunEnvironment runEnv = new RunEnvironment(); ExecutionRuntimeServices runtimeServices = new ExecutionRuntimeServices(); Map<String, Serializable> resultMap = new HashMap<>(); resultMap.put("input1", 5); resultMap.put("input2", 3); when(inputsBinding.bindInputs(eq(inputs), anyMap(), anySet())).thenReturn(resultMap); executableSteps.startExecutable(inputs, runEnv, new HashMap<String, Serializable>(), runtimeServices, "dockerizeStep", 2L); Collection<ScoreEvent> events = runtimeServices.getEvents(); Assert.assertFalse(events.isEmpty()); ScoreEvent boundInputEvent = null; for (ScoreEvent event : events) { if (event.getEventType().equals(ScoreLangConstants.EVENT_INPUT_END)) { boundInputEvent = event; } } Assert.assertNotNull(boundInputEvent); LanguageEventData eventData = (LanguageEventData) boundInputEvent.getData(); Assert.assertTrue(eventData.containsKey(LanguageEventData.BOUND_INPUTS)); Map<String, Serializable> inputsBounded = (Map<String, Serializable>) eventData .get(LanguageEventData.BOUND_INPUTS); Assert.assertNotNull(eventData.getStepName()); Assert.assertEquals(LanguageEventData.StepType.EXECUTABLE, eventData.getStepType()); Assert.assertEquals("dockerizeStep", eventData.getStepName()); // verify input names are in defined order and have the expected value Set<Map.Entry<String, Serializable>> inputEntries = inputsBounded.entrySet(); Iterator<Map.Entry<String, Serializable>> inputNamesIterator = inputEntries.iterator(); Map.Entry<String, Serializable> firstInput = inputNamesIterator.next(); org.junit.Assert.assertEquals("Inputs are not in defined order in end inputs binding event", "input1", firstInput.getKey()); org.junit.Assert.assertEquals(5, firstInput.getValue()); Map.Entry<String, Serializable> secondInput = inputNamesIterator.next(); org.junit.Assert.assertEquals("Inputs are not in defined order in end inputs binding event", "input2", secondInput.getKey()); org.junit.Assert.assertEquals(LanguageEventData.ENCRYPTED_VALUE, secondInput.getValue()); }
From source file:org.openmrs.module.emrapi.account.AccountComponentTest.java
@Test public void shouldSavePersonAndUserAndProvider() { Role fullPrivileges = userService.getRole("Privilege Level: Full"); Role archives = userService.getRole("Application Role: Archives"); Role registration = userService.getRole("Application Role: Registration"); ProviderRole nurse = providerManagementService.getProviderRole(1001); Person person = new Person(); AccountDomainWrapper account = accountService.getAccountByPerson(person); account.setGivenName("Mark"); account.setFamilyName("Jones"); account.setGender("M"); account.setUserEnabled(true);/* ww w .j av a2 s . c o m*/ account.setUsername("mjones"); account.setPassword("Mjones123"); account.setDefaultLocale(new Locale("fr")); account.setPrivilegeLevel(fullPrivileges); Set<Role> capabilities = new HashSet<Role>(); capabilities.add(registration); capabilities.add(archives); account.setCapabilities(capabilities); account.setProviderRole(nurse); account.save(); Integer personId = account.getPerson().getPersonId(); Assert.assertNotNull(personId); Integer userId = account.getUser().getUserId(); Assert.assertNotNull(userId); Context.flushSession(); Context.clearSession(); Person expectedPerson = personService.getPerson(personId); Assert.assertEquals("Mark", expectedPerson.getGivenName()); Assert.assertEquals("Jones", expectedPerson.getFamilyName()); Assert.assertEquals("M", expectedPerson.getGender()); Assert.assertEquals(Context.getAuthenticatedUser(), expectedPerson.getPersonCreator()); Assert.assertNotNull(expectedPerson.getPersonDateCreated()); User expectedUser = userService.getUser(userId); Assert.assertFalse(expectedUser.isRetired()); Assert.assertEquals("mjones", expectedUser.getUsername()); Assert.assertEquals(person, expectedUser.getPerson()); Assert.assertEquals("fr", expectedUser.getUserProperty(OpenmrsConstants.USER_PROPERTY_DEFAULT_LOCALE).toString()); Assert.assertTrue(expectedUser.hasRole(fullPrivileges.toString())); Assert.assertTrue(expectedUser.hasRole(archives.toString())); Assert.assertTrue(expectedUser.hasRole(registration.toString())); // note that we don't expose the provider object outside of the account domain wrapper; saves confusion between the // two Provider object types List<Provider> providers = providerManagementService.getProvidersByPerson(expectedPerson, false); Assert.assertEquals(1, providers.size()); Assert.assertEquals(nurse, providers.get(0).getProviderRole()); }
From source file:com.couchbase.lite.DocumentTest.java
public void testDeleteDocument() throws CouchbaseLiteException { Document document = database.createDocument(); Map<String, Object> properties = new HashMap<String, Object>(); properties.put("foo", "foo"); properties.put("bar", Boolean.FALSE); document.putProperties(properties);/*from w w w.j a v a2 s . c o m*/ Assert.assertNotNull(document.getCurrentRevision()); String docId = document.getId(); document.delete(); Assert.assertTrue(document.isDeleted()); Document fetchedDoc = database.getExistingDocument(docId); Assert.assertNull(fetchedDoc); // query all docs and make sure we don't see that document //database.getAllDocs(new QueryOptions()); Query queryAllDocs = database.createAllDocumentsQuery(); QueryEnumerator queryEnumerator = queryAllDocs.run(); for (Iterator<QueryRow> it = queryEnumerator; it.hasNext();) { QueryRow row = it.next(); Assert.assertFalse(row.getDocument().getId().equals(docId)); } }
From source file:org.openmrs.module.webservices.rest19ext.web.v1_0.controller.LocationAttributeControllerTest.java
@Test public void shouldVoidAttribute() throws Exception { LocationAttribute locationAttribute = service .getLocationAttributeByUuid(Rest19ExtTestConstants.LOCATION_ATTRIBUTE_UUID); Assert.assertFalse(locationAttribute.isVoided()); controller.delete(Rest19ExtTestConstants.LOCATION_UUID, Rest19ExtTestConstants.LOCATION_ATTRIBUTE_UUID, "unit test", request, response); locationAttribute = service.getLocationAttributeByUuid(Rest19ExtTestConstants.LOCATION_ATTRIBUTE_UUID); Assert.assertTrue(locationAttribute.isVoided()); Assert.assertEquals("unit test", locationAttribute.getVoidReason()); }
From source file:org.openmrs.module.webservices.rest19ext.web.v1_0.controller.ProviderAttributeControllerTest.java
@Test public void shouldVoidAttribute() throws Exception { ProviderAttribute providerAttribute = service .getProviderAttributeByUuid(Rest19ExtTestConstants.PROVIDER_ATTRIBUTE_UUID); Assert.assertFalse(providerAttribute.isVoided()); controller.delete(Rest19ExtTestConstants.PROVIDER_UUID, Rest19ExtTestConstants.PROVIDER_ATTRIBUTE_UUID, "unit test", request, response); providerAttribute = service.getProviderAttributeByUuid(Rest19ExtTestConstants.PROVIDER_ATTRIBUTE_UUID); Assert.assertTrue(providerAttribute.isVoided()); Assert.assertEquals("unit test", providerAttribute.getVoidReason()); }
From source file:com.google.api.ads.adwords.awreporting.model.definitions.ReportKeywordDefinitionTest.java
/** * @see com.google.api.ads.adwords.awreporting.model.definitions. * AbstractReportDefinitionTest#testLastEntry( * com.google.api.ads.adwords.awreporting.model.entities.Report) *//* w w w .ja v a 2s. c o m*/ @Override protected void testLastEntry(ReportKeyword last) { Assert.assertEquals(8661954824L, last.getAccountId().longValue()); Assert.assertEquals("2013-05-10", last.getDay()); Assert.assertEquals(0.00, last.getCost().doubleValue()); Assert.assertEquals(0L, last.getClicks().longValue()); Assert.assertEquals(1L, last.getImpressions().longValue()); Assert.assertEquals(0L, last.getConversions().longValue()); Assert.assertEquals(0.00, last.getCtrBigDecimal().doubleValue()); Assert.assertEquals(0.00, last.getAvgCpm().doubleValue()); Assert.assertEquals(0.00, last.getAvgCpc().doubleValue()); Assert.assertEquals(6.00, last.getAvgPositionBigDecimal().doubleValue()); Assert.assertEquals("EUR", last.getCurrencyCode()); Assert.assertEquals(86352677L, last.getCampaignId().longValue()); Assert.assertEquals(3398915357L, last.getAdGroupId().longValue()); Assert.assertEquals(44877775648L, last.getKeywordId().longValue()); Assert.assertEquals("enabled", last.getStatus()); Assert.assertEquals(10.00, last.getQualityScoreAsBigDecimal().doubleValue()); Assert.assertEquals("Broad", last.getKeywordMatchType()); Assert.assertEquals("propriete sologne a vendre", last.getKeywordText()); Assert.assertEquals("", last.getDestinationUrl()); Assert.assertFalse(last.isNegative()); }
From source file:at.tfr.securefs.process.ProcessFilesTest.java
@Test public void testCopyFilesByWalk() throws Exception { // Given: NO target directory yet!!, the source file final String data = "Hallo Echo"; try (OutputStream os = cp.getEncrypter(fromFile)) { IOUtils.write(data, os);/*from ww w.ja v a 2 s . c o m*/ } Assert.assertFalse(Files.exists(toRoot.resolve(DATA_FILES))); Assert.assertFalse(Files.exists(targetToFile)); // When: copy of fromRoot to toRoot ProcessFiles pf = new ProcessFilesBean(new MockSecureFsCache()); ProcessFilesData cfd = new ProcessFilesData().setFromRootPath(fromRoot.toString()) .setToRootPath(toRoot.toString()).setAllowOverwriteExisting(false).setUpdate(false) .setProcessActive(true); pf.copy(fromRoot, toRoot, cp, newSecret, cfd); // Then: a target file is created in same subpath like sourceFile: Assert.assertTrue("subpath is not created", Files.exists(toRoot.resolve(DATA_FILES))); Assert.assertTrue("target file not created", Files.exists(targetToFile)); // Then: the content of target file is decryptable with newSecret // and equals content of source file byte[] buf = new byte[data.getBytes().length]; try (InputStream is = cp.getDecrypter(targetToFile, newSecret)) { IOUtils.read(is, buf); } Assert.assertEquals("failed to decrypt data", data, String.valueOf(data)); }