Skip to content
Browse files

Unit test constructed

  • Loading branch information...
1 parent a260c0a commit c3fa60ba81e14ac868c5c20b7565a02f0fd94e55 @mwl mwl committed Sep 16, 2012
View
4 sc-web/src/main/java/dk/sst/snomedcave/controllers/DrugController.java
@@ -102,9 +102,7 @@ public boolean evaluate(ConceptRelation relation) {
concept = conceptRepository.findOne(causativesDrugAllergy.get(0).getChild().getNodeId());
- JsonObject response = new JsonObject();
- response.addProperty("allergyId", concept.getConceptId());
- return new ResponseEntity<String>(gson.toJson(response), HttpStatus.OK);
+ return new ResponseEntity<String>(gson.toJson(concept.getConceptId()), HttpStatus.OK);
}
private long causativeAgentId() {
View
45 sc-web/src/test/java/dk/sst/snomedcave/controllers/DrugControllerTest.java
@@ -0,0 +1,45 @@
+package dk.sst.snomedcave.controllers;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.ImportResource;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.inject.Inject;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = DrugControllerTest.TestConfig.class)
+@Transactional
+public class DrugControllerTest {
+ Gson gson = new GsonBuilder().create();
+
+ @Configuration
+ @ImportResource("classpath:/Neo4jConfig.xml")
+ public static class TestConfig {
+ @Bean
+ public DrugController drugController() {
+ return new DrugController();
+ }
+ }
+
+ @Inject
+ DrugController drugController;
+
+ @Test
+ public void willAlwaysReturnNonCombinedDrug() throws Exception {
+ for (int i = 0; i < 10; i++) {
+ String json = drugController.tree("Paracetamol").getBody();
+ assertNotNull(json);
+ assertEquals(i + " of 10", "293584003", gson.fromJson(json, String.class));
+ }
+ }
+}

0 comments on commit c3fa60b

Please sign in to comment.
Something went wrong with that request. Please try again.