You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@jclouds.apache.org by Timur Alperovich <no...@github.com> on 2015/07/08 01:39:37 UTC

[jclouds] Swift: do not assume only 1 container in tests. (#800)

Openstack Swift ContainerApiLiveTest testListWithOptions assumes that
there are no other containers and that ContainerApiLiveTest container
will _always_ be the first container.

The patch changes the behavior of the test to instead pull out the
container from the returned list.
You can view, comment on, or merge this pull request online at:

  https://github.com/jclouds/jclouds/pull/800

-- Commit Summary --

  * Swift: do not assume only 1 container in tests.

-- File Changes --

    M apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/ContainerApiLiveTest.java (9)

-- Patch Links --

https://github.com/jclouds/jclouds/pull/800.patch
https://github.com/jclouds/jclouds/pull/800.diff

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/800

Re: [jclouds] Swift: do not assume only 1 container in tests. (#800)

Posted by Timur Alperovich <no...@github.com>.
> @@ -98,7 +99,13 @@ public void testListWithOptions() throws Exception {
>        String lexicographicallyBeforeName = name.substring(0, name.length() - 1);
>        for (String regionId : regions) {
>           ListContainerOptions options = ListContainerOptions.Builder.marker(lexicographicallyBeforeName);
> -         Container container = api.getContainerApi(regionId).list(options).get(0);
> +         Container container = api.getContainerApi(regionId).list(options).firstMatch(new Predicate<Container>() {
> +            @Override
> +            public boolean apply(Container container) {
> +               return container.getName().equals(name);
> +            }
> +         }).get();
> +         assertNotNull(container);

Done

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/800/files#r34106146

Re: [jclouds] Swift: do not assume only 1 container in tests. (#800)

Posted by Timur Alperovich <no...@github.com>.
> @@ -98,7 +99,13 @@ public void testListWithOptions() throws Exception {
>        String lexicographicallyBeforeName = name.substring(0, name.length() - 1);
>        for (String regionId : regions) {
>           ListContainerOptions options = ListContainerOptions.Builder.marker(lexicographicallyBeforeName);
> -         Container container = api.getContainerApi(regionId).list(options).get(0);
> +         Container container = api.getContainerApi(regionId).list(options).firstMatch(new Predicate<Container>() {
> +            @Override
> +            public boolean apply(Container container) {
> +               return container.getName().equals(name);
> +            }
> +         }).get();
> +         assertNotNull(container);
>           assertEquals(container.getName(), name);

Done

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/800/files#r34106131

Re: [jclouds] Swift: do not assume only 1 container in tests. (#800)

Posted by Andrew Gaul <no...@github.com>.
Pushed to master as 86af0753bf51bba42d5c18657e1f0e3dd72630ee.

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/800#issuecomment-119391756

Re: [jclouds] Swift: do not assume only 1 container in tests. (#800)

Posted by Andrew Gaul <no...@github.com>.
> @@ -98,7 +99,13 @@ public void testListWithOptions() throws Exception {
>        String lexicographicallyBeforeName = name.substring(0, name.length() - 1);
>        for (String regionId : regions) {
>           ListContainerOptions options = ListContainerOptions.Builder.marker(lexicographicallyBeforeName);
> -         Container container = api.getContainerApi(regionId).list(options).get(0);
> +         Container container = api.getContainerApi(regionId).list(options).firstMatch(new Predicate<Container>() {
> +            @Override
> +            public boolean apply(Container container) {
> +               return container.getName().equals(name);
> +            }
> +         }).get();
> +         assertNotNull(container);

Needed?  `get` will throw `IllegalStateException` if not present.

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/800/files#r34104023

Re: [jclouds] Swift: do not assume only 1 container in tests. (#800)

Posted by Andrew Gaul <no...@github.com>.
Closed #800.

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/800#event-350296138

Re: [jclouds] Swift: do not assume only 1 container in tests. (#800)

Posted by Andrew Gaul <no...@github.com>.
> @@ -98,7 +99,13 @@ public void testListWithOptions() throws Exception {
>        String lexicographicallyBeforeName = name.substring(0, name.length() - 1);
>        for (String regionId : regions) {
>           ListContainerOptions options = ListContainerOptions.Builder.marker(lexicographicallyBeforeName);
> -         Container container = api.getContainerApi(regionId).list(options).get(0);
> +         Container container = api.getContainerApi(regionId).list(options).firstMatch(new Predicate<Container>() {
> +            @Override
> +            public boolean apply(Container container) {
> +               return container.getName().equals(name);
> +            }
> +         }).get();
> +         assertNotNull(container);
>           assertEquals(container.getName(), name);

This is now always true.

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/800/files#r34103986