Skip to content

Commit

Permalink
#78: Data.selection package at 100%.
Browse files Browse the repository at this point in the history
  • Loading branch information
jvdb committed Jul 26, 2016
1 parent 624c0e1 commit 6fe1b04
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright 2013-2016 Netherlands Forensic Institute
*
* 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 io.parsingdata.metal.data.selection;

import io.parsingdata.metal.data.ParseGraph;
import org.junit.Test;

import static junit.framework.TestCase.assertNull;

public class ByNameTest {

@Test
public void getValueOnEmpty() {
assertNull(ByName.getValue(ParseGraph.EMPTY, "name"));
}

@Test
public void getValueOnBranchedEmpty() {
assertNull(ByName.getValue(ParseGraph.EMPTY.addBranch(ParseGraph.NONE), "name"));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright 2013-2016 Netherlands Forensic Institute
*
* 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 io.parsingdata.metal.data.selection;

import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;

import static io.parsingdata.metal.data.ParseGraph.EMPTY;
import static io.parsingdata.metal.data.selection.ByOffset.getLowestOffsetValue;

public class ByOffsetTest {

@Rule
public ExpectedException thrown = ExpectedException.none();

@Test
public void getLowestOffsetWithoutValue() {
thrown.expect(IllegalStateException.class);
thrown.expectMessage("Cannot determine lowest offset if graph does not contain a value.");
getLowestOffsetValue(EMPTY);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright 2013-2016 Netherlands Forensic Institute
*
* 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 io.parsingdata.metal.data.selection;

import io.parsingdata.metal.data.ParseRef;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;

import static io.parsingdata.metal.data.ParseGraph.EMPTY;
import static io.parsingdata.metal.data.ParseGraph.NONE;
import static io.parsingdata.metal.data.selection.ByType.getRefs;

public class ByTypeTest {

@Rule
public ExpectedException thrown = ExpectedException.none();

@Test
public void unresolvableRef() {
thrown.expect(IllegalStateException.class);
thrown.expectMessage("A ref must point to an existing graph.");
getRefs(EMPTY.add(new ParseRef(0, NONE)));
}

}

0 comments on commit 6fe1b04

Please sign in to comment.