Example usage for java.lang IllegalArgumentException getMessage

List of usage examples for java.lang IllegalArgumentException getMessage

Introduction

In this page you can find the example usage for java.lang IllegalArgumentException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:gaffer.export.ExporterTest.java

@Test
public void shouldThrowExceptionWhenAddIfExporterNotInitialisedWithUser() {
    // Given// ww w  . j av a 2s  .  c o m
    final Iterable<?> values = Arrays.asList("item1", "item2");
    final User user = new User();
    final ExporterImpl exporter = new ExporterImpl();

    // When / Then
    try {
        exporter.add(values, user);
        fail("NotImplementedException expected");
    } catch (final IllegalArgumentException e) {
        assertNotNull(e.getMessage());
    }
}

From source file:com.vmware.loginsightapi.TestConfiguration.java

@Test
public void testBuildConfigInvalidAgentId() {
    Map<String, String> configData = new HashMap<String, String>();
    try {//from   w  w w.  ja  v a  2s.  co m
        configData.put(Configuration.KEY_LI_HOST, "hostname");
        configData.put(Configuration.KEY_LI_USER, "username");
        configData.put(Configuration.KEY_LI_PASSWORD, "password");
        configData.put(Configuration.KEY_LI_PORT, Integer.toString(Configuration.DEFAULT_PORT));
        configData.put(Configuration.KEY_LI_INGESTION_PORT,
                Integer.toString(Configuration.DEFAULT_INGESTION_PORT));
        configData.put(Configuration.KEY_CONNECTION_SCHEME, Configuration.DEFAULT_SCHEME);
        configData.put(Configuration.KEY_AGENT_ID, "");
        Configuration config = Configuration.buildConfig(configData);
    } catch (IllegalArgumentException ex) {
        assertEquals(ex.getMessage(), "Invalid Agent ID");
    }
}

From source file:gaffer.export.ExporterTest.java

@Test
public void shouldThrowExceptionWhenAddIfUserIsNull() {
    // Given//w w  w . j  a va2s  .  com
    final Iterable<?> values = Arrays.asList("item1", "item2");
    final User user = new User();
    final ExporterImpl exporter = new ExporterImpl();
    exporter.initialise("key", null, user);

    // When / Then
    try {
        exporter.add(values, null);
        fail("NotImplementedException expected");
    } catch (final IllegalArgumentException e) {
        assertNotNull(e.getMessage());
    }
}

From source file:gaffer.export.ExporterTest.java

@Test
public void shouldThrowExceptionWhenGetIfExporterNotInitialisedWithUser() {
    // Given/*from   w  w  w  .j av a  2s  .c om*/
    final User user = new User();
    final int start = 0;
    final int end = 10;
    final ExporterImpl exporter = new ExporterImpl();

    // When / Then
    try {
        exporter.get(user, start, end);
        fail("NotImplementedException expected");
    } catch (final IllegalArgumentException e) {
        assertNotNull(e.getMessage());
    }
}

From source file:edu.cudenver.bios.chartsvc.resource.LegendResource.java

/**
 * Disallow GET requests/*from  ww w  .  java2  s.  com*/
 */

@Get
public Representation represent(Variant variant) {
    queryParams = getRequest().getResourceRef().getQueryAsForm();
    LegendImageRepresentation rep = null;
    try {
        // parse the chart parameters from the entity body
        Chart chartSpecification = ChartResourceHelper.chartFromQueryString(queryParams, false);

        // build a JFreeChart from the specs
        XYPlot renderedChart = buildScatterPlot(chartSpecification);
        // write to an image representation
        rep = new LegendImageRepresentation(renderedChart, chartSpecification.getWidth(),
                chartSpecification.getHeight());

        // Add file save headers if requested
        String saveStr = queryParams.getFirstValue(FORM_TAG_SAVE);
        boolean save = Boolean.parseBoolean(saveStr);
        if (save) {
            Form responseHeaders = (Form) getResponse().getAttributes().get("org.restlet.http.headers");
            if (responseHeaders == null) {
                responseHeaders = new Form();
                getResponse().getAttributes().put("org.restlet.http.headers", responseHeaders);
            }
            responseHeaders.add("Content-type", "application/force-download");
            responseHeaders.add("Content-disposition", "attachment; filename=chart.jpg");
        }

        getResponse().setEntity(rep);
        getResponse().setStatus(Status.SUCCESS_CREATED);
    } catch (IllegalArgumentException iae) {
        ChartLogger.getInstance().error(iae.getMessage());
        try {
            getResponse().setEntity(new ErrorXMLRepresentation(iae.getMessage()));
        } catch (IOException e) {
        }
        getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
    } catch (ResourceException re) {
        ChartLogger.getInstance().error(re.getMessage());
        try {
            getResponse().setEntity(new ErrorXMLRepresentation(re.getMessage()));
        } catch (IOException e) {
        }
        getResponse().setStatus(re.getStatus());
    }

    return rep;
}

From source file:com.rcn.controller.ResourceController.java

@RequestMapping(value = "/license-key", method = RequestMethod.POST)
public String licenseKeyPost(@RequestParam("name") String name, @RequestParam("validFor") Integer validFor,
        @RequestParam("keyExpires") Integer keyExpires,
        @RequestParam("activationsNumber") Integer activationsNumber,
        @RequestParam("customKey") String customKey, @RequestParam("key") Long key,
        @RequestParam("val") String val,
        @RequestParam(name = "resourceGroup", required = false) boolean resourceGroup,
        @RequestParam(name = "customNumber", required = false) boolean customNumber, Authentication principal,
        Model model) {//from  ww  w. ja v a  2 s . c  o  m

    RcnUserDetail user = (RcnUserDetail) principal.getPrincipal();
    Long targetUserId = user.getTargetUser().getId();
    try {
        String lk = customNumber
                ? IntStream.range(0, 1).mapToObj(a -> customKey.toUpperCase()).filter(a -> a.length() == 16)
                        .filter(a -> resourceRepository.containsKey(a) == null).findFirst()
                        .orElseThrow(() -> new IllegalArgumentException(l("invalid.custom.number")))
                : IntStream.range(0, 10).mapToObj(a -> generateLicenseKey())
                        .filter(a -> resourceRepository.containsKey(a) == null).findFirst()
                        .orElseThrow(() -> new IllegalArgumentException(l("cant.generate.license.key")));

        Long id = resourceRepository.createLicenseKey(targetUserId, name, lk, validFor, keyExpires,
                activationsNumber);
        if (resourceGroup) {
            resourceRepository.licenseKeyToResourceGroup(targetUserId, id, key);
        }
    } catch (IllegalArgumentException e) {
        model.addAttribute("error", e.getMessage());
    }

    return "license-key";
}

From source file:gaffer.export.ExporterTest.java

@Test
public void shouldThrowExceptionWhenAddIfDifferentUsers() {
    // Given/*from  w w  w. j  a v  a2  s . co m*/
    final Iterable<?> values = Arrays.asList("item1", "item2");
    final User user1 = new User("user1");
    final User user2 = new User("user2");
    final ExporterImpl exporter = new ExporterImpl();
    exporter.initialise("key", null, user1);

    // When / Then
    try {
        exporter.add(values, user2);
        fail("NotImplementedException expected");
    } catch (final IllegalArgumentException e) {
        assertNotNull(e.getMessage());
    }
}

From source file:gaffer.export.ExporterTest.java

@Test
public void shouldThrowExceptionWhenGetIfUserIsNull() {
    // Given// w w  w  .j  ava2 s  .  co  m
    final User user = new User();
    final int start = 0;
    final int end = 10;
    final ExporterImpl exporter = new ExporterImpl();
    exporter.initialise("key", null, user);

    // When / Then
    try {
        exporter.get(null, start, end);
        fail("NotImplementedException expected");
    } catch (final IllegalArgumentException e) {
        assertNotNull(e.getMessage());
    }
}

From source file:ch.slf.FFTRealOneSided.java

/**
 * @param values A two dimensional array that contains in first dimension (values[])
 *        the differents steps, and in the second dimension (value[step][]) the different
 *        measures for this step./*from w  ww. j av  a2s  . co  m*/
 * @param timestamps An array that contains the timestamps in milli seconds at every
 *        step.
 * @return
 */
public void process(double[] values, long[] timestampsInMSec) {

    if (logger.isDebugEnabled()) {
        logger.debug("INPUT FFT DATA");
        for (int i = 0; i < values.length; i++) {
            logger.debug(values[i] + "\n");
        }
    }

    int windowSize = timestampsInMSec.length;
    logger.debug("Window Size: " + windowSize);

    long deltaTimeStampInSec = (timestampsInMSec[timestampsInMSec.length - 1] - timestampsInMSec[0]) / 1000;
    logger.debug("Delta Time Stamp in s: " + deltaTimeStampInSec);

    double sampling_rate = ((double) windowSize / (double) deltaTimeStampInSec);
    logger.debug("Sampling Rate: " + sampling_rate);

    double df = 1 / (double) deltaTimeStampInSec;
    logger.debug("df: " + df);

    int nbOfPointsToReturn = (windowSize / 2) + 1;
    logger.debug("Number of points to return: " + nbOfPointsToReturn);

    long middleTimeStamp = timestampsInMSec[0] + ((deltaTimeStampInSec / 2) * 1000);

    Complex[] fftResult = null;
    try {

        fftResult = fft.transform2(values);

        double[] realPartFftResult = new double[nbOfPointsToReturn];
        for (int i = 0; i < realPartFftResult.length; i++) {
            realPartFftResult[i] = fftResult[i].getReal();
        }

        //
        Serializable[] dataOut = new Serializable[2];
        // df
        dataOut[0] = df;
        // data
        StringBuilder sb = new StringBuilder();
        sb.append(realPartFftResult[0]);
        for (int i = 1; i < realPartFftResult.length; i++) {
            sb.append("," + realPartFftResult[i]);
        }
        dataOut[1] = sb.toString().getBytes();

        //
        StreamElement se = new StreamElement(outputStructure, dataOut, middleTimeStamp);
        logger.debug("FFT StreamElement produced: " + se);
        dataProduced(se);

    } catch (IllegalArgumentException e) {
        logger.error("Unable to compute the FFT: " + e.getMessage());
    }

    catch (Exception e) {
        logger.error("Unable to compute the FFT: " + e.getMessage());
    }
}

From source file:gaffer.export.ExporterTest.java

@Test
public void shouldThrowExceptionWhenGetIfDifferentUsers() {
    // Given//from  ww w .  j  a  v  a 2  s .  c  om
    final User user1 = new User("user1");
    final User user2 = new User("user2");
    final int start = 0;
    final int end = 10;
    final ExporterImpl exporter = new ExporterImpl();
    exporter.initialise("key", null, user1);

    // When / Then
    try {
        exporter.get(user2, start, end);
        fail("NotImplementedException expected");
    } catch (final IllegalArgumentException e) {
        assertNotNull(e.getMessage());
    }
}