Commits

Kevin A. Archie  committed 4ebb655

bug fix for comment parsing, removed a Java 7-ism

  • Participants
  • Parent commits c193b48
  • Tags v2.1.1

Comments (0)

Files changed (6)

   <groupId>org.nrg</groupId>
   <artifactId>DicomEdit</artifactId>
   <packaging>jar</packaging>
-  <version>2.1.0</version>
+  <version>2.1.1</version>
   <name>DicomEdit</name>
-  <description>Implementation of a language for modifying DICOM metadata</description>
+  <description>Language for modifying DICOM metadata</description>
   <url>http://nrg.wustl.edu</url>
   <repositories>
     <repository>

File src/main/antlr3/org/nrg/dcm/edit/EditDCMLexer.g

     ;
 
 COMMENT
-    :   '//' ~('\n'|'\r')* '\r'? '\n' {$channel=HIDDEN;}
+    :   '//' ~('\n'|'\r')*
     ;
 
 WS  :   ( ' '

File src/main/antlr3/org/nrg/dcm/edit/EditDCMParser.g

 	package org.nrg.dcm.edit;
 }
 	
-script	:	NEWLINE!* EOF!
-	|	NEWLINE!* statement (NEWLINE!+ statement)* NEWLINE!* EOF!;
+script	:	separator!? EOF!
+	|	separator!? statement (separator! statement)* separator!? EOF!;
 
+separator 
+	:	(COMMENT? NEWLINE)+
+	;
+	
 statement
 	:	action
 	|	constraint action -> ^(CONSTRAINED action constraint)

File src/main/java/org/nrg/dcm/edit/ValueEqualsConstraint.java

  */
 package org.nrg.dcm.edit;
 
-import java.util.Objects;
+import com.google.common.base.Objects;
 
 
 /**
      * @see org.nrg.dcm.edit.AbstractValueConstraint#matches(java.lang.String, java.lang.String)
      */
     protected boolean matches(final String left, final String right) {
-        return Objects.equals(left, right);
+        return Objects.equal(left, right);
     }
 
     /*

File src/test/java/org/nrg/dcm/edit/NoOpTest.java

+/**
+ * Copyright (c) 2012 Washington University
+ */
+package org.nrg.dcm.edit;
+
+import java.util.Collections;
+
+import org.dcm4che2.data.BasicDicomObject;
+import org.dcm4che2.data.Tag;
+
+import junit.framework.TestCase;
+
+
+/**
+ * @author Kevin A. Archie <karchie@wustl.edu>
+ *
+ */
+public class NoOpTest extends TestCase {
+
+    /**
+     * Test method for {@link org.nrg.dcm.edit.NoOp#makeAction(org.dcm4che2.data.DicomObject)}.
+     */
+    public void testMakeAction() throws AttributeException,ScriptEvaluationException {
+        final Operation noop = new NoOp();
+        final Action noa = noop.makeAction(new BasicDicomObject());
+        assertTrue(noa.getTags().isEmpty());
+        noa.apply();    // TODO: make this a mock and verify zero interactions
+    }
+
+    /**
+     * Test method for {@link org.nrg.dcm.edit.NoOp#apply(java.util.Map)}.
+     */
+    public void testApply() throws ScriptEvaluationException {
+        final Operation noop = new NoOp();
+        assertEquals(null, noop.apply(Collections.singletonMap(Tag.StudyInstanceUID, "1.2.3.4")));
+    }
+
+    /**
+     * Test method for {@link org.nrg.dcm.edit.NoOp#getAffectedTags()}.
+     */
+    public void testGetAffectedTags() {
+        final Operation noop = new NoOp();
+        assertTrue(noop.getAffectedTags().isEmpty());
+    }
+
+    /**
+     * Test method for {@link org.nrg.dcm.edit.NoOp#getRequiredTags()}.
+     */
+    public void testGetRequiredTags() {
+        final Operation noop = new NoOp();
+        assertTrue(noop.getRequiredTags().isEmpty());
+    }
+}

File src/test/java/org/nrg/dcm/edit/ScriptApplicatorTest.java

 
     private static final String S_MULTILINE = "(0008,103e) :=\\\n\"foo\"\n";
 
-    private static final String S_COMMENT = "// (0008,103e) := \"foo\"\n";
+    private static final String S_COMMENT = "// (0008,103e) := \"foo\"\n(0008,103e) := \"bar\"\n";
 
     private static final String S_USE_VARIABLE = "(0008,103e) := studyDescription\n";
 
 
         final ScriptApplicator s_comment = new ScriptApplicator(bytes(S_COMMENT));
         final DicomObject do4_comment = s_comment.apply(f4);
-        assertEquals(do4.getString(Tag.SeriesDescription), do4_comment.getString(Tag.SeriesDescription));
+        assertEquals("bar", do4_comment.getString(Tag.SeriesDescription));
 
         final ScriptApplicator s_use_variable = new ScriptApplicator(bytes(S_USE_VARIABLE));
         final Variable studyDescVar = s_use_variable.getVariable("studyDescription");