List of usage examples for org.springframework.util Assert isNull
@Deprecated public static void isNull(@Nullable Object object)
From source file:org.appverse.web.framework.backend.persistence.services.integration.impl.test.UserRepositoryImplTest.java
@Override public void delete() throws Exception { UserDTO userDTORetrieved = userRepository.retrieve(userDTO); Assert.isNull(userDTORetrieved); userRepository.persist(userDTO);/*from w w w . ja v a2 s . c om*/ userDTORetrieved = userRepository.retrieve(userDTO); Assert.notNull(userDTORetrieved); userRepository.delete(userDTO); userDTORetrieved = userRepository.retrieve(userDTO); Assert.isNull(userDTORetrieved); }
From source file:cz.muni.fi.airport.tests.AirplaneDaoTest.java
@Test public void testRemove() { Airplane airA = new Airplane(); airA.setCapacity(1);//from w w w. ja va 2 s .com airA.setName("airA"); airA.setType("typeA"); airplaneDao.create(airA); Assert.notNull(airplaneDao.findById(airA.getId())); airplaneDao.delete(airA); Assert.isNull(airplaneDao.findById(airA.getId())); }
From source file:com.laxser.blitz.lama.provider.jdbc.JdbcDataAccessProvider.java
/** * findPlugin<br>//from w w w. j a v a2 s . c o m * * @return * * @author tai.wang@opi-corp.com May 26, 2010 - 4:30:09 PM */ protected JdbcWrapper[] findJdbcWrappers() { // JdbcWrapperscoreprototype @SuppressWarnings("unchecked") Collection<JdbcWrapper> jdbcWrappers = this.applicationContext.getBeansOfType(JdbcWrapper.class).values(); JdbcWrapper[] arrayJdbcWrappers = jdbcWrappers.toArray(new JdbcWrapper[0]); for (JdbcWrapper jdbcWrapper : arrayJdbcWrappers) { Assert.isNull(jdbcWrapper.getJdbc());// jdbc should be null here } Arrays.sort(arrayJdbcWrappers, new Comparator<JdbcWrapper>() { @Override public int compare(JdbcWrapper thees, JdbcWrapper that) { Order thessOrder = thees.getClass().getAnnotation(Order.class); Order thatOrder = that.getClass().getAnnotation(Order.class); int thessValue = thessOrder == null ? 0 : thessOrder.value(); int thatValue = thatOrder == null ? 0 : thatOrder.value(); return thessValue - thatValue; } }); return arrayJdbcWrappers; }
From source file:cz.muni.fi.airport.tests.StewardDaoTest.java
@Test public void testCreate() { Assert.isNull(s1.getId()); stewardDao.create(s1); Assert.notNull(stewardDao.findById(s1.getId())); }
From source file:com.azaptree.services.security.commands.subjectRepository.CreateSubject.java
public CreateSubject(final HashServiceConfiguration hashServiceConfig) { Assert.notNull(hashServiceConfig, "hashServiceConfig is required"); this.hashService = hashServiceConfig.getHashService(); this.hashServiceId = hashServiceConfig.getEntityId(); this.setValidator(new CommandContextValidatorSupport() { @Override/* w w w . ja v a 2 s .c om*/ protected void checkOutput(Command command, Context ctx) { // none required } @Override protected void checkInput(Command command, Context ctx) { // check that the subject does not have an entity id, which would imply the subject already exists in the database final Subject subject = get(ctx, SUBJECT); Assert.isNull(subject.getEntityId()); final Optional<UUID> createdBy = subject.getCreatedByEntityId(); if (createdBy.isPresent()) { if (!subjectDAO.exists(createdBy.get())) { throw new IllegalArgumentException("Invalid entity id for created by: " + createdBy.get()); } } final Credential[] credentials = get(ctx, CREDENTIALS); Assert.isTrue(ArrayUtils.isNotEmpty(credentials), "credentials are required"); final Set<String> names = new HashSet<>(); for (Credential credential : credentials) { Assert.isTrue(names.add(credential.getName()), String.format("Duplicate credential name: %s", credential.getName())); if (!securityCredentialsService.isCredentialSupported(credential.getName(), credential.getCredential())) { if (!securityCredentialsService.getSupportedCredentials() .containsKey(credential.getName())) { throw new UnknownCredentialException(credential.getName()); } throw new UnsupportedCredentialTypeException( String.format("credential is not supported : %s -> %s", credential.getName(), credential.getCredential().getClass().getName())); } } } }); this.setInputKeys(SUBJECT, CREDENTIALS); this.setOutputKeys(SUBJECT); }
From source file:org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.DrugResource1_8Test.java
/** * Tests {@link BaseDelegatingResource#setConvertedProperties(Object, java.util.Map, DelegatingResourceDescription, boolean)} *///from w ww . java 2 s. c o m @Test public void setConvertedProperties_shouldAllowSettingANullValue() { DrugResource1_8 resource = new DrugResource1_8(); Drug drug = new Drug(); drug.setRoute(new Concept()); Map<String, Object> propertyMap = new HashMap<String, Object>(); propertyMap.put("route", null); resource.setConvertedProperties(drug, propertyMap, resource.getUpdatableProperties(), false); Assert.isNull(drug.getRoute()); }
From source file:org.appverse.web.framework.backend.persistence.services.integration.impl.test.UserRepositoryImplTest.java
@Override @Test/*from w w w. j av a 2 s. c o m*/ public void persist() throws Exception { UserDTO userDTORetrieved = userRepository.retrieve(userDTO); Assert.isNull(userDTORetrieved); userRepository.persist(userDTO); userDTORetrieved = userRepository.retrieve(userDTO); Assert.notNull(userDTORetrieved); }
From source file:cz.muni.fi.airport.tests.FlightDaoTest.java
@Test public void testCreate() { Assert.isNull(f1.getId()); flightDao.create(f1); Assert.notNull(flightDao.findById(f1.getId())); }
From source file:org.appverse.web.framework.backend.persistence.services.integration.impl.test.UserRepositoryImplTest.java
@Override @Test/* ww w .j a v a 2 s . c om*/ public void retrieveByBean() throws Exception { UserDTO userDTORetrieved = userRepository.retrieve(userDTO); Assert.isNull(userDTORetrieved); persist(); userDTORetrieved = userRepository.retrieve(new UserDTO()); Assert.isNull(userDTORetrieved); userDTORetrieved = userRepository.retrieve(userDTO); Assert.notNull(userDTORetrieved); }
From source file:cz.muni.fi.airport.tests.FlightDaoTest.java
@Test public void testFind() { Flight f1 = new Flight(); f1.setAirplane(a1);/* w w w .j a v a 2 s .com*/ f1.setArrival(date2); f1.setDeparture(date1); f1.setOrigin(d1); f1.setDestination(d2); f1.addSteward(s1); f1.addSteward(s2); Assert.isNull(f1.getId()); flightDao.create(f1); f1 = flightDao.findById(f1.getId()); Assert.notNull(f1); assert f1.getAirplane().equals(a1); assert f1.getArrival().equals(date2); assert f1.getDeparture().equals(date1); assert f1.getOrigin().equals(d1); assert f1.getDestination().equals(d2); assert f1.getStewards().size() == 2; }