Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADDED] New common module for data model used across different modules #153

Merged
merged 8 commits into from
Jan 14, 2025

Conversation

hossain-khan
Copy link
Owner

@hossain-khan hossain-khan commented Jan 14, 2025

This pull request includes several changes to the app module, focusing on database schema updates, data model adjustments, and refactoring of the WeatherRepository interface and implementation. The key changes are summarized below:

Database Schema Updates:

  • Added a new database schema version 4.json which includes the creation of tables cities, alerts, and city_forecasts with their respective fields, indices, and foreign keys.

Dependency and Import Updates:

  • Added implementation(project(":data-model")) to the dependencies block in app/build.gradle.kts.
  • Updated imports in Models.kt and WeatherRepository.kt to use classes from the datamodel package. [1] [2] [3]

Data Model Adjustments:

  • Changed alertId type from Int to Long in AlertTileData and cityId type from Int to Long in WeatherRepository and related classes. [1] [2] [3]
  • Removed WeatherAlertCategory enum and ForecastData data classes from Models.kt, replacing them with AppForecastData from the datamodel package. [1] [2]

Weather Repository Refactoring:

  • Updated WeatherRepository interface and WeatherRepositoryImpl class to use AppForecastData instead of ForecastData. This includes changing method signatures and updating the implementation to handle the new data model. [1] [2] [3] [4] [5] [6] [7]

Code Cleanup:

  • Removed unused constants and outdated methods from Models.kt and WeatherRepository.kt. [1] [2]

@hossain-khan hossain-khan self-assigned this Jan 14, 2025
@Copilot Copilot bot review requested due to automatic review settings January 14, 2025 12:01

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 1 out of 8 changed files in this pull request and generated no comments.

Files not reviewed (7)
  • data-model/.gitignore: Language not supported
  • data-model/build.gradle.kts: Language not supported
  • data-model/proguard-rules.pro: Language not supported
  • data-model/src/androidTest/java/dev/hossain/weatheralert/datamodel/ExampleInstrumentedTest.kt: Language not supported
  • data-model/src/main/AndroidManifest.xml: Language not supported
  • data-model/src/test/java/dev/hossain/weatheralert/datamodel/ExampleUnitTest.kt: Language not supported
  • settings.gradle.kts: Language not supported
```
> Task :service:openweather:testDebugUnitTest

OpenWeatherServiceTest > given weather forecast response for oshawa city - parses data FAILED
    java.net.BindException: Address already in use
        at java.base/sun.nio.ch.Net.bind0(Native Method)
        at java.base/sun.nio.ch.Net.bind(Net.java:555)
        at java.base/sun.nio.ch.Net.bind(Net.java:544)
        at java.base/sun.nio.ch.NioSocketImpl.bind(NioSocketImpl.java:648)
        at java.base/java.net.ServerSocket.bind(ServerSocket.java:388)
        at okhttp3.mockwebserver.MockWebServer.start(MockWebServer.kt:390)
        at okhttp3.mockwebserver.MockWebServer.start(MockWebServer.kt:372)
        at okhttp3.mockwebserver.MockWebServer.start(MockWebServer.kt:362)
        at org.openweathermap.api.OpenWeatherServiceTest.setUp(OpenWeatherServiceTest.kt:28)
```

### Error Analysis:
The error in the GitHub Actions logs shows that two tests are failing in `OpenWeatherServiceTest` due to a `java.net.BindException: Address already in use`.

### Relevant Code:
The `setUp` method in `OpenWeatherServiceTest` initializes a `MockWebServer` and starts it on port 60000:
```kotlin
@before
fun setUp() {
    mockWebServer = MockWebServer()
    mockWebServer.start(60000)
}
```

### Suggested Fix:
The `java.net.BindException` occurs because the port 60000 is already in use. To fix this, you can start `MockWebServer` on a random available port by calling `mockWebServer.start()` without specifying a port.

#### Updated `setUp` Method:
```kotlin
@before
fun setUp() {
    mockWebServer = MockWebServer()
    mockWebServer.start() // Start on a random available port
}
```

### Next Steps:
1. Update the `setUp` method in `OpenWeatherServiceTest`.
2. Commit the changes.
3. Re-run the GitHub Actions workflow to verify the fix.
@hossain-khan hossain-khan merged commit 5e52637 into main Jan 14, 2025
3 checks passed
@hossain-khan hossain-khan deleted the isolate-weather-service branch January 14, 2025 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant