Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/with-latest-snapshot-versions'
Browse files Browse the repository at this point in the history
# Conflicts:
#	assertions-examples/pom.xml
  • Loading branch information
joel-costigliola committed May 21, 2017
2 parents bd1b1a1 + 573ce0d commit bfb8c71
Show file tree
Hide file tree
Showing 16 changed files with 280 additions and 10 deletions.
2 changes: 1 addition & 1 deletion assertions-examples/pom.xml
Expand Up @@ -21,7 +21,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<neo4j.version>2.0.0</neo4j.version>
<assertj-core.version>3.7.0</assertj-core.version>
<assertj-core.version>3.8.1-SNAPSHOT</assertj-core.version>
</properties>

<dependencies>
Expand Down
@@ -0,0 +1,26 @@
/**
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* Copyright 2012-2016 the original author or authors.
*/
package org.assertj.examples.data;

public class ArtWork {

private String creator;

public String getCreator() {
return creator;
}

public void setCreator(String creator) {
this.creator = creator;
}
}
Expand Up @@ -14,7 +14,9 @@

import java.util.Date;

public class Movie {
import org.assertj.examples.data.ArtWork;

public class Movie extends ArtWork {

private String title;
private Date releaseDate;
Expand Down
Expand Up @@ -46,6 +46,16 @@ public static org.assertj.examples.data.AlignmentAssert assertThat(org.assertj.e
return new org.assertj.examples.data.AlignmentAssert(actual);
}

/**
* Creates a new instance of <code>{@link org.assertj.examples.data.ArtWorkAssert}</code>.
*
* @param actual the actual value.
* @return the created assertion object.
*/
public static org.assertj.examples.data.ArtWorkAssert assertThat(org.assertj.examples.data.ArtWork actual) {
return new org.assertj.examples.data.ArtWorkAssert(actual);
}

/**
* Creates a new instance of <code>{@link org.assertj.examples.data.BasketBallPlayerAssert}</code>.
*
Expand Down
Expand Up @@ -46,6 +46,16 @@ public static org.assertj.examples.data.AlignmentAssert then(org.assertj.example
return new org.assertj.examples.data.AlignmentAssert(actual);
}

/**
* Creates a new instance of <code>{@link org.assertj.examples.data.ArtWorkAssert}</code>.
*
* @param actual the actual value.
* @return the created assertion object.
*/
public static org.assertj.examples.data.ArtWorkAssert then(org.assertj.examples.data.ArtWork actual) {
return new org.assertj.examples.data.ArtWorkAssert(actual);
}

/**
* Creates a new instance of <code>{@link org.assertj.examples.data.BasketBallPlayerAssert}</code>.
*
Expand Down
Expand Up @@ -84,6 +84,16 @@ public org.assertj.examples.data.AlignmentAssert assertThat(org.assertj.examples
return proxy(org.assertj.examples.data.AlignmentAssert.class, org.assertj.examples.data.Alignment.class, actual);
}

/**
* Creates a new "soft" instance of <code>{@link org.assertj.examples.data.ArtWorkAssert}</code>.
*
* @param actual the actual value.
* @return the created "soft" assertion object.
*/
public org.assertj.examples.data.ArtWorkAssert assertThat(org.assertj.examples.data.ArtWork actual) {
return proxy(org.assertj.examples.data.ArtWorkAssert.class, org.assertj.examples.data.ArtWork.class, actual);
}

/**
* Creates a new "soft" instance of <code>{@link org.assertj.examples.data.BasketBallPlayerAssert}</code>.
*
Expand Down
Expand Up @@ -81,6 +81,16 @@ public org.assertj.examples.data.AlignmentAssert assertThat(org.assertj.examples
return proxy(org.assertj.examples.data.AlignmentAssert.class, org.assertj.examples.data.Alignment.class, actual);
}

/**
* Creates a new "soft" instance of <code>{@link org.assertj.examples.data.ArtWorkAssert}</code>.
*
* @param actual the actual value.
* @return the created "soft" assertion object.
*/
public org.assertj.examples.data.ArtWorkAssert assertThat(org.assertj.examples.data.ArtWork actual) {
return proxy(org.assertj.examples.data.ArtWorkAssert.class, org.assertj.examples.data.ArtWork.class, actual);
}

/**
* Creates a new "soft" instance of <code>{@link org.assertj.examples.data.BasketBallPlayerAssert}</code>.
*
Expand Down
@@ -0,0 +1,44 @@
package org.assertj.examples.data;

import org.assertj.core.api.AbstractAssert;
import org.assertj.core.util.Objects;

/**
* Abstract base class for {@link ArtWork} specific assertions - Generated by CustomAssertionGenerator.
*/
public abstract class AbstractArtWorkAssert<S extends AbstractArtWorkAssert<S, A>, A extends ArtWork> extends AbstractAssert<S, A> {

/**
* Creates a new <code>{@link AbstractArtWorkAssert}</code> to make assertions on actual ArtWork.
* @param actual the ArtWork we want to make assertions on.
*/
protected AbstractArtWorkAssert(A actual, Class<S> selfType) {
super(actual, selfType);
}

/**
* Verifies that the actual ArtWork's creator is equal to the given one.
* @param creator the given creator to compare the actual ArtWork's creator to.
* @return this assertion object.
* @throws AssertionError - if the actual ArtWork's creator is not equal to the given one.
*/
public S hasCreator(String creator) {
// check that actual ArtWork we want to make assertions on is not null.
isNotNull();


// overrides the default error message with a more explicit one
String assertjErrorMessage = "\nExpecting creator of:\n <%s>\nto be:\n <%s>\nbut was:\n <%s>";

// check
String actualCreator = actual.getCreator();
System.out.println("check Creator");
if (!Objects.areEqual(actualCreator, creator)) {
failWithMessage(assertjErrorMessage, actual, creator, actualCreator);
}

// return the current assertion for method chaining
return myself;
}

}
@@ -0,0 +1,27 @@
package org.assertj.examples.data;


/**
* {@link ArtWork} specific assertions - Generated by me.
*
* Although this class is not final to allow Soft assertions proxy, if you wish to extend it,
* extend {@link AbstractArtWorkAssert} instead.
*/
public class ArtWorkAssert extends AbstractArtWorkAssert<ArtWorkAssert, ArtWork> {

/**
* Creates a new <code>{@link ArtWorkAssert}</code> to make assertions on actual ArtWork.
* @param actual the ArtWork we want to make assertions on.
*/
public ArtWorkAssert(ArtWork actual) {
super(actual, ArtWorkAssert.class);
}

/**
* factory method for ArtWork assertions.
* @return a new <code>{@link ArtWorkAssert}</code>
*/
public static ArtWorkAssert assertThat(ArtWork actual) {
return new ArtWorkAssert(actual);
}
}
@@ -1,12 +1,12 @@
package org.assertj.examples.data.movie;

import org.assertj.core.api.AbstractAssert;
import org.assertj.core.util.Objects;
import org.assertj.examples.data.AbstractArtWorkAssert;

/**
* Abstract base class for {@link Movie} specific assertions - Generated by CustomAssertionGenerator.
*/
public abstract class AbstractMovieAssert<S extends AbstractMovieAssert<S, A>, A extends Movie> extends AbstractAssert<S, A> {
public abstract class AbstractMovieAssert<S extends AbstractMovieAssert<S, A>, A extends Movie> extends AbstractArtWorkAssert<S, A> {

/**
* Creates a new <code>{@link AbstractMovieAssert}</code> to make assertions on actual Movie.
Expand Down
Expand Up @@ -51,8 +51,10 @@ public void generated_bdd_assertions_example() throws NameException {
assertThat(test).hasOnlyMovies(theFellowshipOfTheRing)
.doesNotHaveMovies(theTwoTowers);

Movie movie = new Movie("boom", new Date(), "1h");
movie.setCreator("foo");
assertThat(movie).hasCreator("foo");
try {
Movie movie = new Movie("boom", new Date(), "1h");
movie = null;
assertThat(movie).as("can be given ?").canBeGiven();
} catch (AssertionError e) {
Expand Down
Expand Up @@ -70,6 +70,9 @@ public class IterableAssertionsExamples extends AbstractAssertionsExamples {
@Test
public void iterable_basic_assertions_examples() {

List<? extends String> strings = asList("a", "b", "c");
assertThat(strings).hasSize(3);

// would work the same way with Iterable<Ring>,
Iterable<Ring> elvesRings = newArrayList(vilya, nenya, narya);
assertThat(elvesRings).isNotEmpty().hasSize(3);
Expand Down

0 comments on commit bfb8c71

Please sign in to comment.