List of usage examples for java.lang AssertionError AssertionError
public AssertionError()
From source file:org.sentilo.common.rest.hmac.HMACBuilder.java
private HMACBuilder() { throw new AssertionError(); }
From source file:de.unentscheidbar.validation.builtin.EmailAddressValidator.java
@Override protected void validateNonEmptyString(ValidationResult problems, String model) { String[] nameAndHost = StringUtils.splitPreserveAllTokens(model, '@'); switch (nameAndHost.length) { case 0://w w w .j av a2 s. c o m // String is empty - cannot happen in validateNonEmptyString throw new AssertionError(); case 1: problems.add(Id.NO_AT_SYMBOL, model); break; case 2: validateLocalPart(nameAndHost[0], model, problems); validateGlobalPart(nameAndHost[1], model, problems); break; default: assert nameAndHost.length > 2; problems.add(Id.EMAIL_HAS_MORE_THAN_ONE_AT_SYMBOL, model); break; } }
From source file:com.attribyte.essem.ESUserStore.java
/** * Creates the user store./*from w w w .ja v a2 s .c om*/ * @param index The index. * @return Was the store created? * @throws IOException on create error. */ public boolean createStore(final String index) throws IOException { String indexName = index + SUFFIX; try { URI indexURI = new URI(esEndpoint.uri.getScheme(), esEndpoint.uri.getUserInfo(), esEndpoint.uri.getHost(), esEndpoint.uri.getPort(), "/" + indexName, null, null); Request esRequest = esEndpoint.putRequestBuilder(indexURI, schema.toByteArray()).create(); Response esResponse = httpClient.send(esRequest); boolean created = esResponse.getStatusCode() / 100 == 2; if (created) { logger.info("Created ES index, '" + indexName + "'"); } else { logger.warn("ES Index, '" + indexName + "' exists!"); } return created; } catch (URISyntaxException use) { throw new AssertionError(); } }
From source file:org.jhk.pulsing.web.service.prod.helper.PulseServiceUtil.java
public static Map<Long, String> processTrendingPulseSubscribe(Set<String> tps, ObjectMapper objMapper) { @SuppressWarnings("unchecked") Map<Long, String> tpSubscriptions = Collections.EMPTY_MAP; final Map<String, Integer> count = new HashMap<>(); tps.parallelStream().forEach(tpsIdValueCounts -> { try {//from www . j a va 2 s . c o m _LOGGER.debug( "PulseServiceUtil.processTrendingPulseSubscribe: trying to convert " + tpsIdValueCounts); Map<String, Integer> converted = objMapper.readValue(tpsIdValueCounts, _TRENDING_PULSE_SUBSCRIPTION_TYPE_REF); _LOGGER.debug("PulseServiceUtil.processTrendingPulseSubscribe: sucessfully converted " + converted.size()); //Structure is <id>0x07<value>0x13<timestamp> -> count; i.e. {"10020x07Mocked 10020x13<timestamp>" -> 1} //Need to split the String content, gather the count for the searched interval //and return the sorted using Java8 stream //TODO impl better Map<String, Integer> computed = converted.entrySet().stream().reduce(new HashMap<String, Integer>(), (Map<String, Integer> mapped, Entry<String, Integer> entry) -> { String[] split = entry.getKey() .split(CommonConstants.TIME_INTERVAL_PERSIST_TIMESTAMP_DELIM); Integer value = entry.getValue(); mapped.compute(split[0], (key, val) -> { return val == null ? value : val + value; }); return mapped; }, (Map<String, Integer> result, Map<String, Integer> aggregated) -> { result.putAll(aggregated); return result; }); computed.entrySet().parallelStream().forEach(entry -> { Integer value = entry.getValue(); count.compute(entry.getKey(), (key, val) -> { return val == null ? value : val + value; }); }); } catch (Exception cException) { cException.printStackTrace(); } }); if (count.size() > 0) { tpSubscriptions = count.entrySet().stream() .sorted(Map.Entry.comparingByValue(Comparator.reverseOrder())) .collect(Collectors.toMap( entry -> Long.parseLong( entry.getKey().split(CommonConstants.TIME_INTERVAL_ID_VALUE_DELIM)[0]), entry -> entry.getKey().split(CommonConstants.TIME_INTERVAL_ID_VALUE_DELIM)[1], (x, y) -> { throw new AssertionError(); }, LinkedHashMap::new)); } return tpSubscriptions; }
From source file:io.kahu.hawaii.rest.DefaultResponseManagerTest.java
@Test public void testToResponseWithRuntimeException() throws Exception { ResponseEntity<?> response = responseManager.toResponse(new Throwable()); assertThat(response.getStatusCode(), is(equalTo(HttpStatus.OK))); response = responseManager.toResponse(new AssertionError()); assertThat(response.getStatusCode(), is(equalTo(HttpStatus.OK))); response = responseManager.toResponse(new NullPointerException()); assertThat(response.getStatusCode(), is(equalTo(HttpStatus.OK))); verify(logManager, times(3))//from w w w.ja v a2s . c o m .logIncomingCallEnd(Mockito.argThat(new TestInstanceOfMatcher<>(HawaiiException.class))); }