BAEL-2431 Implementing multi-inheritance and Polymorphism using interfaces (#5924)

* Implementing Hexagonal Architecture in java

* Implementing multi-inheritance and Polymorphism using interfaces

* Removing hexagonal code

* Deleting hexagonal architecture code

* fix for unit test names
This commit is contained in:
kyleandari
2018-12-15 17:35:09 -05:00
committed by maibin
parent 1fc93000b6
commit 94f4092314
9 changed files with 133 additions and 0 deletions
@@ -0,0 +1,26 @@
package com.baeldung.interfaces;
import com.baeldung.interfaces.polymorphysim.Circle;
import com.baeldung.interfaces.polymorphysim.Shape;
import com.baeldung.interfaces.polymorphysim.Square;
import org.assertj.core.api.Assertions;
import org.junit.Test;
public class PolymorphysimUnitTest {
@Test
public void whenInterfacePointsToCircle_CircleAreaMethodisBeingCalled(){
double expectedArea = 12.566370614359172;
Shape circle = new Circle(2);
double actualArea = circle.area();
Assertions.assertThat(actualArea).isEqualTo(expectedArea);
}
@Test
public void whenInterfacePointsToSquare_SquareAreaMethodisBeingCalled(){
double expectedArea = 4;
Shape square = new Square(2);
double actualArea = square.area();
Assertions.assertThat(actualArea).isEqualTo(expectedArea);
}
}