APILoader { public Map<String, Buildable> getBuildableMap() { Map<String, Buildable> buildables = new HashMap<>(); for (EndpointPOJO pojo : pojos) { try { String completeUrl; if (pojo.getHttpMethod() == null) { throw new UnsupportedOperationException("HttpMethod cannot be null"); } completeUrl = ApiHelper.getUrlWithHttpMethod(pojo.getUrl(), pojo.getHttpMethod().toString()); if (buildables.containsKey(completeUrl)) { logger.error("******* More than one Buildable defined for api: \"" + pojo.getUrl()+"\", all except first occurrences will be ignored. *******"); } else { APIBuildable apiBuildable = new APIBuildable(legoSet, pojo, configuration, getCalls(pojo.getTasks())); buildables.put(completeUrl, apiBuildable); } } catch (Throwable error) { logger.error("Buildable loading failed for api: " + pojo.getUrl(), error); } } return buildables; } APILoader(PoseidonLegoSet legoSet, String config, Configuration configuration); Map<String, Buildable> getBuildableMap();  }
@Test public void testGetBuildableMap() throws Exception { APILoader loader = new APILoader(legoSet, configs, configuration); Map<String, Buildable> buildableMap = loader.getBuildableMap(); assertEquals(2, buildableMap.size()); }
@Test public void testGetBuildableMapCompeteUrl() throws Exception { APILoader loader = new APILoader(legoSet, configs, configuration); Map<String, Buildable> buildableMap = loader.getBuildableMap(); String url = "/home/test"; String method = "POST"; String completeUrl = ApiHelper.getUrlWithHttpMethod(url, method.toString()); assertEquals(2, buildableMap.size()); assertNotNull(buildableMap.get(completeUrl)); assertTrue(buildableMap.get(completeUrl) instanceof APIBuildable); APIBuildable apiBuildable = (APIBuildable) buildableMap.get(completeUrl); assertEquals(url, apiBuildable.getPojo().getUrl()); }
@Test public void testGetBuildableMapCompeteUrlWithMissingSlash() throws Exception { APILoader loader = new APILoader(legoSet, configs, configuration); Map<String, Buildable> buildableMap = loader.getBuildableMap(); String url = "/shop/test"; String method = "POST"; String completeUrl = ApiHelper.getUrlWithHttpMethod(url, method.toString()); assertEquals(2, buildableMap.size()); assertNotNull(buildableMap.get(completeUrl)); assertTrue(buildableMap.get(completeUrl) instanceof APIBuildable); APIBuildable apiBuildable = (APIBuildable) buildableMap.get(completeUrl); assertEquals(url, apiBuildable.getPojo().getUrl()); }