List of usage examples for junit.framework Assert assertNull
static public void assertNull(Object object)
From source file:de.hybris.platform.b2badmin.services.impl.B2BUnitServiceTest.java
@Test public void testRestrictionsOfUsersAndUnits() throws Exception { sessionService.executeInLocalView(new SessionExecutionBody() { @Override//from w w w .j av a 2 s .co m public void executeWithoutResult() { final String userId = "IC CEO"; login(userId); // test restrictions on units and employees Assert.assertNull(b2bUnitService.getUnitForUid("GC")); Assert.assertNull(baseDao.findFirstByAttribute(B2BCustomer.UID, "GC CEO", B2BCustomerModel.class)); // test costcenter and budget restriction Assert.assertNotNull( baseDao.findFirstByAttribute(B2BCostCenterModel.CODE, "IC 0", B2BCostCenterModel.class)); Assert.assertNull( baseDao.findFirstByAttribute(B2BCostCenterModel.CODE, "GC 0", B2BCostCenterModel.class)); Assert.assertNotNull(baseDao.findFirstByAttribute(B2BBudgetModel.CODE, "IC BUDGET EUR 1M", B2BBudgetModel.class)); Assert.assertNull(baseDao.findFirstByAttribute(B2BBudgetModel.CODE, "GC BUDGET EUR 1M", B2BBudgetModel.class)); // change the session IC_USER to the customer who belongs to different organization final UserModel GC_USER = (UserModel) sessionService.executeInLocalView(new SessionExecutionBody() { @Override public Object execute() { searchRestrictionService.disableSearchRestrictions(); final UserModel user = baseDao.findFirstByAttribute(B2BCustomerModel.UID, "GC CEO", B2BCustomerModel.class); Assert.assertNotNull(user); return user; } }); Assert.assertNotNull(GC_USER); login(GC_USER); // should now we able to see only items linked to C_2.. units Assert.assertNull( baseDao.findFirstByAttribute(B2BCostCenterModel.CODE, "IC 0", B2BCostCenterModel.class)); Assert.assertNotNull( baseDao.findFirstByAttribute(B2BCostCenterModel.CODE, "GC 0", B2BCostCenterModel.class)); Assert.assertNull(baseDao.findFirstByAttribute(B2BBudgetModel.CODE, "IC BUDGET EUR 1M", B2BBudgetModel.class)); Assert.assertNotNull(baseDao.findFirstByAttribute(B2BBudgetModel.CODE, "GC BUDGET EUR 1M", B2BBudgetModel.class)); } }, userService.getAdminUser()); }
From source file:eu.trentorise.smartcampus.ac.provider.repository.persistence.AcDaoPersistenceImplTest.java
@Test public void searchAuthorityByName() { Assert.assertNotNull(dao.readAuthorityByName(AUTH_NAME_PRESENT)); Assert.assertNull(dao.readAuthorityByName(AUTH_NAME_NOT_PRESENT)); }
From source file:com.connectsdk.service.sessions.WebOSWebAppSessionTest.java
@Test public void testJumpToTrack() throws JSONException { ResponseListener<Object> listener = Mockito.mock(ResponseListener.class); session.jumpToTrack(7, listener);/*from ww w.j a v a 2 s . co m*/ Robolectric.runUiThreadTasksIncludingDelayedTasks(); ArgumentCaptor<JSONObject> argPacket = ArgumentCaptor.forClass(JSONObject.class); ArgumentCaptor<JSONObject> argPayload = ArgumentCaptor.forClass(JSONObject.class); Mockito.verify(socket).sendMessage(argPacket.capture(), argPayload.capture()); Mockito.verify(listener).onSuccess(null); JSONObject packet = argPacket.getValue(); JSONObject payload = argPayload.getValue(); Assert.assertNull(payload); Assert.assertTrue(packet.has("payload")); Assert.assertEquals("jumpToTrack", packet.getJSONObject("payload").getJSONObject("mediaCommand").getString("type")); Assert.assertEquals(7, packet.getJSONObject("payload").getJSONObject("mediaCommand").getInt("index")); Assert.assertEquals("connectsdk.mediaCommand", packet.getJSONObject("payload").getString("contentType")); }
From source file:com.dianping.dpsf.centralstat.test.CentralStatTestCase.java
@Test public void testOneWayTimeout() throws Exception { log.info("$$$$$$$$$$testOneWayTimeout"); String ret = null;/*from w ww .j a va 2 s. c om*/ try { CentralStatTestService service = (CentralStatTestService) context .getBean("centralStatTestServiceOneWay"); service.invokeOneWayTimeOut("testOneWayTimeout"); } catch (Exception e) { Assert.assertNull(ret); } }
From source file:eu.trentorise.smartcampus.ac.provider.repository.persistence.AcDaoPersistenceImplTest.java
@Test public void searchAuthorityByUrl() { Assert.assertNotNull(dao.readAuthorityByUrl(AUTH_URL_PRESENT)); Assert.assertNull(dao.readAuthorityByUrl(AUTH_URL_NOT_PRESENT)); }
From source file:ejportal.webapp.action.UserActionTest.java
/** * Test search.//from www .j av a2s.c om * * @throws Exception * the exception */ public void testSearch() throws Exception { Assert.assertNull(this.action.getUsers()); Assert.assertEquals("success", this.action.list()); Assert.assertNotNull(this.action.getUsers()); Assert.assertFalse(this.action.hasActionErrors()); }
From source file:org.openmrs.module.webservices.rest.web.v1_0.controller.PersonNameControllerTest.java
@Test public void shouldPurgeName() throws Exception { // I'm using sql queries and a flush-session because if I try to test this the natural way, hibernate // complains that the name will be re-created since the person is in the session. Number before = (Number) Context.getAdministrationService() .executeSQL("select count(*) from person_name where person_id = 1", true).get(0).get(0); controller.purge(personUuid, nameUuid, request, response); Context.flushSession();// w w w. j av a2 s .co m Number after = (Number) Context.getAdministrationService() .executeSQL("select count(*) from person_name where person_id = 1", true).get(0).get(0); Assert.assertEquals(before.intValue() - 1, after.intValue()); Assert.assertNull(service.getPersonNameByUuid(nameUuid)); }
From source file:com.impetus.client.couchdb.crud.CouchDBClientTest.java
@Test @PerfTest(invocations = 10)/*w w w.java 2 s. c o m*/ public void testCRUDWithBatch() { Map<String, String> batchProperty = new HashMap<String, String>(1); batchProperty.put(PersistenceProperties.KUNDERA_BATCH_SIZE, "5"); EntityManagerFactory emf = Persistence.createEntityManagerFactory(_PU, batchProperty); EntityManager em = emf.createEntityManager(); Map<String, Client> clients = (Map<String, Client>) em.getDelegate(); CouchDBClient client = (CouchDBClient) clients.get(_PU); Assert.assertEquals(5, ((Batcher) client).getBatchSize()); final String originalName = "vivek"; for (int i = 0; i < 9; i++) { PersonCouchDB object = new PersonCouchDB(); object.setAge(32); object.setPersonId(ROW_KEY + i); object.setPersonName(originalName); em.persist(object); if (i >= 5) { PersonCouchDB result = (PersonCouchDB) client.find(PersonCouchDB.class, ROW_KEY + i); Assert.assertNull(result); } else if (i > 0 && i % 4 == 0) { PersonCouchDB result = (PersonCouchDB) client.find(PersonCouchDB.class, ROW_KEY + i); Assert.assertNotNull(result); Assert.assertEquals(result.getPersonId(), object.getPersonId()); Assert.assertEquals(result.getAge(), object.getAge()); Assert.assertEquals(result.getPersonName(), object.getPersonName()); } } em.flush(); em.clear(); em.close(); em = null; }
From source file:de.hybris.platform.catalog.jalo.synchronization.ItemCopyCreatorServiceLayerTest.java
@Test public void testExceptionDuringCreation() throws InterruptedException { createConstraint = createCreateConstraint(PRODUCT_FAILING_ON_CREATE); modelService.save(createConstraint); validationService.reloadValidationEngine(); final CatalogVersionSyncCopyContext ctx = new CatalogVersionSyncCopyContext(syncJob, syncCronJob, worker); final Product source = ProductManager.getInstance().createProduct(PRODUCT_FAILING_ON_CREATE + " foo "); final Product target = null; final Collection<String> whiteList = Arrays .asList(Product.CODE/*, Product.NAME, Product.TYPE, Product.PK*/); final Collection<String> blackList = Arrays.asList(Product.MODIFIED_TIME, Product.CREATION_TIME); final Map<String, Object> presets = Collections.EMPTY_MAP; final ItemCopyCreator copyCreator = new ItemCopyCreator(ctx, null, source, target, blackList, whiteList, presets);/*from www . j a v a 2s .co m*/ Assert.assertNull(copyCreator.copy()); }
From source file:com.impetus.kundera.EntityManagerImplTest.java
@Test public void testSingleEntityCRUD_EmCleared() { // Persist/*w ww. j a va2 s. c o m*/ final SampleEntity entity = new SampleEntity(); entity.setKey(1); entity.setName("Amry"); entity.setCity("Delhi"); em.persist(entity); Assert.assertTrue(em.contains(entity)); em.clear(); Assert.assertFalse(em.contains(entity)); SampleEntity found = em.find(SampleEntity.class, 1, new HashMap<String, Object>()); assertSampleEntity(found); found.setName("Xamry"); found.setCity("Noida"); em.clear(); em.merge(found); SampleEntity foundAfterMerge = em.find(SampleEntity.class, 1); assertUpdatedSampleEntity(foundAfterMerge); // Modify record in dummy database directly SampleEntity se = (SampleEntity) DummyDatabase.INSTANCE.getSchema("KunderaTest").getTable("table") .getRecord(new Integer(1)); se.setCity("Singapore"); em.refresh(foundAfterMerge); SampleEntity found2 = em.find(SampleEntity.class, 1); Assert.assertEquals("Singapore", found2.getCity()); em.detach(foundAfterMerge); em.clear(); found = em.find(SampleEntity.class, 1); em.remove(found); em.clear(); SampleEntity foundAfterDeletion = em.find(SampleEntity.class, 1); Assert.assertNull(foundAfterDeletion); }