Skip to content

Commit

Permalink
GoTimeUtilTest : Use assertThat(actual).contains(expected) instead of…
Browse files Browse the repository at this point in the history
… fetching and comparing optional#1378
  • Loading branch information
Prathamkrishna authored and manusa committed Apr 4, 2022
1 parent ebc37c4 commit ded7049
Showing 1 changed file with 6 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,12 @@
*/
package org.eclipse.jkube.kit.enricher.api.util;

import org.assertj.core.api.Assertions;
import org.junit.Test;

import java.util.Arrays;
import java.util.List;
import java.util.Optional;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;

public class GoTimeUtilTest {

Expand All @@ -33,28 +30,24 @@ public void testConversion() {
List<Integer> expectations = Arrays.asList(23, 0, 0, 0, 1, 123, 3663, 1810, -15, 30);

for (int i = 0; i < inputs.size(); i++) {
// When
Optional<Integer> result = GoTimeUtil.durationSeconds(inputs.get(i));

// Then
assertTrue(result.isPresent());
Assertions.assertThat(result.get()).isEqualTo(expectations.get(i).intValue());
assertThat(GoTimeUtil.durationSeconds(inputs.get(i)))
.contains(expectations.get(i));
}
}

@Test
public void testNull() {
assertEquals(Optional.empty(), GoTimeUtil.durationSeconds(null));
assertThat(GoTimeUtil.durationSeconds(null)).isEmpty();
}

@Test
public void testEmpty() {
assertEquals(Optional.empty(), GoTimeUtil.durationSeconds(""));
assertThat(GoTimeUtil.durationSeconds("")).isEmpty();
}

@Test
public void testBlankSpace() {
assertEquals(Optional.empty(), GoTimeUtil.durationSeconds(" "));
assertThat(GoTimeUtil.durationSeconds(" ")).isEmpty();
}

@Test(expected = IllegalArgumentException.class)
Expand All @@ -76,7 +69,4 @@ public void testErrorUnknownUnit() {
public void testErrorUnparsable() {
GoTimeUtil.durationSeconds("ms");
}



}

0 comments on commit ded7049

Please sign in to comment.