Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Corrections in calculating interfaces to be implemented by facade
- Loading branch information
1 parent
d39c780
commit 393b60f
Showing
4 changed files
with
76 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/test/java/pl/ais/commons/bean/domain/model/DefaultName.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package pl.ais.commons.bean.domain.model; | ||
|
||
/** | ||
* @author Warlock, AIS.PL | ||
* @since 1.3.3 | ||
*/ | ||
public final class DefaultName implements Name { | ||
|
||
private final String firstName; | ||
|
||
private final String lastname; | ||
|
||
public DefaultName(final String firstName, final String lastname) { | ||
this.firstName = firstName; | ||
this.lastname = lastname; | ||
} | ||
|
||
@Override | ||
public String getFirstName() { | ||
return firstName; | ||
} | ||
|
||
@Override | ||
public String getLastName() { | ||
return lastname; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package pl.ais.commons.bean.domain.model; | ||
|
||
/** | ||
* @author Warlock, AIS.PL | ||
* @since 1.3.3 | ||
*/ | ||
public interface Name { | ||
|
||
String getFirstName(); | ||
|
||
String getLastName(); | ||
|
||
} |
32 changes: 32 additions & 0 deletions
32
src/test/java/pl/ais/commons/bean/facade/FacadeExpectations.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package pl.ais.commons.bean.facade; | ||
|
||
import org.junit.Test; | ||
import pl.ais.commons.bean.domain.model.DefaultName; | ||
import pl.ais.commons.bean.domain.model.Name; | ||
|
||
import static org.junit.Assert.fail; | ||
|
||
/** | ||
* Verifies {@link Facade} expectations. | ||
* | ||
* @author Warlock, AIS.PL | ||
* @since 1.3.3 | ||
*/ | ||
public class FacadeExpectations { | ||
|
||
/** | ||
* Verifies if facade created for final class instance, implementing some i-face, will implement same i-face itself. | ||
*/ | ||
@Test | ||
public void shouldBeAssignableToImplementedIfaceForFinalClass() { | ||
final Name name = new DefaultName("John", "Smith"); | ||
final TraverseListener traverseListener = new TraverseListener(); | ||
|
||
try { | ||
final Name facade = Facade.over(name, traverseListener); | ||
} catch (final ClassCastException exception) { | ||
fail("Created facade does not implement desired i-face."); | ||
} | ||
} | ||
|
||
} |