Skip to content

Commit

Permalink
[Issue comixed#130] Allow for an issue number of "0".
Browse files Browse the repository at this point in the history
  • Loading branch information
mcpierce committed Jan 18, 2020
1 parent bd8a62b commit c8caa88
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
Expand Up @@ -23,10 +23,6 @@
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonView;
import java.io.File;
import java.text.DateFormat;
import java.util.*;
import javax.persistence.*;
import org.apache.commons.io.FilenameUtils;
import org.comixed.adaptors.ArchiveType;
import org.comixed.adaptors.archive.ArchiveAdaptor;
Expand All @@ -41,6 +37,11 @@
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import javax.persistence.*;
import java.io.File;
import java.text.DateFormat;
import java.util.*;

/**
* <code>Comic</code> represents a single digital comic issue.
*
Expand Down Expand Up @@ -693,7 +694,7 @@ public void setIssueNumber(String issueNumber) {
this.logger.debug("Setting issue number=" + issueNumber);
if ((issueNumber != null) && issueNumber.startsWith("0")) {
this.logger.debug("Removing leading 0s from issue number");
while (issueNumber.startsWith("0")) {
while (issueNumber.startsWith("0") && !issueNumber.equals("0")) {
issueNumber = issueNumber.substring(1);
}
}
Expand Down
Expand Up @@ -18,16 +18,17 @@

package org.comixed.model.library;

import static org.junit.Assert.*;

import java.io.File;
import java.io.IOException;
import java.util.Date;
import org.apache.commons.io.FileUtils;
import org.comixed.adaptors.ArchiveType;
import org.junit.Before;
import org.junit.Test;

import java.io.File;
import java.io.IOException;
import java.util.Date;

import static org.junit.Assert.*;

public class ComicTest {
private static final String TEST_SERIES = "Batman";
private static final String TEST_VOLUME = "2017";
Expand Down Expand Up @@ -288,6 +289,12 @@ public void testIssueNumber() {
assertEquals(TEST_ISSUE_NUMBER, this.comic.getIssueNumber());
}

@Test
public void testIssueNumberAllowsItToBe0() {
this.comic.setIssueNumber("0");
assertEquals("0", this.comic.getIssueNumber());
}

@Test
public void testMultipleCharacters() {
String secondCharacter = TEST_CHARACTER.substring(1);
Expand Down

0 comments on commit c8caa88

Please sign in to comment.