+ return false;
+ }
+
+ private Set<Operation> findOperations(final List<Operation> operations, final String operationName) {
+ final Set<Operation> filteredOperations = new HashSet<>();
+ for (Operation operation : operations) {
+ if (operation.getMethod().equals(operationName)) {
+ filteredOperations.add(operation);
+ }
+ }
+ return filteredOperations;
+ }
+
+ private boolean containAllParameters(final List<Parameter> searchedIns, String[] searchedWhats) {
+ for (String searchedWhat : searchedWhats) {
+ boolean parameterFound = false;
+ for (Parameter searchedIn : searchedIns) {
+ if (searchedIn.getType().equals(searchedWhat)) {
+ parameterFound = true;
+ }
+ }
+ if (!parameterFound) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Tries to find {@code Api} with path {@code path}
+ */
+ private Api findApi(final String path, final ApiDeclaration doc) {
+ for (Api api : doc.getApis()) {
+ if (api.getPath().equals(path)) {
+ return api;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Validates whether doc {@code doc} contains concrete specified models.
+ */
+ private void validateSwaggerModules(ApiDeclaration doc) {
+ JSONObject models = doc.getModels();
+ assertNotNull(models);
+ try {
+ JSONObject configLst = models.getJSONObject("(config)lst");
+ assertNotNull(configLst);
+
+ containsReferences(configLst, "lst1");
+ containsReferences(configLst, "cont1");
+
+ JSONObject configLst1 = models.getJSONObject("(config)lst1");
+ assertNotNull(configLst1);
+
+ JSONObject configCont1 = models.getJSONObject("(config)cont1");
+ assertNotNull(configCont1);
+
+ containsReferences(configCont1, "cont11");
+ containsReferences(configCont1, "lst11");
+
+ JSONObject configCont11 = models.getJSONObject("(config)cont11");
+ assertNotNull(configCont11);
+
+ JSONObject configLst11 = models.getJSONObject("(config)lst11");
+ assertNotNull(configLst11);
+ } catch (JSONException e) {
+ fail("JSONException wasn't expected");
+ }
+
+ }
+
+ /**
+ * Checks whether object {@code mainObject} contains in properties/items key $ref with concrete value.
+ */
+ private void containsReferences(final JSONObject mainObject, final String childObject) throws JSONException {
+ JSONObject properties = mainObject.getJSONObject("properties");
+ assertNotNull(properties);
+
+ JSONObject nodeInProperties = properties.getJSONObject(childObject);
+ assertNotNull(nodeInProperties);
+
+ JSONObject itemsInNodeInProperties = nodeInProperties.getJSONObject("items");
+ assertNotNull(itemsInNodeInProperties);
+
+ String itemRef = itemsInNodeInProperties.getString("$ref");
+ assertEquals("(config)" + childObject, itemRef);