This project provides a command-line utility for fetching geolocation data (latitude and longitude) for cities, states, and ZIP codes using the OpenWeatherMap API. The utility can handle multiple location inputs and return relevant information, including latitude, longitude, and place name. Integration tests are provided using WireMock to mock API responses.
SDET/
├── src/
│ ├── main/
│ │ ├── java/
│ │ │ ├── com/
│ │ │ │ ├── geoloc/
│ │ │ │ │ ├── GeolocationUtil.java # Main CLI Utility
│ │ │ │ │ ├── OpenWeatherApiClient.java # API Client
│ │ │ │ │ ├── LocationData.java # Data Model for Location
│ │ │ │ │ ├── Config.java # API Key Handling
│ ├── test/
│ │ ├── java/
│ │ │ ├── com/
│ │ │ │ ├── geoloc/
│ │ │ │ │ ├── GeolocationUtilTest.java # Integration Tests
├── pom.xml # Maven Build File
├── README.md # Documentation
├── .gitignore # Ignore API keys, build files
- JDK 11 or higher: Ensure you have Java 11 or higher installed.
- Maven: The project uses Maven for build and dependency management.
-
Clone the Repository:
git clone https://github.com/niyatisharma82/SDET.git cd SDET -
Set Up API Key:
-
Obtain an API key from OpenWeatherMap by signing up at OpenWeatherMap.
-
Set the
OPENWEATHER_API_KEYenvironment variable with your API key:For Linux/macOS:
export OPENWEATHER_API_KEY=your_api_key_hereFor Windows (Command Prompt):
set OPENWEATHER_API_KEY=your_api_key_here
-
To run the utility from the command line, use the following command:
mvn clean test
java -jar target/geoloc-util-1.0.jar "City, State" "ZIP"