Top Description Fields Constructors Methods
org.assertj.core.api

public abstract Class AbstractUriAssert<SELF extends AbstractUriAssert<SELF>>

extends AbstractComparableAssert<SELF extends AbstractUriAssert<SELF>, URI>
Class Inheritance
Known Direct Subclasses
org.assertj.core.api.UriAssert
Type Parameters
<SELF>
the "self" type of this assertion class.
Imports
java.net.URI, org.assertj.core.internal.Uris, org.assertj.core.util.VisibleForTesting

Base class for all implementations of assertions for URIs.
See Also
java.net.URI

Field Summary

Modifier and TypeField and Description
protected Uris
Inherited from org.assertj.core.api.AbstractComparableAssert:
comparables

Constructor Summary

AccessConstructor and Description
protected
AbstractUriAssert(final URI actual, final Class<?> selfType)

Method Summary

Modifier and TypeMethod and Description
public SELF

Returns:

this assertion object.
hasAuthority
(String
the expected authority of the actual URI.
expected
)

Verifies that the actual URI has the expected authority.

public SELF

Returns:

this assertion object.
hasFragment
(String
the expected fragment of the actual URI.
expected
)

Verifies that the actual URI has the expected fragment.

public SELF

Returns:

this assertion object.
hasHost
(String
the expected host of the actual URI.
expected
)

Verifies that the actual URI has the expected host.

public SELF

Returns:

this assertion object.
hasNoFragment
()

Verifies that the actual URI has no fragment.

public SELF

Returns:

this assertion object.
hasNoHost
()

Verifies that the actual URI has no host.

public SELF

Returns:

this assertion object.
hasNoParameter
(String
the name of the parameter expected to be absent.
name
)

Verifies that the actual URI does not have a parameter with the specified name.

public SELF

Returns:

this assertion object.
hasNoParameter
(String
the name of the parameter expected to be absent.
name
,
String
the value of the parameter expected to be absent.
value
)

Verifies that the actual URI does not have a parameter with the expected name and value.

public SELF

Returns:

this assertion object.
hasNoParameters
()

Verifies that the actual URI does not have any parameters.

public SELF

Returns:

this assertion object.
hasNoPath
()

Verifies that the actual URI has no path.

public SELF

Returns:

this assertion object.
hasNoPort
()

Verifies that the actual URI has no port.

public SELF

Returns:

this assertion object.
hasNoQuery
()

Verifies that the actual URI has no query.

public SELF

Returns:

this assertion object.
hasNoUserInfo
()

Verifies that the actual URI has no userinfo.

public SELF

Returns:

this assertion object.
hasParameter
(String
the name of the parameter expected to be present.
name
)

Verifies that the actual URI has a parameter with the expected name.

public SELF

Returns:

this assertion object.
hasParameter
(String
the name of the parameter expected to be present.
name
,
String
the value of the parameter expected to be present.
value
)

Verifies that the actual URI has a parameter with the expected name and value.

public SELF

Returns:

this assertion object.
hasPath
(String
the expected path of the actual URI.
expected
)

Verifies that the actual URI has the expected path.

public SELF

Returns:

this assertion object.
hasPort
(int
the expected port of the actual URI.
expected
)

Verifies that the actual URI has the expected port.

public SELF

Returns:

this assertion object.
hasQuery
(String
the expected query of the actual URI.
expected
)

Verifies that the actual URI has the expected query.

public SELF

Returns:

this assertion object.
hasScheme
(String
the expected scheme of the actual URI.
expected
)

Verifies that the actual URI has the expected scheme.

public SELF

Returns:

this assertion object.
hasUserInfo
(String
the expected userinfo of the actual URI.
expected
)

Verifies that the actual URI has the expected userinfo.

Inherited from org.assertj.core.api.AbstractComparableAssert:
inBinaryinHexadecimalisBetweenisEqualByComparingToisGreaterThanisGreaterThanOrEqualToisLessThanisLessThanOrEqualToisNotEqualByComparingToisStrictlyBetweenusingComparatorusingComparatorusingDefaultComparator

Field Detail

urisback to summary
protected Uris uris
Annotations
@VisibleForTesting

Constructor Detail

AbstractUriAssertback to summary
protected AbstractUriAssert(final URI actual, final Class<?> selfType)

Method Detail

hasAuthorityback to summary
public SELF hasAuthority(String expected)

Verifies that the actual URI has the expected authority.

Examples:

 // These assertions succeed:
assertThat(new URI("http://helloworld.org:8080")).hasAuthority("helloworld.org:8080");
assertThat(new URI("http://www.helloworld.org:8080/news")).hasAuthority("www.helloworld.org:8080");

// These assertions fail:
assertThat(new URI("http://www.helloworld.org:8080")).hasAuthority("www.helloworld.org");
assertThat(new URI("http://www.helloworld.org")).hasAuthority("www.helloworld.org:8080");
Parameters
expected:String

the expected authority of the actual URI.

Returns:SELF

this assertion object.

Exceptions
AssertionError:
if the actual authority is not equal to the expected authority.
hasFragmentback to summary
public SELF hasFragment(String expected)

Verifies that the actual URI has the expected fragment.

Examples:

 // This assertion succeeds:
assertThat(new URI("http://helloworld.org:8080/index.html#print")).hasFragment("print");

// These assertions fail:
assertThat(new URI("http://helloworld.org:8080/index.html#print")).hasFragment("hello");
assertThat(new URI("http://helloworld.org:8080/index.html")).hasFragment("hello");
Parameters
expected:String

the expected fragment of the actual URI.

Returns:SELF

this assertion object.

Exceptions
AssertionError:
if the actual fragment is not equal to the expected fragment.
hasHostback to summary
public SELF hasHost(String expected)

Verifies that the actual URI has the expected host.

Examples:

 // These assertions succeed:
assertThat(new URI("http://helloworld.org")).hasAuthority("helloworld.org");
assertThat(new URI("http://helloworld.org/pages")).hasHost("helloworld.org");
assertThat(new URI("http://helloworld.org:8080")).hasHost("helloworld.org");

// These assertions fail:
assertThat(new URI("http://www.helloworld.org")).hasHost("helloworld.org");
assertThat(new URI("http://www.helloworld.org:8080")).hasHost("helloworld.org");
Parameters
expected:String

the expected host of the actual URI.

Returns:SELF

this assertion object.

Exceptions
AssertionError:
if the actual host is not equal to the expected host.
hasNoFragmentback to summary
public SELF hasNoFragment()

Verifies that the actual URI has no fragment.

Examples:

 // This assertion succeeds:
assertThat(new URI("http://www.helloworld.org/index.html")).hasNoFragment();

// This assertion fails:
assertThat(new URI("http://helloworld.org:8080/index.html#print")).hasNoFragment();
Returns:SELF

this assertion object.

Exceptions
AssertionError:
if actual has a fragment.
hasNoHostback to summary
public SELF hasNoHost()

Verifies that the actual URI has no host.

Examples:

 // This assertion succeeds:
assertThat(new URI("file:///home/user/Documents/hello-world.txt")).hasNoHost();

// This assertion fails:
assertThat(new URI("http://helloworld.org:8080/index.html")).hasNoHost();
Returns:SELF

this assertion object.

Exceptions
AssertionError:
if actual has a host.
Since
3.22.0
hasNoParameterback to summary
public SELF hasNoParameter(String name)

Verifies that the actual URI does not have a parameter with the specified name.

The value of the parameter is not checked.

Examples:

 // This assertion succeeds:
assertThat(new URI("http://www.helloworld.org/index.html")).hasNoParameter("happy");

// These assertions fail:
assertThat(new URI("http://www.helloworld.org/index.html?sad")).hasNoParameter("sad");
assertThat(new URI("http://www.helloworld.org/index.html?sad=much")).hasNoParameter("sad");
Parameters
name:String

the name of the parameter expected to be absent.

Returns:SELF

this assertion object.

Exceptions
AssertionError:
if actual has the expected parameter.
IllegalArgumentException:
if the query string contains an invalid escape sequence.
hasNoParameterback to summary
public SELF hasNoParameter(String name, String value)

Verifies that the actual URI does not have a parameter with the expected name and value.

Use null to indicate an absent value (e.g. foo&bar) as opposed to an empty value (e.g. foo=&bar=).

Examples:

 // These assertions succeed:
assertThat(new URI("http://www.helloworld.org/index.html")).hasNoParameter("happy", "very");
assertThat(new URI("http://www.helloworld.org/index.html?happy")).hasNoParameter("happy", "very");
assertThat(new URI("http://www.helloworld.org/index.html?happy=very")).hasNoParameter("happy", null);

// These assertions fail:
assertThat(new URI("http://www.helloworld.org/index.html?sad")).hasNoParameter("sad", null);
assertThat(new URI("http://www.helloworld.org/index.html?sad=much")).hasNoParameter("sad", "much");
Parameters
name:String

the name of the parameter expected to be absent.

value:String

the value of the parameter expected to be absent.

Returns:SELF

this assertion object.

Exceptions
AssertionError:
if actual has the expected parameter.
IllegalArgumentException:
if the query string contains an invalid escape sequence.
hasNoParametersback to summary
public SELF hasNoParameters()

Verifies that the actual URI does not have any parameters.

Examples:

 // This assertion succeeds:
assertThat(new URI("http://www.helloworld.org/index.html")).hasNoParameters();

// These assertions fail:
assertThat(new URI("http://www.helloworld.org/index.html?sad")).hasNoParameters();
assertThat(new URI("http://www.helloworld.org/index.html?sad=much")).hasNoParameters();
Returns:SELF

this assertion object.

Exceptions
AssertionError:
if actual has a parameter.
IllegalArgumentException:
if the query string contains an invalid escape sequence.
Since
2.5.0 / 3.5.0
hasNoPathback to summary
public SELF hasNoPath()

Verifies that the actual URI has no path.

Examples:

 // This assertion succeeds:
assertThat(new URI("mailto:[email protected]")).hasNoPath();

// these assertions fail:
assertThat(new URI("http://helloworld.org")).hasNoPath(); // empty path
assertThat(new URI("http://helloworld.org/france")).hasNoPath();
Returns:SELF

this assertion object.

Exceptions
AssertionError:
if actual has a path.
hasNoPortback to summary
public SELF hasNoPort()

Verifies that the actual URI has no port.

Examples:

 // These assertions succeed:
assertThat(new URI("http://helloworld.org")).hasNoPort();

// This assertion fails:
assertThat(new URI("http://helloworld.org:8080")).hasNoPort();
Returns:SELF

this assertion object.

Exceptions
AssertionError:
if actual has a port.
hasNoQueryback to summary
public SELF hasNoQuery()

Verifies that the actual URI has no query.

Examples:

 // This assertion succeeds:
assertThat(new URI("http://www.helloworld.org/index.html")).hasNoQuery();

// These assertions fail:
assertThat(new URI("http://www.helloworld.org/index.html?type=test")).hasNoQuery();
Returns:SELF

this assertion object.

Exceptions
AssertionError:
if actual has a query.
hasNoUserInfoback to summary
public SELF hasNoUserInfo()

Verifies that the actual URI has no userinfo.

Examples:

 // This assertion succeeds:
assertThat(new URI("http://www.helloworld.org/index.html")).hasNoUserInfo();

// This assertion fails:
assertThat(new URI("http://test:[email protected]/index.html")).hasNoUserInfo();
Returns:SELF

this assertion object.

Exceptions
AssertionError:
if actual has some userinfo.
hasParameterback to summary
public SELF hasParameter(String name)

Verifies that the actual URI has a parameter with the expected name.

The value of the parameter is not checked.

Examples:

 // These assertions succeed:
assertThat(new URI("http://www.helloworld.org/index.html?happy")).hasParameter("happy");
assertThat(new URI("http://www.helloworld.org/index.html?happy=very")).hasParameter("happy");

// These assertions fail:
assertThat(new URI("http://www.helloworld.org/index.html")).hasParameter("happy");
assertThat(new URI("http://www.helloworld.org/index.html?sad=much")).hasParameter("happy");
Parameters
name:String

the name of the parameter expected to be present.

Returns:SELF

this assertion object.

Exceptions
AssertionError:
if the actual does not have the expected parameter.
IllegalArgumentException:
if the query string contains an invalid escape sequence.
Since
2.5.0 / 3.5.0
hasParameterback to summary
public SELF hasParameter(String name, String value)

Verifies that the actual URI has a parameter with the expected name and value.

Use null to indicate an absent value (e.g. foo&bar) as opposed to an empty value (e.g. foo=&bar=).

Examples:

 // These assertions succeed:
assertThat(new URI("http://www.helloworld.org/index.html?happy")).hasParameter("happy", null);
assertThat(new URI("http://www.helloworld.org/index.html?happy=very")).hasParameter("happy", "very");

// These assertions fail:
assertThat(new URI("http://www.helloworld.org/index.html?sad")).hasParameter("sad", "much");
assertThat(new URI("http://www.helloworld.org/index.html?sad=much")).hasParameter("sad", null);
Parameters
name:String

the name of the parameter expected to be present.

value:String

the value of the parameter expected to be present.

Returns:SELF

this assertion object.

Exceptions
AssertionError:
if the actual does not have the expected parameter.
IllegalArgumentException:
if the query string contains an invalid escape sequence.
Since
2.5.0 / 3.5.0
hasPathback to summary
public SELF hasPath(String expected)

Verifies that the actual URI has the expected path.

Examples:

 // These assertions succeed:
assertThat(new URI("http://helloworld.org/pages")).hasPath("/pages");
assertThat(new URI("http://www.helloworld.org")).hasPath("");

// this assertion fails:
assertThat(new URI("http://helloworld.org/pickme")).hasPath("/pages");
Parameters
expected:String

the expected path of the actual URI.

Returns:SELF

this assertion object.

Exceptions
AssertionError:
if the actual URI path is not equal to the expected path.
hasPortback to summary
public SELF hasPort(int expected)

Verifies that the actual URI has the expected port.

Examples:

 // These assertions succeed:
assertThat(new URI("http://helloworld.org:8080")).hasPort(8080);

// These assertions fail:
assertThat(new URI("http://helloworld.org:8080")).hasPort(9876);
assertThat(new URI("http://helloworld.org")).hasPort(8080);
assertThat(new URI("helloworld.org:8080")).hasPort(8080);
Parameters
expected:int

the expected port of the actual URI.

Returns:SELF

this assertion object.

Exceptions
AssertionError:
if the actual port is not equal to the expected port.
hasQueryback to summary
public SELF hasQuery(String expected)

Verifies that the actual URI has the expected query.

Examples:

 // This assertion succeeds:
assertThat(new URI("http://www.helloworld.org/index.html?type=test")).hasQuery("type=test");

// These assertions fail:
assertThat(new URI("http://www.helloworld.org/index.html?type=test")).hasQuery("type=hello");
assertThat(new URI("http://www.helloworld.org/index.html")).hasQuery("type=hello");
Parameters
expected:String

the expected query of the actual URI.

Returns:SELF

this assertion object.

Exceptions
AssertionError:
if the actual query is not equal to the expected query.
hasSchemeback to summary
public SELF hasScheme(String expected)

Verifies that the actual URI has the expected scheme.

Examples:

 // This assertion succeeds:
assertThat(new URI("ftp://helloworld.org")).hasScheme("ftp");

// These assertion fails:
assertThat(new URI("http://helloworld.org")).hasScheme("ftp");
Parameters
expected:String

the expected scheme of the actual URI.

Returns:SELF

this assertion object.

Exceptions
AssertionError:
if the actual scheme is not equal to the expected scheme.
hasUserInfoback to summary
public SELF hasUserInfo(String expected)

Verifies that the actual URI has the expected userinfo.

Examples:

 // These assertions succeed:
assertThat(new URI("http://test:[email protected]/index.html")).hasUserInfo("test:pass");
assertThat(new URI("http://[email protected]/index.html")).hasUserInfo("test");
assertThat(new URI("http://:[email protected]/index.html")).hasUserInfo(":pass");

// These assertions fail:
assertThat(new URI("http://test:[email protected]/index.html")).hasUserInfo("test:fail");
assertThat(new URI("http://www.helloworld.org/index.html")).hasUserInfo("test:pass");
Parameters
expected:String

the expected userinfo of the actual URI.

Returns:SELF

this assertion object.

Exceptions
AssertionError:
if the actual userinfo is not equal to the expected userinfo.