Skip to content

Commit

Permalink
Minor code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ajs6f authored and Andrew Woods committed Sep 5, 2014
1 parent 10060d7 commit e144f37
Show file tree
Hide file tree
Showing 28 changed files with 271 additions and 274 deletions.
Expand Up @@ -157,7 +157,6 @@ public void testPutContent()
verify(mockSession).save();
}

@SuppressWarnings("unused")
@Test
public void testCreateContent() throws RepositoryException, IOException,
InvalidChecksumException, URISyntaxException, ParseException {
Expand Down
Expand Up @@ -15,34 +15,36 @@
*/
package org.fcrepo.http.api;

import com.hp.hpl.jena.graph.Triple;
import org.fcrepo.kernel.Lock;
import org.fcrepo.kernel.services.LockService;
import org.fcrepo.kernel.utils.iterators.RdfStream;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;

import javax.jcr.Node;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.jcr.nodetype.NodeType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
import java.net.URISyntaxException;
import java.util.UUID;

import static java.util.UUID.randomUUID;
import static org.fcrepo.http.commons.test.util.PathSegmentImpl.createPathList;
import static org.fcrepo.http.commons.test.util.TestHelpers.getUriInfoImpl;
import static org.fcrepo.http.commons.test.util.TestHelpers.mockSession;
import static org.fcrepo.http.commons.test.util.TestHelpers.setField;
import static org.fcrepo.kernel.RdfLexicon.HAS_LOCK_TOKEN;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;

import java.net.URISyntaxException;

import javax.jcr.Node;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.jcr.nodetype.NodeType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;

import org.fcrepo.kernel.Lock;
import org.fcrepo.kernel.services.LockService;
import org.fcrepo.kernel.utils.iterators.RdfStream;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;

import com.hp.hpl.jena.graph.Triple;

/**
* @author Mike Durbin
*/
Expand Down Expand Up @@ -79,7 +81,7 @@ public void setUp() throws Exception {

@Test
public void testGetLock() throws RepositoryException {
final String pid = UUID.randomUUID().toString();
final String pid = randomUUID().toString();
final String path = "/" + pid;
initializeMockNode(path);
when(mockLockService.getLock(mockSession, path)).thenReturn(mockLock);
Expand All @@ -91,32 +93,32 @@ public void testGetLock() throws RepositoryException {

@Test
public void testCreateLock() throws RepositoryException, URISyntaxException {
final String pid = UUID.randomUUID().toString();
final String pid = randomUUID().toString();
final String path = "/" + pid;
initializeMockNode(path);
when(mockLockService.acquireLock(mockSession, path, false)).thenReturn(mockLock);

final Response response = testObj.createLock(createPathList(pid), false);

verify(mockLockService).acquireLock(mockSession, path, false);
Assert.assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
}

@Test
public void testDeleteLock() throws RepositoryException, URISyntaxException {
final String pid = UUID.randomUUID().toString();
final String pid = randomUUID().toString();
final String path = "/" + pid;
initializeMockNode(path);

final Response response = testObj.deleteLock(createPathList(pid));

verify(mockLockService).releaseLock(mockSession, path);
Assert.assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
}

@Test
public void testRDFGenerationForLockToken() throws RepositoryException {
final String pid = UUID.randomUUID().toString();
final String pid = randomUUID().toString();
final String path = "/" + pid;
initializeMockNode(path);
when(mockLockService.getLock(mockSession, path)).thenReturn(mockLock);
Expand Down

0 comments on commit e144f37

Please sign in to comment.