Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ jobs:
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- uses: gradle/wrapper-validation-action@v1
- uses: actions/checkout@v4
- uses: gradle/actions/wrapper-validation@v4

- name: Set up JDK 1.8
uses: actions/setup-java@v1
- name: Setup Java
uses: actions/setup-java@v4
with:
java-version: 1.8
distribution: 'jetbrains'
java-version: '21'
- name: Build and Unit Test
run: ./gradlew build
23 changes: 23 additions & 0 deletions .idea/appInsightsSettings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

340 changes: 340 additions & 0 deletions .idea/caches/deviceStreaming.xml

Large diffs are not rendered by default.

12 changes: 11 additions & 1 deletion .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/migrations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions .idea/runConfigurations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/studiobot.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## UNRELEASED

### Changed

- Bump Kotlin version to 1.9.20
- Bump Gradle to 8.9
- Bump mockito to 5.13.0
- Bump to JDK_1_8
- Replace jcenter() with mavenCentral()
- Update github actions setup

## 1.0.0 - 2021-02-15

### Added
Expand Down
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ POM_DEV_EMAIL=kruk.oleksandr@gmail.com
POM_SCM_URL=https://github.com/0mega/worldtides/
POM_SCM_CONNECTION=scm:git@github.com:0mega/worldtides.git
POM_SCM_DEV_CONNECTION=scm:git@github.com:0mega/worldtides.git

org.gradle.warning.mode=all
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#Sun Jan 12 21:38:08 GMT 2025
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
12 changes: 5 additions & 7 deletions worldtides/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

plugins {
// Apply the org.jetbrains.kotlin.jvm Plugin to add support for Kotlin.
id("org.jetbrains.kotlin.jvm") version "1.4.10"
id("org.jetbrains.kotlin.jvm") version "1.9.20"

// Apply the java-library plugin for API and implementation separation.
`java-library`
Expand All @@ -14,8 +14,8 @@ plugins {
}

repositories {
// Use JCenter for resolving dependencies.
jcenter()
// Use Maven central for resolving dependencies.
mavenCentral()
}

dependencies {
Expand All @@ -34,14 +34,12 @@ dependencies {
implementation("com.squareup.moshi:moshi-kotlin:1.11.0")

// Use the Kotlin test library.
testImplementation("org.jetbrains.kotlin:kotlin-test")
// Use the Kotlin JUnit integration.
testImplementation("org.jetbrains.kotlin:kotlin-test-junit")
testImplementation(kotlin("test"))
testImplementation("org.assertj:assertj-core:3.12.2")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.6.2")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.6.2")
testImplementation("com.squareup.okhttp3:mockwebserver:3.12.0")
testImplementation("org.mockito:mockito-core:3.3.1")
testImplementation("org.mockito:mockito-core:5.13.0")
}

group = project.property("GROUP") as String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ package com.oleksandrkruk.worldtides.extremes
import com.oleksandrkruk.worldtides.RetrofitClient
import okhttp3.mockwebserver.MockResponse
import okhttp3.mockwebserver.MockWebServer
import org.junit.Assert
import org.junit.jupiter.api.AfterEach
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test

Expand Down Expand Up @@ -58,70 +59,70 @@ class WorldTidesGatewayTest {
fun containsExtremesInQueryParams() {
val response = service?.extremes("foo", 1, "bar", "baz", "key")?.execute()
val requestUrl = response?.raw()?.request()?.url()
Assert.assertTrue(requestUrl!!.queryParameterNames().contains("extremes"))
assertTrue(requestUrl!!.queryParameterNames().contains("extremes"))
}

@Test
fun containsDateInQueryParams() {
val response = service?.extremes("foo", 1, "bar", "baz", "key")?.execute()
val requestUrl = response?.raw()?.request()?.url()
Assert.assertTrue(requestUrl!!.queryParameterNames().contains("date"))
Assert.assertEquals("foo", requestUrl.queryParameter("date"))
assertTrue(requestUrl!!.queryParameterNames().contains("date"))
assertEquals("foo", requestUrl.queryParameter("date"))
}

@Test
fun containsDaysInQueryParams() {
val response = service?.extremes("foo", 1, "bar", "baz", "key")?.execute()
val requestUrl = response?.raw()?.request()?.url()
Assert.assertTrue(requestUrl!!.queryParameterNames().contains("days"))
Assert.assertEquals("1", requestUrl.queryParameter("days"))
assertTrue(requestUrl!!.queryParameterNames().contains("days"))
assertEquals("1", requestUrl.queryParameter("days"))
}

@Test
fun containsLatInQueryParams() {
val response = service?.extremes("foo", 1, "25.134", "baz", "key")?.execute()
val requestUrl = response?.raw()?.request()?.url()
Assert.assertTrue(requestUrl!!.queryParameterNames().contains("lat"))
Assert.assertEquals("25.134", requestUrl.queryParameter("lat"))
assertTrue(requestUrl!!.queryParameterNames().contains("lat"))
assertEquals("25.134", requestUrl.queryParameter("lat"))
}

@Test
fun containsLonInQueryParams() {
val response = service?.extremes("foo", 1, "bar", "13.948", "key")?.execute()
val requestUrl = response?.raw()?.request()?.url()
Assert.assertTrue(requestUrl!!.queryParameterNames().contains("lon"))
Assert.assertEquals("13.948", requestUrl.queryParameter("lon"))
assertTrue(requestUrl!!.queryParameterNames().contains("lon"))
assertEquals("13.948", requestUrl.queryParameter("lon"))
}

@Test
fun containsApiKeyInQueryParams() {
val response = service?.extremes("foo", 1, "bar", "baz", "someKey")?.execute()
val requestUrl = response?.raw()?.request()?.url()
Assert.assertTrue(requestUrl!!.queryParameterNames().contains("key"))
Assert.assertEquals("someKey", requestUrl.queryParameter("key"))
assertTrue(requestUrl!!.queryParameterNames().contains("key"))
assertEquals("someKey", requestUrl.queryParameter("key"))
}

@Test
fun parsesThreeTideExtremesFromMockJsonResponse() {
val response = service?.extremes("foo", 1, "bar", "baz", "key")?.execute()
Assert.assertTrue(response!!.isSuccessful)
Assert.assertEquals(3, response.body()?.extremes?.size)
assertTrue(response!!.isSuccessful)
assertEquals(3, response.body()?.extremes?.size)
}

@Test
fun parsesTideExtremeTypesFromMockJsonResponse() {
val response = service?.extremes("foo", 1, "bar", "baz", "key")?.execute()
Assert.assertTrue(response!!.isSuccessful)
Assert.assertEquals(
assertTrue(response!!.isSuccessful)
assertEquals(
listOf("High", "Low", "High"),
response.body()?.extremes?.map { extreme -> extreme.type })
}

@Test
fun parsesTideExtremeDatesFromMockJsonResponse() {
val response = service?.extremes("foo", 1, "bar", "baz", "key")?.execute()
Assert.assertTrue(response!!.isSuccessful)
Assert.assertEquals(listOf(
assertTrue(response!!.isSuccessful)
assertEquals(listOf(
"2021-02-17T05:37+0000",
"2021-02-17T11:49+0000",
"2021-02-17T17:58+0000"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import com.oleksandrkruk.worldtides.extremes.data.TideExtremesResponse
import com.oleksandrkruk.worldtides.extremes.models.TideType
import okhttp3.MediaType
import okhttp3.ResponseBody
import org.junit.Assert.assertEquals
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.mockito.ArgumentMatchers
Expand All @@ -20,7 +21,6 @@ import retrofit2.Callback
import retrofit2.Response
import java.text.SimpleDateFormat
import java.util.*
import kotlin.test.assertTrue
import kotlin.test.fail

@Suppress("UNCHECKED_CAST")
Expand All @@ -40,7 +40,7 @@ class WorldTidesRepositoryTest {

@BeforeEach
fun setup() {
MockitoAnnotations.initMocks(this)
MockitoAnnotations.openMocks(this)

`when`(dateFormatterMock.parse(ArgumentMatchers.any())).thenReturn(today)
tidesRepository = WorldTidesRepository(gatewayMock, dateFormatterMock)
Expand Down
Loading