Example usage for org.springframework.util Assert notEmpty

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

Introduction

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

Prototype

@Deprecated
public static void notEmpty(@Nullable Map<?, ?> map) 

Source Link

Document

Assert that a Map contains entries; that is, it must not be null and must contain at least one entry.

Usage

From source file:org.eclipse.swordfish.core.util.ServiceMixSupport.java

public static void setSourceService(ComponentContext componentContext, MessageExchange messageExchange,
        QName sourceService) {/*from w w  w  .j  a  v  a 2s .  co  m*/
    Assert.notNull(componentContext);
    Assert.notNull(messageExchange);
    Assert.notNull(sourceService);
    ServiceEndpoint[] serviceEndpoints = componentContext.getEndpointsForService(sourceService);
    Assert.notEmpty(serviceEndpoints);
    messageExchange.setProperty(JbiConstants.SENDER_ENDPOINT,
            serviceEndpoints[0].getServiceName() + ":" + serviceEndpoints[0].getEndpointName());
}

From source file:net.joaopeixoto.geode.server.functions.PatternFunctions.java

/**
 * Replace here with your favorite algorithm
 *///from   w ww. j a v a2 s  .  c om
@GemfireFunction
public DistanceResult distance(List<Metric> metrics) {
    Assert.notEmpty(metrics);
    Metric first = metrics.get(0);

    LinkedList<Metric> currentWindow = new LinkedList<>();
    LinkedList<Metric> matchedWindow = new LinkedList<>();
    double minDistance = THRESHOLD;
    int matchCount = 0;

    log.debug("Checking for patterns comparing with {}", metrics);

    List<Metric> localValues = new ArrayList<>(metricRegion.values());

    /**
     * Ensure the local values are ordered. {@link Region#values()} does not guarantee it.
     */
    Collections.sort(localValues);
    for (Metric metric : localValues) {

        // Ignore overlapping points or noise
        if (metric.getTimestamp() >= first.getTimestamp() || metric.getValue().compareTo(BigDecimal.TEN) < 1) {
            if (!currentWindow.isEmpty()) {
                currentWindow.pop();
            }
            continue;
        }

        currentWindow.add(metric);
        if (currentWindow.size() > 13) {
            currentWindow.pop();
        }

        /**
         * We only compare windows the same size (for now)
         */
        if (currentWindow.size() == 13) {

            TimeWarpInfo compare = DTW.compare(metricToSeries(currentWindow), metricToSeries(metrics),
                    Distances.EUCLIDEAN_DISTANCE);
            if (compare.getDistance() <= 1D) {
                matchCount++;
                matchedWindow = new LinkedList<>(currentWindow);
            }
        }
    }

    if (matchCount > 0) {
        return new DistanceResult(matchedWindow, minDistance, matchCount);
    }
    return null;
}

From source file:org.drizzly.MySQLConnectionTest.java

@Test
public void testGetAllEmployees() {
    ApplicationContext application = new AnnotationConfigApplicationContext(EmployeeManager.class);
    EmployeeManager emp = application.getBean(EmployeeManager.class);
    Long empId = new Long(1);
    EmployeeDAO dao = new EmployeeDAO();
    Assert.notEmpty(dao.findAllEmployees());

}

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

@Test
public void simpleQueryTest() {

    SqlBuilder sqlBuilder = new SqlBuilder(tableDescription);
    sqlBuilder.where(equal("name", "Joe"));

    String sql = sqlBuilder.toSql();
    System.out.println(sql);/*w  w w.ja v  a 2  s. co  m*/
    Assert.notNull(sql);

    List<Object> values = sqlBuilder.getQueryParameterValues();
    Assert.notNull(values);
    Assert.notEmpty(values);
    Assert.isTrue(values.size() == 1);
    String name = (String) values.get(0);
    Assert.isTrue("Joe".equals(name));

}

From source file:com.kurento.kmf.jsonrpcconnector.internal.server.config.DefaultJsonRpcHandlerRegistration.java

public JsonRpcHandlerRegistration addPerSessionHandler(Class<? extends JsonRpcHandler<?>> handlerClass,
        String[] paths) {/* w ww  .j  av a  2s. c  o  m*/
    Assert.notNull(handlerClass);
    Assert.notEmpty(paths);
    this.perSessionHandlerClassMap.put(handlerClass, Arrays.asList(paths));
    return this;
}

From source file:org.esco.portlet.flashinfo.FlashInfoServiceTest.java

@Test
public void test1() throws Exception {
    MockRenderRequest request = new MockRenderRequest();
    request.setServerName("edu.internal.fr");
    request.setServerPort(8443);//from   w  ww .  j  a v a  2  s.c o m
    request.setContextPath("/portal");
    request.setScheme("http");
    request.addParameter("param1", "value");

    MockPortletPreferences prefs = new MockPortletPreferences();
    prefs.setValue(FlashInfoServiceImpl.getPrefFlashUrl(), "/test/{ESCOUAICourant}");
    request.setPreferences(prefs);

    List<FlashInfo> fil = flashInfoService.retrieveFlashInfos(request);
    Assert.notNull(fil);
    Assert.notEmpty(fil);
    Assert.isTrue(fil.size() == 5);
    //Assert.assertEquals(url,"http://edu.internal.fr:8443/portal/test/" + MockUserResourceImpl.getESCOUAICourant().get(0));
}

From source file:com.miko.demo.neo4j.service.EntityASearchTest.java

@Test
public void searchEntityATest() {

    EntityA entityA = entityAService.findByDescription("description1");
    logger.debug("DELETE EntityA = " + entityA);
    for (EntityB entityB : entityA.getEntityBSet()) {
        logger.debug("DELETE entityB = " + entityB.getId());
    }/*from  w  ww.jav  a  2s  . c om*/
    Assert.notNull(entityA);
    Assert.notEmpty(entityA.getEntityBSet());
}

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

@Override
public final void setupKmlIntegration(Set<Long> intanceIds, Point lookAtPoint) {
    Assert.notEmpty(intanceIds);
    Assert.isTrue(intanceIds.size() >= 1);

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

    Kml kml = KmlFactory.createKml();// w  w w  .j  ava  2s. c o m
    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:org.red5.server.script.jython.JythonScriptFactory.java

@SuppressWarnings({ "rawtypes" })
public JythonScriptFactory(String scriptSourceLocator, Class[] scriptInterfaces) {
    Assert.hasText(scriptSourceLocator);
    Assert.notEmpty(scriptInterfaces);
    this.scriptSourceLocator = scriptSourceLocator;
    this.scriptInterfaces = scriptInterfaces;
    this.arguments = null;
}

From source file:com.kurento.kmf.jsonrpcconnector.internal.server.config.DefaultJsonRpcHandlerRegistration.java

public JsonRpcHandlerRegistration addPerSessionHandler(String beanName, String[] paths) {
    Assert.notNull(beanName);//from   w  w w. ja va 2s  .c o  m
    Assert.notEmpty(paths);
    this.perSessionHandlerBeanNameMap.put(beanName, Arrays.asList(paths));
    return this;
}