Skip to content

Commit

Permalink
License and checkstyle cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ajs6f committed Oct 30, 2014
1 parent 25c12b7 commit 83773bc
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 27 deletions.
Expand Up @@ -39,8 +39,10 @@ public MultiPrefer(final String header) throws ParseException {

/**
* @param prefers
* @throws ParseException
*/
public MultiPrefer(final @HeaderParam("Prefer") Set<SinglePrefer> prefers) {
public MultiPrefer(final @HeaderParam("Prefer") Set<SinglePrefer> prefers) throws ParseException {
super("");
for (SinglePrefer prefer : prefers) {
preferTags().addAll(prefer.preferTags());
}
Expand Down
Expand Up @@ -38,35 +38,16 @@ public class SinglePrefer {

private final Set<PreferTag> preferTags = new TreeSet<>();

/**
* Simple empty constructor.
*/
protected SinglePrefer() {
}

/**
* Parse a Prefer: header
*
* @param inputValue
* @throws ParseException
*/
public SinglePrefer(final String header) throws ParseException {
this();
preferTags.addAll(HttpHeaderReader.readList(PREFER_CREATOR, header));
}

/**
* Constructs a {@link SinglePrefer} from two underlying SinglePrefers
*
* @param base
* @param additional
*/
public SinglePrefer(final SinglePrefer base, final SinglePrefer additional) {
this();
preferTags.addAll(base.preferTags());
preferTags.addAll(additional.preferTags());
}

/**
* Does the Prefer: header have a return tag
*
Expand Down
@@ -1,3 +1,18 @@
/**
* Copyright 2014 DuraSpace, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.fcrepo.http.commons.domain;

import static com.google.common.collect.Sets.newHashSet;
Expand All @@ -9,19 +24,23 @@
import org.junit.Test;


/**
* @author ajs6f
* @date 30 Oct 2014
*
*/
public class MultiPreferTest extends SinglePreferTest {

@Override
protected SinglePrefer createTestPreferTypeFromHeader(String header) throws ParseException {
protected SinglePrefer createTestPreferTypeFromHeader(final String header) throws ParseException {
return new MultiPrefer(header);
}

@Test
public void testMultiConstructor() throws ParseException {
SinglePrefer first = new SinglePrefer();
SinglePrefer second = new SinglePrefer("return=representation");
SinglePrefer third = new SinglePrefer("handling=strict");
MultiPrefer testPrefer = new MultiPrefer(newHashSet(first, second, third));
final SinglePrefer first = new SinglePrefer("return=representation");
final SinglePrefer second = new SinglePrefer("handling=strict");
final MultiPrefer testPrefer = new MultiPrefer(newHashSet(first, second));
// check to see that both headers were parsed
assertTrue(testPrefer.hasReturn());
assertEquals("representation", testPrefer.getReturn().getValue());
Expand Down
Expand Up @@ -28,7 +28,7 @@
*/
public class SinglePreferTest {

protected SinglePrefer createTestPreferTypeFromHeader(String header) throws ParseException {
protected SinglePrefer createTestPreferTypeFromHeader(final String header) throws ParseException {
return new SinglePrefer(header);
}

Expand All @@ -49,7 +49,8 @@ public void testGetReturn() throws ParseException {
@Test
public void testGetReturnParameters() throws ParseException {
final SinglePrefer prefer =
createTestPreferTypeFromHeader("return=representation; include=\"http://www.w3.org/ns/ldp#PreferMinimalContainer\"");
createTestPreferTypeFromHeader("return=representation; "
+ "include=\"http://www.w3.org/ns/ldp#PreferMinimalContainer\"");

assertTrue(prefer.hasReturn());
assertEquals("representation", prefer.getReturn().getValue());
Expand Down

0 comments on commit 83773bc

Please sign in to comment.