Skip to content

Commit

Permalink
Add PackageEntry unit tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
dranuhl authored and ctron committed Nov 29, 2021
1 parent b6ee66f commit 676736c
Showing 1 changed file with 81 additions and 0 deletions.
81 changes: 81 additions & 0 deletions src/test/java/de/dentrassi/rpm/builder/PackageEntryTest.java
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 () );
}
}

0 comments on commit 676736c

Please sign in to comment.