Example usage for org.springframework.util Assert hasLength

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

Introduction

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

Prototype

@Deprecated
public static void hasLength(@Nullable String text) 

Source Link

Document

Assert that the given String is not empty; that is, it must not be null and not the empty String.

Usage

From source file:com.orange.cepheus.broker.LocalRegistrationsTest.java

@Test
public void testRegistrationWithPersistenceException() throws Exception {

    thrown.expect(RegistrationPersistenceException.class);
    doThrow(RegistrationPersistenceException.class).when(registrationsRepository).saveRegistration(any());

    RegisterContext registerContext = createRegistrationContext();
    String registrationId = localRegistrations.updateRegistrationContext(registerContext);
    Assert.hasLength(registrationId);
    Registration registration = localRegistrations.getRegistration(registrationId);
    assertNotNull(registration);//  w w w  .j  a va  2  s.  c  om
    assertNotNull(registration.getExpirationDate());

    verify(remoteRegistrations, never()).registerContext(eq(registerContext), eq(registrationId));
    verify(registrationsRepository).getRegistration(eq(registrationId));
    verify(registrationsRepository).saveRegistration(eq(registration));
}

From source file:io.kahu.hawaii.util.logger.RequestLogBuilder.java

public RequestLogBuilder param(String name, JSONObject value) {
    Assert.hasLength(name);
    try {/*from w w  w  . j av  a 2s .  com*/
        this.params.put(name, value);
    } catch (JSONException cant_happen) {
        //
    }
    return this;
}

From source file:org.jcf.MultiUserChatImpl.java

/**
 * sets the attribute roomID/*from ww  w  .ja  v  a 2 s.c o m*/
 * @param room singe room name
 */
private void setRoomID(String room) {
    Assert.hasLength(room);

    roomID = room + conferenceKey + jCFConnection.getJabberServer();
}

From source file:io.kahu.hawaii.util.logger.RequestLogBuilder.java

public RequestLogBuilder param(String name, JSONArray value) {
    Assert.hasLength(name);
    try {/*w  ww .j a  v a2  s  .c  om*/
        this.params.put(name, value);
    } catch (JSONException cant_happen) {
        //
    }
    return this;
}

From source file:com.orange.cepheus.broker.SubscriptionsTest.java

@Test
public void addSubscriptionWithZeroDurationTest()
        throws SubscriptionException, URISyntaxException, SubscriptionPersistenceException {
    SubscribeContext subscribeContext = createSubscribeContextTemperature();
    subscribeContext.setDuration("PT0S");
    String subscriptionId = subscriptions.addSubscription(subscribeContext);
    Assert.notNull(subscriptionId);/*from  w  w  w.jav a  2  s. com*/
    Assert.hasLength(subscriptionId);
    Subscription subscription = subscriptions.getSubscription(subscriptionId);
    Assert.notNull(subscription);
    Assert.notNull(subscription.getExpirationDate());
    Assert.notNull(subscription.getSubscriptionId());
    assertEquals(subscriptionId, subscription.getSubscriptionId());
    Calendar c = (Calendar) Calendar.getInstance().clone();
    c.add(Calendar.MONTH, 1);
    c.add(Calendar.HOUR, 24);
    assertFalse(subscription.getExpirationDate().isAfter(c.toInstant()));
    c.add(Calendar.HOUR, -48);
    assertFalse(subscription.getExpirationDate().isBefore(c.toInstant()));
    Assert.isTrue(subscriptionsRepository.getAllSubscriptions().size() == 1);
}

From source file:io.kahu.hawaii.util.logger.RequestLogBuilder.java

public RequestLogBuilder excludeParam(String name) {
    Assert.hasLength(name);
    this.params.remove(name);
    return this;
}

From source file:com.orange.cepheus.broker.LocalRegistrationsTest.java

@Test
public void testUpdateRegistration() throws Exception {

    RegisterContext registerContext = createRegistrationContext();
    registerContext.setRegistrationId("12345");

    Registration registration = new Registration(Instant.now().plus(1, ChronoUnit.DAYS), registerContext);

    reset(registrationsRepository);// ww w .  ja va2  s  . c om
    when(registrationsRepository.getRegistration(any())).thenReturn(registration);

    String registrationId = localRegistrations.updateRegistrationContext(registerContext);
    Assert.hasLength(registrationId);
    assertNotEquals("12345", registrationId);
    Registration registration2 = localRegistrations.getRegistration(registrationId);
    assertNotNull(registration2);
    assertNotNull(registration2.getExpirationDate());

    verify(remoteRegistrations).registerContext(eq(registerContext), eq(registrationId));
    verify(registrationsRepository).getRegistration(eq(registrationId));
    verify(registrationsRepository).updateRegistration(eq(registration));
}

From source file:io.kahu.hawaii.util.logger.RequestLogBuilder.java

public RequestLogBuilder header(String name, String value) {
    Assert.hasLength(name);
    Assert.hasLength(value);
    return header(new BasicHeader(name, value));
}

From source file:de.escalon.hypermedia.affordance.Affordance.java

/**
 * The relation type of the link./*from   w ww .  j  av  a  2  s  .c om*/
 *
 * @param rel
 *         IANA-registered type or extension relation type.
 */
public void addRel(String rel) {
    Assert.hasLength(rel);
    linkParams.add("rel", rel);
}

From source file:com.github.hateoas.forms.affordance.Affordance.java

/**
 * The relation type of the link./*  w  w w. j av  a 2 s  . com*/
 *
 * @param rel IANA-registered type or extension relation type.
 */
public void addRel(final String rel) {
    Assert.hasLength(rel);
    linkParams.add("rel", rel);
}