test-support and temperature #2

Merged
adsu7578 merged 3 commits from test into develop 2022-05-13 13:43:41 +02:00
5 changed files with 32 additions and 8 deletions

View File

@ -1,5 +1,11 @@
# Springboot weather service
#### GIT:
- Create a new branch
- `add`, `commit` and `push` the branch to Gitea
- Create a `pull request` at Gitea from your branch to 'develop'
#### The _URI_ to access the current weather data:
https://group-4-75.pvt.dsv.su.se/weather-0.0.1-SNAPSHOT/weather

View File

@ -10,7 +10,7 @@
</parent>
<groupId>com.smhi</groupId>
<artifactId>weather</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>0.0.2-SNAPSHOT</version>
<packaging>war</packaging>
<name>weather</name>
<description>Collecting current weather data in Stockholm</description>
@ -33,6 +33,11 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-annotations
<dependency>

View File

@ -53,10 +53,13 @@ public class OpenWeatherService {
private OpenResponce buildResult(Root root) {
OpenResponce responce = new OpenResponce();
DataVO dvo = new DataVO();
for (TimeSeries ts : root.timeSeries) {
for (Parameter p : ts.parameters) {
if (p.getName().equalsIgnoreCase("t")) {
dvo.setTemp(p.getValues().get(0));
}
if (p.getName().equalsIgnoreCase("Wsymb2")) {
DataVO dvo = new DataVO();
dvo.setWsymb2(p.getValues().get(0).intValue());
responce.setDataVO(dvo);
return responce;

View File

@ -4,22 +4,32 @@ import java.io.Serializable;
public class DataVO implements Serializable {
int Wsymb2;
int wsymb2;
double temp;
public DataVO() {}
public int getWsymb2() {
return Wsymb2;
return wsymb2;
}
public void setWsymb2(int wsymb2) {
Wsymb2 = wsymb2;
this.wsymb2 = wsymb2;
}
public double getTemp() {
return temp;
}
public void setTemp(double temp) {
this.temp = temp;
}
@Override
public String toString() {
return "DataVO{" +
"Wsymb2=" + Wsymb2 +
"wsymb2=" + wsymb2 +
", temp=" + temp +
'}';
}
}

View File

@ -1,8 +1,8 @@
package com.smhi.weather;
import org.junit.jupiter.api.Test;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.*;
import static org.junit.Assert.*;
class OpenWeatherServiceTest {