Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions core/src/test/java/feast/core/service/ProjectServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@
*/
package feast.core.service;

import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.*;
import static org.mockito.MockitoAnnotations.initMocks;

import feast.core.dao.ProjectRepository;
Expand All @@ -29,16 +27,12 @@
import java.util.Optional;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.mockito.Mock;

public class ProjectServiceTest {

@Mock private ProjectRepository projectRepository;
@Rule public final ExpectedException expectedException = ExpectedException.none();

private ProjectService projectService;

@Before
Expand Down Expand Up @@ -75,8 +69,9 @@ public void shouldArchiveProjectIfItExists() {

@Test
public void shouldNotArchiveDefaultProject() {
expectedException.expect(IllegalArgumentException.class);
this.projectService.archiveProject(Project.DEFAULT_NAME);
assertThrows(
IllegalArgumentException.class,
() -> this.projectService.archiveProject(Project.DEFAULT_NAME));
}

@Test(expected = IllegalArgumentException.class)
Expand Down
2 changes: 1 addition & 1 deletion core/src/test/java/feast/core/util/TypeConversionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
package feast.core.util;

import static com.jayway.jsonpath.matchers.JsonPathMatchers.hasJsonPath;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.*;

import com.google.protobuf.Timestamp;
import java.util.*;
Expand Down
26 changes: 11 additions & 15 deletions core/src/test/java/feast/core/validators/MatchersTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,12 @@
import static feast.core.validators.Matchers.checkLowerSnakeCase;
import static feast.core.validators.Matchers.checkUpperSnakeCase;
import static feast.core.validators.Matchers.checkValidClassPath;
import static org.junit.jupiter.api.Assertions.assertThrows;

import com.google.common.base.Strings;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;

public class MatchersTest {
@Rule public final ExpectedException exception = ExpectedException.none();

@Test
public void checkUpperSnakeCaseShouldPassForLegitUpperSnakeCase() {
Expand All @@ -42,15 +40,15 @@ public void checkUpperSnakeCaseShouldPassForLegitUpperSnakeCaseWithNumbers() {

@Test
public void checkUpperSnakeCaseShouldThrowIllegalArgumentExceptionWithFieldForInvalidString() {
exception.expect(IllegalArgumentException.class);
exception.expectMessage(
String in = "redis";
assertThrows(
IllegalArgumentException.class,
() -> checkUpperSnakeCase(in, "featuretable"),
Strings.lenientFormat(
"invalid value for %s resource, %s: %s",
"featuretable",
"redis",
"argument must be in upper snake case, and cannot include any special characters."));
String in = "redis";
checkUpperSnakeCase(in, "featuretable");
}

@Test
Expand All @@ -61,15 +59,15 @@ public void checkLowerSnakeCaseShouldPassForLegitLowerSnakeCase() {

@Test
public void checkLowerSnakeCaseShouldThrowIllegalArgumentExceptionWithFieldForInvalidString() {
exception.expect(IllegalArgumentException.class);
exception.expectMessage(
String in = "Invalid_feature name";
assertThrows(
IllegalArgumentException.class,
() -> checkLowerSnakeCase(in, "feature"),
Strings.lenientFormat(
"invalid value for %s resource, %s: %s",
"feature",
"Invalid_feature name",
"argument must be in lower snake case, and cannot include any special characters."));
String in = "Invalid_feature name";
checkLowerSnakeCase(in, "feature");
}

@Test
Expand All @@ -80,13 +78,11 @@ public void checkValidClassPathSuccess() {

@Test
public void checkValidClassPathEmpty() {
exception.expect(IllegalArgumentException.class);
checkValidClassPath("", "FeatureTable");
assertThrows(IllegalArgumentException.class, () -> checkValidClassPath("", "FeatureTable"));
}

@Test
public void checkValidClassPathDigits() {
exception.expect(IllegalArgumentException.class);
checkValidClassPath("123", "FeatureTable");
assertThrows(IllegalArgumentException.class, () -> checkValidClassPath("123", "FeatureTable"));
}
}