Example usage for org.springframework.util Assert isTrue

List of usage examples for org.springframework.util Assert isTrue

Introduction

In this page you can find the example usage for org.springframework.util Assert isTrue.

Prototype

@Deprecated
public static void isTrue(boolean expression) 

Source Link

Document

Assert a boolean expression, throwing an IllegalArgumentException if the expression evaluates to false .

Usage

From source file:security.UserAccount.java

public void addAuthority(Authority authority) {
    Assert.notNull(authority);
    Assert.isTrue(!authorities.contains(authority));

    authorities.add(authority);
}

From source file:edu.pitt.dbmi.ccd.anno.access.AccessResourceAssembler.java

/**
 * Convert Accesses to AccessResources//w  w  w  .j a va2  s  .c  o  m
 *
 * @param accesses entities
 * @return list of resources
 */
@Override
public List<AccessResource> toResources(Iterable<? extends Access> accesses) throws IllegalArgumentException {
    // Assert accesses is not empty
    Assert.isTrue(accesses.iterator().hasNext());
    return StreamSupport.stream(accesses.spliterator(), false).map(this::toResource)
            .collect(Collectors.toList());
}

From source file:org.synyx.hades.dao.query.QueryCreator.java

/**
 * Creates a new {@link QueryCreator} for the given {@link QueryMethod}.
 * //from w w w  . ja va2 s . c  o m
 * @param finderMethod
 */
public QueryCreator(QueryMethod finderMethod) {

    Assert.isTrue(!finderMethod.isModifyingQuery());

    this.method = finderMethod;
}

From source file:de.iew.raspimotion.controllers.MotionJpegController.java

@RequestMapping(value = "image/{imagename:.+}")
public void imageAction(HttpServletResponse response, @PathVariable String imagename) throws Exception {
    Assert.isTrue(validateImagename(imagename));

    FileDescriptor file = this.fileDao.getFileLastCreated(imagename);

    if (file == null) {
        throw new NoSuchElementException("Image was not found");
    }/*from   w  ww.  ja va  2s . co m*/

    sendCachingHeaders(response);
    response.setContentType("image/jpeg");
    response.setContentLength(new Long(file.getFilesize()).intValue());

    sendImageAsJpeg(file, response);
}

From source file:org.spring.data.gemfire.app.dao.GemfireRegionCustomerDao.java

@PostConstruct
public void init() {
    Region customers = customersRegion();
    Assert.isTrue("Customers".equals(customers.getName()));
    System.out.printf("%1$s initialized!%n", this);
}

From source file:frk.gpssimulator.service.impl.DefaultKmlService.java

@Override
public final void setupKmlIntegration(Set<Long> intanceIds, Point lookAtPoint) {
    Assert.notEmpty(intanceIds);//from ww w. j ava 2s  .  com
    Assert.isTrue(intanceIds.size() >= 1);

    File f = new File("gps.kml");

    Kml kml = KmlFactory.createKml();
    Folder folder = KmlFactory.createFolder();
    folder.setOpen(true);
    folder.setName("Contains GPS Coordinates");
    kml.setFeature(folder);

    final LookAt lookAt = KmlFactory.createLookAt();
    lookAt.setLatitude(lookAtPoint.getLatitude());
    lookAt.setLongitude(lookAtPoint.getLongitude());
    lookAt.setAltitude(8000);
    lookAt.setAltitudeMode(AltitudeMode.ABSOLUTE);
    ;
    folder.setAbstractView(lookAt);

    for (long instanceId : intanceIds) {
        Link link = KmlFactory.createLink();
        link.setHref(KML_POSITION_FILE_NAME + instanceId + KML_POSITION_FILE_SUFFIX);
        link.setRefreshMode(RefreshMode.ON_INTERVAL);
        link.setRefreshInterval(1.0);

        NetworkLink networkLink = KmlFactory.createNetworkLink();
        networkLink.setName("GPS link " + instanceId);
        networkLink.setOpen(true);
        networkLink.setLink(link);
        folder.addToFeature(networkLink);
    }

    final OutputStream out;

    try {
        out = new FileOutputStream(f);
    } catch (FileNotFoundException e) {
        throw new IllegalStateException(e);
    }

    try {
        marshaller.marshal(kml, new StreamResult(out));
    } catch (XmlMappingException | IOException e) {
        throw new IllegalStateException(e);
    }
}

From source file:com.jaxio.celerio.factory.PrimaryKeyFactory.java

private PrimaryKey buildSimplePrimaryKey(Entity entity) {
    Assert.isTrue(entity.isRoot());

    Table table = config.getMetadata().getTableByName(entity.getTableName());
    Attribute pkAttribute = entity.getAttributeByTableAndColumnName(table.getName(), table.getPrimaryKey());
    pkAttribute.setSimplePk(true);//from   www . j  av  a2  s  .  com
    overridePkFieldName(pkAttribute);
    return new SimplePrimaryKey(entity, pkAttribute);
}

From source file:org.focusns.service.core.impl.ProjectLinkServiceImpl.java

public void removeProjectLink(ProjectLink link) {
    if (link.getId() > 0) {
        linkDao.delete(link.getId());/*  w  w  w . j av  a2  s .  co m*/
    } else {
        Assert.isTrue(link.getFromProjectId() > 0);
        Assert.isTrue(link.getToProjectId() > 0);
        linkDao.deleteByFromAndToProjectId(link.getFromProjectId(), link.getToProjectId());
    }
    //
    fillProjectLink(link);
}

From source file:fr.rktv.iamcore.test.hibernate.AuthHibernateDAOTest.java

/**
 * Test case checking success case of licensedUserAlreadyExist method of Authenticate DAO
 * @throws IllegalArgumentException//from   www. jav a 2 s.c  om
 * @throws IllegalAccessException
 */
@Test
public void licesUsrAlreadyExistTestSucc() throws IllegalArgumentException, IllegalAccessException {
    final Credentail user = new Credentail("testuser", "test");
    user.setLicense(license);
    authenticationDAO.addUser(user);
    Assert.isTrue(authenticationDAO.licensedUserAlreadyExist(license));
}

From source file:org.oncoblocks.centromere.sql.test.GenericJdbcRepositoryTests.java

@Test
public void findAllTest() {
    List<Subject> subjects = subjectRepository.findAll();
    Assert.notNull(subjects);//from  w  w w.  j a  va 2  s .co m
    Assert.notEmpty(subjects);
    Assert.isTrue(subjects.size() == 5);
    Subject subject = subjects.get(0);
    Assert.notNull(subject);
    Assert.isTrue(subject.getId().equals(1L));
    Assert.isTrue(subject.getName().equals("PersonA"));
}