Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

neutron: update to junit 4.11 #146

Open
wants to merge 1 commit into
base: v4.0.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion quantum-model/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.woorea.openstack.quantum.model;

import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.hasItem;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.junit.Assert.assertThat;
import static org.junit.matchers.JUnitMatchers.containsString;
import static org.junit.matchers.JUnitMatchers.hasItem;

import java.util.Arrays;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
package com.woorea.openstack.quantum.model;

import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.hasItem;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.junit.Assert.assertThat;
import static org.junit.matchers.JUnitMatchers.containsString;
import static org.junit.matchers.JUnitMatchers.hasItem;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import org.hamcrest.BaseMatcher;
import org.hamcrest.Description;
import org.hamcrest.CustomMatcher;
import org.junit.Before;
import org.junit.Test;

Expand Down Expand Up @@ -142,23 +141,15 @@ public void testDeserializationAfterSerialization() throws Exception {
assertThat(port.getTenantId(), is(equalTo(TENANT_ID)));

assertThat(port.getSecurityGroups(), hasItem(equalTo(SEC_GROUP)));
assertThat(port.getList(), hasItem(new IpMatcher()));
}

private final class IpMatcher extends BaseMatcher<Ip> {
@Override
public boolean matches(Object item) {
assertThat(item, is(Ip.class));
Ip ip = (Ip) item;
return IP_ADDRESS.equals(ip.getAddress()) && IP_SUBNET_ID.equals(ip.getSubnetId());
}

@Override
public void describeTo(Description description) {
description.appendText("an Ip object with address ");
description.appendValue(IP_ADDRESS);
description.appendText(" and subnet id ");
description.appendValue(IP_SUBNET_ID);
}
assertThat(port.getList(), hasItem(new CustomMatcher<Ip>(
"an Ip object with address " + IP_ADDRESS + " and subnet id " + IP_SUBNET_ID) {

@Override
public boolean matches(Object ip) {
return ip instanceof Ip
&& IP_ADDRESS.equals(((Ip) ip).getAddress())
&& IP_SUBNET_ID.equals(((Ip) ip).getSubnetId());
}
}));
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
package com.woorea.openstack.quantum.model;

import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.hasItem;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.junit.Assert.assertThat;
import static org.junit.matchers.JUnitMatchers.containsString;
import static org.junit.matchers.JUnitMatchers.hasItem;

import java.util.Arrays;

import org.hamcrest.BaseMatcher;
import org.hamcrest.Description;
import org.hamcrest.CustomMatcher;
import org.junit.Before;
import org.junit.Test;

Expand Down Expand Up @@ -124,25 +123,15 @@ public void testDeserializationAfterSerialization() throws Exception {
assertThat(subnet.getName(), is(equalTo(NAME)));
assertThat(subnet.getNetworkId(), is(equalTo(NETWORK_ID)));
assertThat(subnet.getTenantId(), is(equalTo(TENANT_ID)));
assertThat(subnet.getList(), hasItem(new PoolMatcher()));
}

private class PoolMatcher extends BaseMatcher<Pool> {

@Override
public void describeTo(Description description) {
description.appendText("a Pool object with start ");
description.appendValue(POOL_START);
description.appendText(" and end ");
description.appendValue(POOL_END);
}

@Override
public boolean matches(Object item) {
assertThat(item, is(Pool.class));
Pool pool = (Pool) item;
return POOL_START.equals(pool.getStart()) && POOL_END.equals(pool.getEnd());
}

assertThat(subnet.getList(), hasItem(new CustomMatcher<Pool>(
"a Pool object with start " + POOL_START + " and end " + POOL_END) {

@Override
public boolean matches(Object pool) {
return pool instanceof Pool
&& POOL_START.equals(((Pool) pool).getStart())
&& POOL_END.equals(((Pool) pool).getEnd());
}
}));
}
}