diff --git a/src/main/java/no/nibio/model/maizepheno/MaizePhenologyModel.java b/src/main/java/no/nibio/model/maizepheno/MaizePhenologyModel.java index cf0a5c21b320247fdfa1abea7c257dc78ea3f599..7d08ea267bbe440b0191655d3ef4213266f90a24 100644 --- a/src/main/java/no/nibio/model/maizepheno/MaizePhenologyModel.java +++ b/src/main/java/no/nibio/model/maizepheno/MaizePhenologyModel.java @@ -19,13 +19,10 @@ package no.nibio.model.maizepheno; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; import java.text.DecimalFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; -import java.util.Arrays; import java.util.Calendar; import java.util.Collections; import java.util.Date; @@ -33,8 +30,6 @@ import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.TimeZone; -import java.util.logging.Level; -import java.util.logging.Logger; import no.nibio.vips.entity.ModelConfiguration; import no.nibio.vips.entity.Result; import no.nibio.vips.entity.ResultImpl; @@ -130,62 +125,86 @@ public class MaizePhenologyModel extends I18nImpl implements Model{ @Override public ModelId getModelId() { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + return MaizePhenologyModel.MODEL_ID; } @Override public String getModelName() { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + return this.getModelName(Model.DEFAULT_LANGUAGE); } @Override public String getModelName(String language) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + return this.getText("name", language); } @Override public String getLicense() { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + return "Copyright (c) 2022 NIBIO <http://www.nibio.no/>. \n" + + "\n" + + "This file is part of Model_MAIZEPHENO. \n" + + "AppleScabModel is free software: you can redistribute it and/or modify \n" + + "it under the terms of the NIBIO Open Source License as published by \n" + + "NIBIO, either version 1 of the License, or (at your option) any \n" + + "later version. \n" + + "\n" + + "Model_MAIZEPHENO is distributed in the hope that it will be useful, \n" + + "but WITHOUT ANY WARRANTY; without even the implied warranty of \n" + + "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the \n" + + "NIBIO Open Source License for more details. \n" + + "" + + "You should have received a copy of the NIBIO Open Source License \n" + + "along with Model_MAIZEPHENO. If not, see <http://www.nibio.no/licenses/>. \n"; + } @Override public String getCopyright() { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + return "(c) 2022 NIBIO (http://www.nibio.no/). Contact: post@nibio.no"; } @Override public String getModelDescription() { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + return this.getModelDescription(Model.DEFAULT_LANGUAGE); } @Override public String getModelDescription(String language) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + return this.getText("description", language); } @Override public String getWarningStatusInterpretation() { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + return this.getWarningStatusInterpretation(Model.DEFAULT_LANGUAGE); } @Override public String getWarningStatusInterpretation(String language) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + return this.getText("statusInterpretation", language); } @Override public String getModelUsage() { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + return this.getModelUsage(Model.DEFAULT_LANGUAGE); } @Override public String getModelUsage(String language) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + return this.getText("usage", language); } @Override public String getSampleConfig() { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + return "{\n" + +" \"sowingDate\":\"2020-11-18\",\n" + +" \"timeZone\":\"GMT+01:00\",\n" + +" \"observations\":[\n" + +" {\"elementMeasurementTypeId\":\"TM\",\"logIntervalId\":1,\"timeMeasured\":\"2020-11-16T07:00:00Z\",\"value\":28.799999999999997},\n" + +" {\"elementMeasurementTypeId\":\"TM\",\"logIntervalId\":1,\"timeMeasured\":\"2020-11-16T08:00:00Z\",\"value\":30.191666666666663},\n" + +" {\"elementMeasurementTypeId\":\"TM\",\"logIntervalId\":1,\"timeMeasured\":\"2020-11-16T09:00:00Z\",\"value\":32.18333333333333}\n" + +" [...]\n" + +" ]\n" + +"}"; } @Override diff --git a/src/main/resources/no/nibio/vips/model/maizepheno/texts.properties b/src/main/resources/no/nibio/vips/model/maizepheno/texts.properties index b9b829d15565eb3931b5af163aeda0dc0d6d75a6..cf90f52bd4e8ae854670217d431e66a23ef78d1b 100644 --- a/src/main/resources/no/nibio/vips/model/maizepheno/texts.properties +++ b/src/main/resources/no/nibio/vips/model/maizepheno/texts.properties @@ -16,6 +16,6 @@ # name=Maize Phenology Model -usage= +usage=Input data are timeZone (e.g. "GMT+01:00"), sowingDate (e.g. "2020-11-15") and weather observations. They may be daily min and max temperatures, or hourly mean temperatures description= statusInterpretation= diff --git a/src/test/java/no/nibio/model/maizepheno/MaizePhenologyModelTest.java b/src/test/java/no/nibio/model/maizepheno/MaizePhenologyModelTest.java index ebbdd87fe7cbab7c68038476c315b3714be15cae..d9d8acb3e5776b5b998db53d1b3171e6c2707c3b 100644 --- a/src/test/java/no/nibio/model/maizepheno/MaizePhenologyModelTest.java +++ b/src/test/java/no/nibio/model/maizepheno/MaizePhenologyModelTest.java @@ -90,8 +90,6 @@ public class MaizePhenologyModelTest { assertNotNull(result); //result.forEach(r->System.out.println(r)); - // TODO review the generated test code and remove the default call to fail. - fail("The test case is a prototype."); } /** @@ -101,11 +99,10 @@ public class MaizePhenologyModelTest { public void testGetModelId() { System.out.println("getModelId"); MaizePhenologyModel instance = new MaizePhenologyModel(); - ModelId expResult = null; + String expResult = "MAIZEPHENO"; ModelId result = instance.getModelId(); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - fail("The test case is a prototype."); + assertEquals(expResult, result.toString()); + } /** @@ -115,11 +112,10 @@ public class MaizePhenologyModelTest { public void testGetModelName_0args() { System.out.println("getModelName"); MaizePhenologyModel instance = new MaizePhenologyModel(); - String expResult = ""; + String expResult = "Maize Phenology Model"; String result = instance.getModelName(); assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - fail("The test case is a prototype."); + } /** @@ -128,13 +124,12 @@ public class MaizePhenologyModelTest { @org.junit.jupiter.api.Test public void testGetModelName_String() { System.out.println("getModelName"); - String language = ""; + String language = "nb"; MaizePhenologyModel instance = new MaizePhenologyModel(); - String expResult = ""; + String expResult = "Mais-fenologimodell"; String result = instance.getModelName(language); assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - fail("The test case is a prototype."); + } /** @@ -144,11 +139,9 @@ public class MaizePhenologyModelTest { public void testGetLicense() { System.out.println("getLicense"); MaizePhenologyModel instance = new MaizePhenologyModel(); - String expResult = ""; String result = instance.getLicense(); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - fail("The test case is a prototype."); + assertNotNull(result); + } /** @@ -158,11 +151,10 @@ public class MaizePhenologyModelTest { public void testGetCopyright() { System.out.println("getCopyright"); MaizePhenologyModel instance = new MaizePhenologyModel(); - String expResult = ""; + String expResult = "(c) 2022 NIBIO (http://www.nibio.no/). Contact: post@nibio.no"; String result = instance.getCopyright(); assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - fail("The test case is a prototype."); + } /** @@ -172,11 +164,8 @@ public class MaizePhenologyModelTest { public void testGetModelDescription_0args() { System.out.println("getModelDescription"); MaizePhenologyModel instance = new MaizePhenologyModel(); - String expResult = ""; String result = instance.getModelDescription(); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - fail("The test case is a prototype."); + assertNotNull(result); } /** @@ -185,13 +174,10 @@ public class MaizePhenologyModelTest { @org.junit.jupiter.api.Test public void testGetModelDescription_String() { System.out.println("getModelDescription"); - String language = ""; + String language = "nb"; MaizePhenologyModel instance = new MaizePhenologyModel(); - String expResult = ""; String result = instance.getModelDescription(language); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - fail("The test case is a prototype."); + assertNotNull(result); } /** @@ -201,11 +187,9 @@ public class MaizePhenologyModelTest { public void testGetWarningStatusInterpretation_0args() { System.out.println("getWarningStatusInterpretation"); MaizePhenologyModel instance = new MaizePhenologyModel(); - String expResult = ""; String result = instance.getWarningStatusInterpretation(); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - fail("The test case is a prototype."); + assertNotNull(result); + } /** @@ -214,13 +198,10 @@ public class MaizePhenologyModelTest { @org.junit.jupiter.api.Test public void testGetWarningStatusInterpretation_String() { System.out.println("getWarningStatusInterpretation"); - String language = ""; + String language = "nb"; MaizePhenologyModel instance = new MaizePhenologyModel(); - String expResult = ""; String result = instance.getWarningStatusInterpretation(language); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - fail("The test case is a prototype."); + assertNotNull(result); } /** @@ -230,11 +211,9 @@ public class MaizePhenologyModelTest { public void testGetModelUsage_0args() { System.out.println("getModelUsage"); MaizePhenologyModel instance = new MaizePhenologyModel(); - String expResult = ""; String result = instance.getModelUsage(); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - fail("The test case is a prototype."); + assertNotNull(result); + } /** @@ -245,11 +224,9 @@ public class MaizePhenologyModelTest { System.out.println("getModelUsage"); String language = ""; MaizePhenologyModel instance = new MaizePhenologyModel(); - String expResult = ""; String result = instance.getModelUsage(language); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - fail("The test case is a prototype."); + assertNotNull(result); + } /** @@ -259,11 +236,9 @@ public class MaizePhenologyModelTest { public void testGetSampleConfig() { System.out.println("getSampleConfig"); MaizePhenologyModel instance = new MaizePhenologyModel(); - String expResult = ""; String result = instance.getSampleConfig(); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - fail("The test case is a prototype."); + assertTrue(result.indexOf("sowingDate") > 0); + }