/*
 * Test for PDCController
 */
package de.ddb.pdc.web;

import de.ddb.pdc.answerer.AnswererService;
import de.ddb.pdc.core.AnsweredQuestion;
import de.ddb.pdc.core.PDCResult;
import de.ddb.pdc.metadata.DDBItem;
import de.ddb.pdc.metadata.MetaFetcher;
import java.util.ArrayList;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import org.mockito.Mockito;

public class PDCControllerTest {

  @Test
  public void calculate() throws Exception{
    MetaFetcher mfetcher = Mockito.mock(MetaFetcher.class);
    AnswererService ansService = Mockito.mock(AnswererService.class);
    DDBItem ddbItemfromMetaFetcher = new DDBItem("123");
    List<AnsweredQuestion> trace = new ArrayList<AnsweredQuestion>();
    PDCResult pdcResult = new PDCResult(true,trace);
    Mockito.when(mfetcher.fetchMetadata("123")).thenReturn(ddbItemfromMetaFetcher);
    Mockito.when(ansService.getResult("Germany", ddbItemfromMetaFetcher)).thenReturn(pdcResult);
    PDCController pdcController = new PDCController(mfetcher, ansService);
    Mockito.when(pdcController.calculate("123")).thenReturn(pdcResult);

    Assert.assertSame(pdcResult, pdcController.calculate("123"));
  }

}

@@ -480,16 +480,18 @@
 ption%7B%0D%0A
+%0D%0A
     Meta
@@ -539,24 +539,169 @@
 er.class);%0D%0A
+    DDBItem ddbItemfromMetaFetcher = new DDBItem(%22123%22);%0D%0A    Mockito.when(mfetcher.fetchMetadata(%22123%22)).thenReturn(ddbItemfromMetaFetcher);%0D%0A%0D%0A
     Answerer
@@ -763,66 +763,8 @@
 );%0D%0A
-    DDBItem ddbItemfromMetaFetcher = new DDBItem(%22123%22);%0D%0A
     
@@ -892,87 +892,26 @@
     
-Mockito.when(mfetcher.fetchMetadata(%22123%22)).thenReturn(ddbItemfromMetaFetcher);
+// country is null
 %0D%0A  
@@ -950,41 +950,43 @@
 ult(
-%22Germany%22, ddbItemfromMetaFetcher
+null, mfetcher.fetchMetadata(%22123%22)
 )).t
@@ -1004,24 +1004,26 @@
 dcResult);%0D%0A
+%0D%0A
     PDCContr
@@ -1089,81 +1089,8 @@
 e);%0D
-%0A    Mockito.when(pdcController.calculate(%22123%22)).thenReturn(pdcResult);%0D
 %0A%0D%0A 

Add test for calculate-method in PDCControllerTest.