Skip to content

Commit

Permalink
Unit tests, code coverage, badges, and basic cue numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
nlowe committed Dec 1, 2016
1 parent 137c9fd commit 6ecec46
Show file tree
Hide file tree
Showing 9 changed files with 541 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
language: java

sudo: false

jdk:
- oraclejdk8

cache:
directories:
- $HOME/.m2

after_success:
- mvn -DrepoToken=$COVERALLS_TOKEN jacoco:report coveralls:report
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# soundclip
[![Build Status](https://travis-ci.org/nlowe/soundclip.svg?branch=master)](https://travis-ci.org/nlowe/soundclip)
[![Coverage Status](https://coveralls.io/repos/github/nlowe/soundclip/badge.svg?branch=master)](https://coveralls.io/github/nlowe/soundclip?branch=master)
[![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](http://www.gnu.org/licenses/gpl-3.0)

An open source, sound cue management system for theatre.
Still a very early WIP.

Expand Down
30 changes: 30 additions & 0 deletions Soundclip.Core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,25 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>20.0</version>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
Expand Down Expand Up @@ -45,6 +64,17 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<useFile>false</useFile>
<includes>
<include>soundclip/core/tests/**/*.java</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>

Expand Down
91 changes: 91 additions & 0 deletions Soundclip.Core/src/main/java/soundclip/core/CueNumber.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
// Copyright (C) 2016 Nathan Lowe
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package soundclip.core;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.stream.Collectors;

/**
*
*/
public class CueNumber implements Comparable<CueNumber>
{
private final ArrayList<Integer> parts;

private CueNumber()
{
parts = new ArrayList<>();
}

public CueNumber(int...parts)
{
this();

for(int i : parts)
{
if(i < 0) throw new IllegalArgumentException("All parts must be positive");
this.parts.add(i);
}

if(this.parts.size() == 0) throw new IllegalArgumentException("No number provided");
}

public CueNumber(String fromString)
{
this();

if(fromString.trim().isEmpty()) throw new IllegalArgumentException("No number provided");

for(String s : fromString.split("\\."))
{
int i = Integer.parseInt(s);

if(i < 0) throw new IllegalArgumentException("All parts must be positive");
parts.add(i);
}

if(parts.size() == 0) throw new IllegalArgumentException("No number provided");
}

@Override
public String toString()
{
return parts.stream().map(Object::toString).collect(Collectors.joining("."));
}

@Override
public int compareTo(CueNumber o)
{
if(o == null) throw new NullPointerException("The other cue is null");
if(o == this) return 0;

int compare;
for(int i=0; i < Math.min(parts.size(), o.parts.size()); i++)
{
compare = parts.get(i).compareTo(o.parts.get(i));

if(compare != 0) return compare;
}

return parts.size() == o.parts.size() ? 0 : parts.size() > o.parts.size() ? 1 : -1;
}

@Override
public boolean equals(Object o)
{
return o == this || (o instanceof CueNumber && ((CueNumber)o).parts.equals(this.parts));
}
}
29 changes: 29 additions & 0 deletions Soundclip.Core/src/main/java/soundclip/core/CueSupportFlags.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright (C) 2016 Nathan Lowe
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package soundclip.core;

/**
*
*/
public class CueSupportFlags
{
public static int RESUME = 0b1;
public static int FADE = 0b10;

public boolean Supports(ICue cue, int flag)
{
return (cue.getSupportedOperations() & flag) == flag;
}
}
15 changes: 15 additions & 0 deletions Soundclip.Core/src/main/java/soundclip/core/ICue.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package soundclip.core;

import java.time.Duration;

/**
* The basic cue interface
*/
public interface ICue
{
CueNumber getNumber();
String getName();
Duration getDuration();

int getSupportedOperations();
}
36 changes: 36 additions & 0 deletions Soundclip.Core/src/main/java/soundclip/core/Project.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,47 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package soundclip.core;

import java.util.Date;

/**
* A project is the basic unit of work. Each project contains a collection of cue lists
* and metadata for the project.
*/
public class Project
{
private String projectPath;
private String name;
private Date lastModified;



public String getPath()
{
return projectPath;
}

public void setPath(String projectPath)
{
this.projectPath = projectPath;
}

public String getName()
{
return name;
}

public void setName(String name)
{
this.name = name;
}

public Date getLastModified()
{
return lastModified;
}

public void setLastModified(Date lastModified)
{
this.lastModified = lastModified;
}
}
Loading

0 comments on commit 6ecec46

Please sign in to comment.