Code cleanup.
diff --git a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/scoping/ProtoDescriptor_availableOptionsFor_Test.java b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/scoping/ProtoDescriptor_availableOptionsFor_Test.java
index ba4bd84..1812287 100644
--- a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/scoping/ProtoDescriptor_availableOptionsFor_Test.java
+++ b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/scoping/ProtoDescriptor_availableOptionsFor_Test.java
@@ -12,8 +12,7 @@
 import static com.google.eclipse.protobuf.junit.core.XtextRule.createWith;
 import static com.google.eclipse.protobuf.junit.matchers.PropertyHasType.*;
 import static org.hamcrest.core.IsEqual.equalTo;
-import static org.hamcrest.core.IsNull.notNullValue;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.*;
 import static org.mockito.Mockito.mock;
 
 import java.util.*;
@@ -49,7 +48,7 @@
     assertThat(options.option("java_outer_classname"), isString());
     assertThat(options.option("java_multiple_files"), isBool());
     assertThat(options.option("java_generate_equals_and_hash"), isBool());
-    assertThat(options.option("optimize_for"), notNullValue());
+    assertNotNull(options.option("optimize_for"));
     assertThat(options.option("cc_generic_services"), isBool());
     assertThat(options.option("java_generic_services"), isBool());
     assertThat(options.option("py_generic_services"), isBool());
@@ -65,7 +64,7 @@
   @Test public void should_return_all_field_options() {
     Property optionContainer = mock(Property.class);
     options.mapByName(descriptor.availableOptionsFor(optionContainer));
-    assertThat(options.option("ctype"), notNullValue());
+    assertNotNull(options.option("ctype"));
     assertThat(options.option("packed"), isBool());
     assertThat(options.option("deprecated"), isBool());
     assertThat(options.option("experimental_map_key"), isString());
diff --git a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/scoping/ProtoDescriptor_enumTypeOf_Test.java b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/scoping/ProtoDescriptor_enumTypeOf_Test.java
index 01f84f8..68c1e30 100644
--- a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/scoping/ProtoDescriptor_enumTypeOf_Test.java
+++ b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/scoping/ProtoDescriptor_enumTypeOf_Test.java
@@ -12,8 +12,7 @@
 import static com.google.eclipse.protobuf.junit.core.XtextRule.createWith;
 import static com.google.eclipse.protobuf.scoping.OptionType.FILE;
 import static org.hamcrest.core.IsEqual.equalTo;
-import static org.hamcrest.core.IsNull.nullValue;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.*;
 
 import org.junit.*;
 
@@ -44,6 +43,6 @@
   }
 
   @Test public void should_return_null_if_property_is_null() {
-    assertThat(descriptor.enumTypeOf(null), nullValue());
+    assertNull(descriptor.enumTypeOf(null));
   }
 }
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/bugs/Issue91_AddSupportForUTF16Strings_Test.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/bugs/Issue91_AddSupportForUTF16Strings_Test.java
index b694cbe..d08e795 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/bugs/Issue91_AddSupportForUTF16Strings_Test.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/bugs/Issue91_AddSupportForUTF16Strings_Test.java
@@ -10,14 +10,13 @@
 
 import static com.google.eclipse.protobuf.junit.core.Setups.unitTestSetup;
 import static com.google.eclipse.protobuf.junit.core.XtextRule.createWith;
-import static org.hamcrest.core.IsNull.notNullValue;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.*;
 
 import com.google.eclipse.protobuf.junit.core.XtextRule;
 import com.google.eclipse.protobuf.protobuf.Protobuf;
 
-import org.junit.*;
-
 /**
  * Tests fix for <a href="http://code.google.com/p/protobuf-dt/issues/detail?id=91">Issue 91</a>.
  * 
@@ -37,6 +36,6 @@
   //    optional string bar = 1 [default="\\302\\265"];
   //  }
   @Test public void should_recognize_UTF16_strings() {
-    assertThat(root, notNullValue());
+    assertNotNull(root);
   }
 }
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/ModelFinder_enumTypeOf_Test.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/ModelFinder_enumTypeOf_Test.java
index e4651ce..c699f5d 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/ModelFinder_enumTypeOf_Test.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/ModelFinder_enumTypeOf_Test.java
@@ -11,15 +11,14 @@
 import static com.google.eclipse.protobuf.junit.core.Setups.unitTestSetup;
 import static com.google.eclipse.protobuf.junit.core.XtextRule.createWith;
 import static org.hamcrest.core.IsEqual.equalTo;
-import static org.hamcrest.core.IsNull.nullValue;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.*;
+
+import org.junit.*;
 
 import com.google.eclipse.protobuf.junit.core.XtextRule;
 import com.google.eclipse.protobuf.protobuf.*;
 import com.google.eclipse.protobuf.protobuf.Enum;
 
-import org.junit.*;
-
 /**
  * Tests for <code>{@link ModelFinder#enumTypeOf(Property)}</code>.
  *
@@ -55,7 +54,6 @@
   // }
   @Test public void should_return_null_if_property_type_is_not_enum() {
     Property name = xtext.find("name", Property.class);
-    Enum anEnum = finder.enumTypeOf(name);
-    assertThat(anEnum, nullValue());
+    assertNull(finder.enumTypeOf(name));
   }
 }
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/ModelFinder_packageOf_Test.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/ModelFinder_packageOf_Test.java
index 668d3d7..6dc128f 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/ModelFinder_packageOf_Test.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/ModelFinder_packageOf_Test.java
@@ -11,16 +11,15 @@
 import static com.google.eclipse.protobuf.junit.core.Setups.unitTestSetup;
 import static com.google.eclipse.protobuf.junit.core.XtextRule.createWith;
 import static org.hamcrest.core.IsEqual.equalTo;
-import static org.hamcrest.core.IsNull.nullValue;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.*;
+
+import org.eclipse.emf.ecore.EObject;
+import org.junit.*;
 
 import com.google.eclipse.protobuf.junit.core.XtextRule;
 import com.google.eclipse.protobuf.protobuf.*;
 import com.google.eclipse.protobuf.protobuf.Package;
 
-import org.eclipse.emf.ecore.EObject;
-import org.junit.*;
-
 /**
  * Tests for <code>{@link ModelFinder#packageOf(EObject)}</code>.
  *
@@ -52,7 +51,6 @@
   // }
   @Test public void should_return_null_if_proto_does_not_have_package() {
     Property id = xtext.find("id", Property.class);
-    Package aPackage = finder.packageOf(id);
-    assertThat(aPackage, nullValue());
+    assertNull(finder.packageOf(id));
   }
 }
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/ModelFinder_scalarTypeOf_Test.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/ModelFinder_scalarTypeOf_Test.java
index 4e33278..a021e26 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/ModelFinder_scalarTypeOf_Test.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/ModelFinder_scalarTypeOf_Test.java
@@ -11,14 +11,13 @@
 import static com.google.eclipse.protobuf.junit.core.Setups.unitTestSetup;
 import static com.google.eclipse.protobuf.junit.core.XtextRule.createWith;
 import static org.hamcrest.core.IsEqual.equalTo;
-import static org.hamcrest.core.IsNull.nullValue;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.*;
+
+import org.junit.*;
 
 import com.google.eclipse.protobuf.junit.core.XtextRule;
 import com.google.eclipse.protobuf.protobuf.*;
 
-import org.junit.*;
-
 /**
  * Tests for <code>{@link ModelFinder#scalarTypeOf(Property)}</code>.
  *
@@ -54,7 +53,6 @@
   // }
   @Test public void should_return_null_if_property_type_is_not_scalar() {
     Property type = xtext.find("type", Property.class);
-    ScalarType scalar = finder.scalarTypeOf(type);
-    assertThat(scalar, nullValue());
+    assertNull(finder.scalarTypeOf(type));
   }
 }
diff --git a/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/builder/ProtoDescriptorPathFinder_findRootOf_Test.java b/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/builder/ProtoDescriptorPathFinder_findRootOf_Test.java
index 015dda5..9639d8f 100644
--- a/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/builder/ProtoDescriptorPathFinder_findRootOf_Test.java
+++ b/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/builder/ProtoDescriptorPathFinder_findRootOf_Test.java
@@ -9,8 +9,7 @@
 package com.google.eclipse.protobuf.ui.builder;
 
 import static org.hamcrest.core.IsEqual.equalTo;
-import static org.hamcrest.core.IsNull.nullValue;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.*;
 import static org.junit.rules.ExpectedException.none;
 
 import org.junit.*;
@@ -32,11 +31,11 @@
   @Rule public ExpectedException thrown = none();
 
   @Test public void should_return_null_if_path_is_null() {
-    assertThat(finder.findRootOf(null), nullValue());
+    assertNull(finder.findRootOf(null));
   }
 
   @Test public void should_return_null_if_path_is_empty() {
-    assertThat(finder.findRootOf(""), nullValue());
+    assertNull(finder.findRootOf(""));
   }
 
   @Test public void should_throw_error_if_path_does_not_contain_descriptor_FQN() {
diff --git a/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/commands/CommentNodesFinder_matchingCommentNode_Test.java b/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/commands/CommentNodesFinder_matchingCommentNode_Test.java
index 56cb222..6db1908 100644
--- a/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/commands/CommentNodesFinder_matchingCommentNode_Test.java
+++ b/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/commands/CommentNodesFinder_matchingCommentNode_Test.java
@@ -11,18 +11,17 @@
 import static com.google.eclipse.protobuf.junit.core.Setups.unitTestSetup;
 import static com.google.eclipse.protobuf.junit.core.XtextRule.createWith;
 import static org.hamcrest.core.IsEqual.equalTo;
-import static org.hamcrest.core.IsNull.*;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.*;
 
-import com.google.eclipse.protobuf.junit.core.XtextRule;
-import com.google.eclipse.protobuf.protobuf.*;
+import java.util.regex.Matcher;
 
 import org.eclipse.emf.ecore.EObject;
 import org.eclipse.xtext.nodemodel.INode;
 import org.eclipse.xtext.util.Pair;
 import org.junit.*;
 
-import java.util.regex.Matcher;
+import com.google.eclipse.protobuf.junit.core.XtextRule;
+import com.google.eclipse.protobuf.protobuf.Property;
 
 /**
  * Tests for <code>{@link CommentNodesFinder#matchingCommentNode(EObject, String...)}</code>.
@@ -59,8 +58,7 @@
   @Test public void should_return_matching_multi_line_comment_of_element() {
     Property active = xtext.find("active", Property.class);
     Pair<INode, Matcher> match = finder.matchingCommentNode(active, "NEXT ID: [\\d]+");
-    INode node = match.getFirst();
-    assertThat(node, notNullValue());
+    assertNotNull(match.getFirst());
   }
 
   // message Person {
@@ -70,6 +68,6 @@
   @Test public void should_return_null_if_no_matching_node_found() {
     Property active = xtext.find("active", Property.class);
     Pair<INode, Matcher> match = finder.matchingCommentNode(active, "Hello");
-    assertThat(match, nullValue());
+    assertNull(match);
   }
 }
diff --git a/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/scoping/SingleDirectoryFileResolver_resolveUri_Test.java b/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/scoping/SingleDirectoryFileResolver_resolveUri_Test.java
index 737370f..7ca5aff 100644
--- a/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/scoping/SingleDirectoryFileResolver_resolveUri_Test.java
+++ b/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/scoping/SingleDirectoryFileResolver_resolveUri_Test.java
@@ -10,7 +10,7 @@
 
 import static org.eclipse.emf.common.util.URI.createURI;
 import static org.hamcrest.core.IsEqual.equalTo;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.*;
 import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.*;
 
@@ -44,20 +44,30 @@
   }
 
   @Test public void should_resolve_import_URI_if_missing_scheme() {
-    when(resources.fileExists(any(URI.class))).thenReturn(true);
+    expectResolvedPathToBelongToExistingFile();
     String resolved = resolver.resolveUri("folder1/address.proto", resourceUri, preferences);
     assertThat(resolved, equalTo("platform:/resource/src/proto/folder1/address.proto"));
   }
 
-  @Test public void should_resolve_import_URI_even_if_overlapping_folders_with_resource_URI() {
-    when(resources.fileExists(any(URI.class))).thenReturn(true);
+  @Test public void should_resolve_import_URI_when_overlapping_folders_with_resource_URI() {
+    expectResolvedPathToBelongToExistingFile();
     String resolved = resolver.resolveUri("src/proto/folder1/address.proto", resourceUri, preferences);
     assertThat(resolved, equalTo("platform:/resource/src/proto/folder1/address.proto"));
   }
 
-  @Test public void should_resolve_import_URI_even_if_overlapping_one_folder_only_with_resource_URI() {
-    when(resources.fileExists(any(URI.class))).thenReturn(true);
+  @Test public void should_resolve_import_URI_when_overlapping_one_folder_only_with_resource_URI() {
+    expectResolvedPathToBelongToExistingFile();
     String resolved = resolver.resolveUri("src/proto/read-only/address.proto", resourceUri, preferences);
     assertThat(resolved, equalTo("platform:/resource/src/proto/read-only/address.proto"));
   }
+  
+  private void expectResolvedPathToBelongToExistingFile() {
+    when(resources.fileExists(any(URI.class))).thenReturn(true);
+  }
+  
+  @Test public void should_return_null_if_URI_cannot_be_resolved() {
+    when(resources.fileExists(any(URI.class))).thenReturn(false);
+    String resolved = resolver.resolveUri("src/proto/read-only/person.proto", resourceUri, preferences);
+    assertNull(resolved);
+  }
 }
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/scoping/SingleDirectoryFileResolver.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/scoping/SingleDirectoryFileResolver.java
index 95124f5..163188d 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/scoping/SingleDirectoryFileResolver.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/scoping/SingleDirectoryFileResolver.java
@@ -9,12 +9,10 @@
 package com.google.eclipse.protobuf.ui.scoping;
 
 import static org.eclipse.emf.common.util.URI.createURI;
-import static org.eclipse.xtext.util.Tuples.pair;
 
 import java.util.*;
 
 import org.eclipse.emf.common.util.URI;
-import org.eclipse.xtext.util.Pair;
 
 import com.google.eclipse.protobuf.ui.preferences.pages.paths.PathsPreferences;
 import com.google.eclipse.protobuf.ui.util.Resources;
@@ -31,29 +29,39 @@
   }
 
   @Override public String resolveUri(String importUri, URI declaringResourceUri, PathsPreferences preferences) {
-    List<String> resourceUriSegments = removeFirstAndLast(declaringResourceUri.segmentsList());
-    Pair<String, List<String>> importUriPair = pair(importUri, createURI(importUri).segmentsList());
-    return resolveUri(importUriPair, resourceUriSegments);
+    return resolveUri(createURI(importUri), declaringResourceUri);
   }
 
-  // first is always "platform" and last is the file name (both unnecessary)
-  private static List<String> removeFirstAndLast(List<String> list) {
-    if (list.isEmpty()) return list;
-    List<String> newList = new ArrayList<String>(list);
-    newList.remove(0);
-    newList.remove(newList.size() - 1);
-    return newList;
-  }
-
-  private String resolveUri(Pair<String, List<String>> importUri, List<String> resourceUri) {
+  private String resolveUri(URI importUri, URI declaringResourceUri) {
     StringBuilder pathBuilder = new StringBuilder();
-    String firstSegment = importUri.getSecond().get(0);
-    for (String segment : resourceUri) {
+    String firstSegment = importUri.segments()[0];
+    for (String segment : removeFirstAndLast(declaringResourceUri)) {
       if (segment.equals(firstSegment)) break;
       pathBuilder.append(segment).append(SEPARATOR);
     }
-    String resolved = PLATFORM_RESOURCE_PREFIX + SEPARATOR + pathBuilder.toString() + importUri.getFirst();
-    return (resources.fileExists(createURI(resolved))) ? resolved : null;
+    String resolved = createResolvedUri(pathBuilder.toString(), importUri);
+    return fileExists(resolved) ? resolved : null;
   }
 
+  private String createResolvedUri(String path, URI importUri) {
+    StringBuilder uriBuilder = new StringBuilder();
+    return uriBuilder.append(PLATFORM_RESOURCE_PREFIX)
+                     .append(SEPARATOR)
+                     .append(path)
+                     .append(importUri.toString())
+                     .toString();
+  }
+  
+  private boolean fileExists(String uri) {
+    return resources.fileExists(createURI(uri));
+  }
+  
+  // first is always "platform" and last is the file name (both unnecessary)
+  private static List<String> removeFirstAndLast(URI declaringResourceUri) {
+    List<String> segments = new ArrayList<String>(declaringResourceUri.segmentsList());
+    if (segments.isEmpty()) return segments;
+    segments.remove(0);
+    segments.remove(segments.size() - 1);
+    return segments;
+  }
 }