vavr's either (#2180)

* moving jmh into libraries module

* refactoring jmh

* Update pom.xml

* manual algorightm

* with BM result

* fix for space issue

* Fixed indentation

* change as per suggestion

* vavr either

* adding unit test and othe rutilities
This commit is contained in:
Abhinab Kanrar
2017-07-09 12:33:08 +05:30
committed by Grzegorz Piwowarek
parent 62254d9beb
commit f876c6d02e
2 changed files with 122 additions and 0 deletions
@@ -0,0 +1,32 @@
package com.baeldung.vavr.either;
import org.junit.Test;
import io.vavr.control.Either;
import static org.junit.Assert.assertEquals;
public class EitherUnitTest {
@Test
public void givenMarks_whenPassNumber_thenExpectNumber() {
Either<String, Integer> result = EitherDemo.computeWithEither(100);
int marks = EitherDemo.getMarks(result);
assertEquals(100, marks);
}
@Test
public void givenMarks_whenFailNumber_thenExpectErrorMesssage() {
Either<String, Integer> result = EitherDemo.computeWithEither(50);
String error = EitherDemo.getError(result);
assertEquals("Marks not acceptable", error);
}
@Test
public void givenPassMarks_whenModified_thenExpectNumber() {
Either<String, Integer> result = EitherDemo.computeWithEither(90);
int marks = EitherDemo.getModifiedMarks(result);
assertEquals(180, marks);
}
}