@Test public void getToken() { ExternalService service=new ExternalService(); String token=service.getToken(); System.out.println("Token is: "+token); }
public String getToken(){ String token=""; ObjectMapper objectMapper=new ObjectMapper(); try{ File file=new ClassPathResource("env.json").getFile(); if(!file.exists()){ System.out.println("Invalid Access Token Provided... Copy the content of env.example.json to env.json and update the access token"); return "An error occurred with the Access Token Provided"; } Map<String,Object> dataMap=objectMapper.readValue(file,HashMap.class); token=(String)dataMap.get("token"); } catch (Exception ex){ ex.printStackTrace(); } return token; }
ExternalService { public String getToken(){ String token=""; ObjectMapper objectMapper=new ObjectMapper(); try{ File file=new ClassPathResource("env.json").getFile(); if(!file.exists()){ System.out.println("Invalid Access Token Provided... Copy the content of env.example.json to env.json and update the access token"); return "An error occurred with the Access Token Provided"; } Map<String,Object> dataMap=objectMapper.readValue(file,HashMap.class); token=(String)dataMap.get("token"); } catch (Exception ex){ ex.printStackTrace(); } return token; } }
ExternalService { public String getToken(){ String token=""; ObjectMapper objectMapper=new ObjectMapper(); try{ File file=new ClassPathResource("env.json").getFile(); if(!file.exists()){ System.out.println("Invalid Access Token Provided... Copy the content of env.example.json to env.json and update the access token"); return "An error occurred with the Access Token Provided"; } Map<String,Object> dataMap=objectMapper.readValue(file,HashMap.class); token=(String)dataMap.get("token"); } catch (Exception ex){ ex.printStackTrace(); } return token; }  }
ExternalService { public String getToken(){ String token=""; ObjectMapper objectMapper=new ObjectMapper(); try{ File file=new ClassPathResource("env.json").getFile(); if(!file.exists()){ System.out.println("Invalid Access Token Provided... Copy the content of env.example.json to env.json and update the access token"); return "An error occurred with the Access Token Provided"; } Map<String,Object> dataMap=objectMapper.readValue(file,HashMap.class); token=(String)dataMap.get("token"); } catch (Exception ex){ ex.printStackTrace(); } return token; }  String sendGetRequest(String url); String sendPostRequest(String body); String getToken(); String getLeagueStanding(int leagueID); String getLeagueFixture(int leagueID, int matchDay); }
ExternalService { public String getToken(){ String token=""; ObjectMapper objectMapper=new ObjectMapper(); try{ File file=new ClassPathResource("env.json").getFile(); if(!file.exists()){ System.out.println("Invalid Access Token Provided... Copy the content of env.example.json to env.json and update the access token"); return "An error occurred with the Access Token Provided"; } Map<String,Object> dataMap=objectMapper.readValue(file,HashMap.class); token=(String)dataMap.get("token"); } catch (Exception ex){ ex.printStackTrace(); } return token; }  String sendGetRequest(String url); String sendPostRequest(String body); String getToken(); String getLeagueStanding(int leagueID); String getLeagueFixture(int leagueID, int matchDay);  }