-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
81 additions
and
0 deletions.
There are no files selected for viewing
81 changes: 81 additions & 0 deletions
81
src/test/java/de/dentrassi/rpm/builder/PackageEntryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package de.dentrassi.rpm.builder; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
import java.io.File; | ||
|
||
import org.junit.Test; | ||
|
||
public class PackageEntryTest | ||
{ | ||
public PackageEntryTest () | ||
{ | ||
super(); | ||
} | ||
|
||
@Test | ||
public void testValidateNameNull () | ||
{ | ||
final PackageEntry entry = new PackageEntry (); | ||
entry.setLinkTo ( "something-to-link-to" ); | ||
|
||
assertThrows ( IllegalStateException.class, () -> entry.validate () ); | ||
} | ||
|
||
@Test | ||
public void testValidateNameEmpty () | ||
{ | ||
final PackageEntry entry = new PackageEntry (); | ||
entry.setName (""); | ||
entry.setLinkTo ( "something-to-link-to" ); | ||
|
||
assertThrows ( IllegalStateException.class, () -> entry.validate () ); | ||
} | ||
|
||
@Test | ||
public void testValidateNoSource () | ||
{ | ||
final PackageEntry entry = new PackageEntry (); | ||
entry.setName ("some-entry"); | ||
|
||
assertThrows ( IllegalStateException.class, () -> entry.validate () ); | ||
} | ||
|
||
@Test | ||
public void testValidateGhostNull () | ||
{ | ||
final PackageEntry entry = new PackageEntry (); | ||
entry.setName ("some-entry"); | ||
entry.setGhost ( null ); | ||
|
||
// no NullPointerException must be thrown | ||
assertThrows ( IllegalStateException.class, () -> entry.validate () ); | ||
} | ||
|
||
@Test | ||
public void testValidateGhostSource() | ||
{ | ||
final PackageEntry entry = new PackageEntry (); | ||
entry.setName ("some-entry"); | ||
entry.setGhost ( Boolean.TRUE ); | ||
|
||
try { | ||
entry.validate (); | ||
} | ||
catch ( final RuntimeException e) | ||
{ | ||
fail ( "Ghost entries do not require other sources, got error: " + e.getMessage () ); | ||
} | ||
} | ||
|
||
@Test | ||
public void testValidateMultipleSourcesGhost() | ||
{ | ||
final PackageEntry entry = new PackageEntry (); | ||
entry.setName ("some-entry"); | ||
entry.setFile ( new File ( "some-file-entry" ) ); | ||
entry.setGhost ( Boolean.TRUE ); | ||
|
||
assertThrows ( IllegalStateException.class, () -> entry.validate () ); | ||
} | ||
} |