Skip to content

Commit

Permalink
increase coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
abuttaro committed Feb 1, 2018
1 parent 8f1bc78 commit 2673c55
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 14 deletions.
36 changes: 22 additions & 14 deletions up-annotations/pom.xml
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
<?xml version="1.0"?>
<project
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.github.restup</groupId>
<artifactId>up-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../up-parent</relativePath>
</parent>
<parent>
<groupId>com.github.restup</groupId>
<artifactId>up-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../up-parent</relativePath>
</parent>

<artifactId>up-annotations</artifactId>
<packaging>jar</packaging>
<name>Up! :: annotations</name>
<artifactId>up-annotations</artifactId>
<packaging>jar</packaging>
<name>Up! :: annotations</name>

<dependencies>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>

</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.github.restup.annotations.field;

import static com.github.restup.annotations.field.RelationshipType.manyToMany;
import static com.github.restup.annotations.field.RelationshipType.manyToOne;
import static com.github.restup.annotations.field.RelationshipType.oneToMany;
import static com.github.restup.annotations.field.RelationshipType.oneToOne;
import static org.junit.Assert.assertEquals;
import java.util.function.Function;
import org.junit.Test;

public class RelationshipTypeTest {

@Test
public void testIsOneTo() {
assertType(true, RelationshipType::isOneTo, oneToOne, oneToMany);
assertType(false, RelationshipType::isOneTo, manyToOne, manyToMany);
}

@Test
public void testIsManyTo() {
assertType(true, RelationshipType::isManyTo, manyToOne, manyToMany);
assertType(false, RelationshipType::isManyTo, oneToOne, oneToMany);
}

@Test
public void testToOne() {
assertType(true, RelationshipType::isToOne, oneToOne, manyToOne);
assertType(false, RelationshipType::isToOne, oneToMany, manyToMany);
}

@Test
public void testToMany() {
assertType(true, RelationshipType::isToMany, oneToMany, manyToMany);
assertType(false, RelationshipType::isToMany, oneToOne, manyToOne);
}

private static void assertType(boolean expected, Function<RelationshipType, Boolean> f, RelationshipType... relationshipTypes ) {
for ( RelationshipType type : relationshipTypes ) {
assertEquals(expected, f.apply(type));
}
}

}

0 comments on commit 2673c55

Please sign in to comment.