import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
responseEntity.getStatusCode());
// Make sure that there are no two result <result><result>
- assertThat(responseEntity.getBody().toString(),
+ assertThat(responseEntity.getBody(),
is(not(containsString("<result><result>"))));
- assertThat(responseEntity.getBody().toString(), is(containsString("<results><result>")));
+ assertThat(responseEntity.getBody(), is(containsString("<results><result>")));
+ }
+
+ @Test
+ public void thatWildcardContentTypeCanBeUsed() throws Exception {
+
+ String endpoint = "/aai/v14/dsl?format=console";
+ Map<String, String> dslQueryMap = new HashMap<>();
+ dslQueryMap.put("dsl-query", "pserver*('hostname','test-pserver-dsl')");
+ String payload = PayloadUtil.getTemplatePayload("dsl-query.json", dslQueryMap);
+ headers.add("X-Dsl-Version", "V1");
+ headers.setAccept(Arrays.asList(MediaType.ALL));
+ httpEntity = new HttpEntity<String>(payload, headers);
+ ResponseEntity<String> responseEntity =
+ restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class);
+
+ JsonObject result = JsonParser.parseString(responseEntity.getBody()).getAsJsonObject();
+ assertEquals(1, result.get("results").getAsJsonArray().size());
}
@Test
responseEntity.getStatusCode());
// Make sure that there are no two result <result><result>
- assertThat(responseEntity.getBody().toString(),
+ assertThat(responseEntity.getBody(),
is(not(containsString("<result><result>"))));
- assertThat(responseEntity.getBody().toString(), is(containsString("<results><result>")));
+ assertThat(responseEntity.getBody(), is(containsString("<results><result>")));
}
@Test
httpEntity = new HttpEntity<String>(payload, headers);
ResponseEntity<String> responseEntity =
restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class);
- String responseString = responseEntity.getBody().toString();
+ String responseString = responseEntity.getBody();
// Extract the properties array from the response and compare in assert statements
JsonObject results = JsonParser.parseString(responseString).getAsJsonObject();
ResponseEntity<String> responseEntity =
restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class);
- String responseString = responseEntity.getBody().toString();
+ String responseString = responseEntity.getBody();
// Extract the properties array from the response and compare in assert statements
JsonObject results = JsonParser.parseString(responseString).getAsJsonObject();
httpEntity = new HttpEntity<String>(payload, headers);
ResponseEntity<String> responseEntity =
restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class);
- String responseString = responseEntity.getBody().toString();
+ String responseString = responseEntity.getBody();
// Extract the properties array from the response and compare in assert statements
JsonObject results = JsonParser.parseString(responseString).getAsJsonObject();
httpEntity = new HttpEntity<String>(payload, headers);
ResponseEntity<String> responseEntity =
restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class);
- String responseString = responseEntity.getBody().toString();
+ String responseString = responseEntity.getBody();
// Extract the properties array from the response and compare in assert statements
JsonObject results = JsonParser.parseString(responseString).getAsJsonObject();
httpEntity = new HttpEntity<String>(payload, headers);
ResponseEntity<String> responseEntity =
restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class);
- String responseString = responseEntity.getBody().toString();
+ String responseString = responseEntity.getBody();
// Extract the properties array from the response and compare in assert statements
JsonObject results = JsonParser.parseString(responseString).getAsJsonObject();
httpEntity = new HttpEntity<String>(payload, headers);
ResponseEntity<String> responseEntity =
restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class);
- String responseString = responseEntity.getBody().toString();
+ String responseString = responseEntity.getBody();
// Extract the properties array from the response and compare in assert statements
JsonObject results = JsonParser.parseString(responseString).getAsJsonObject();
httpEntity = new HttpEntity<String>(payload, headers);
ResponseEntity<String> responseEntity =
restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class);
- String responseString = responseEntity.getBody().toString();
+ String responseString = responseEntity.getBody();
// Extract the properties array from the response and compare in assert statements
JsonObject results = JsonParser.parseString(responseString).getAsJsonObject();
JsonArray resultsArray = results.get("results").getAsJsonArray();
httpEntity = new HttpEntity<String>(payload, headers);
ResponseEntity<String> responseEntity =
restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class);
- String responseString = responseEntity.getBody().toString();
+ String responseString = responseEntity.getBody();
// Extract the properties array from the response and compare in assert statements
JsonObject results = JsonParser.parseString(responseString).getAsJsonObject();
JsonArray resultsArray = results.get("results").getAsJsonArray();
httpEntity = new HttpEntity<String>(payload, headers);
ResponseEntity<String> responseEntity =
restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class);
- String responseString = responseEntity.getBody().toString();
+ String responseString = responseEntity.getBody();
// Extract the properties array from the response and compare in assert statements
JsonObject results = JsonParser.parseString(responseString).getAsJsonObject();
JsonArray resultsArray = results.get("results").getAsJsonArray();
httpEntity = new HttpEntity<String>(payload, headers);
ResponseEntity<String> responseEntity =
restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class);
- String responseString = responseEntity.getBody().toString();
+ String responseString = responseEntity.getBody();
// Extract the properties array from the response and compare in assert statements
JsonObject results = JsonParser.parseString(responseString).getAsJsonObject();
JsonArray resultsArray = results.get("results").getAsJsonArray();
httpEntity = new HttpEntity<String>(payload, headers);
ResponseEntity<String> responseEntity =
restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class);
- String responseString = responseEntity.getBody().toString();
+ String responseString = responseEntity.getBody();
// Extract the properties array from the response and compare in assert statements
JsonObject results = JsonParser.parseString(responseString).getAsJsonObject();
JsonArray resultsArray = results.get("results").getAsJsonArray();
httpEntity = new HttpEntity<String>(payload, headers);
ResponseEntity<String> responseEntity =
restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class);
- String responseString = responseEntity.getBody().toString();
+ String responseString = responseEntity.getBody();
Assert.assertTrue(responseString.contains(
"Value ['test'] is not an instance of the expected data type for property key ['number-of-cpus'] and cannot be converted. "
+ "Expected: class java.lang.Integer, found: class java.lang.String"));
httpEntity = new HttpEntity<String>(payload, headers);
ResponseEntity<String> responseEntity =
restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class);
- String responseString = responseEntity.getBody().toString();
+ String responseString = responseEntity.getBody();
// Extract the properties array from the response and compare in assert statements
JsonObject results = JsonParser.parseString(responseString).getAsJsonObject();
httpEntity = new HttpEntity<String>(payload, headers);
ResponseEntity<String> responseEntity =
restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class);
- String responseString = responseEntity.getBody().toString();
+ String responseString = responseEntity.getBody();
// Extract the properties array from the response and compare in assert statements
JsonObject results = JsonParser.parseString(responseString).getAsJsonObject();
httpEntity = new HttpEntity<String>(payload, headers);
ResponseEntity<String> responseEntity =
restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class);
- String responseString = responseEntity.getBody().toString(); // pnf should have no results
+ String responseString = responseEntity.getBody(); // pnf should have no results
JsonObject results = JsonParser.parseString(responseString).getAsJsonObject();
JsonArray resultsArray = results.get("results").getAsJsonArray();
httpEntity = new HttpEntity<String>(payload, headers);
ResponseEntity<String> responseEntity =
restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class);
- String responseString = responseEntity.getBody().toString();
+ String responseString = responseEntity.getBody();
JsonObject results = JsonParser.parseString(responseString).getAsJsonObject();
JsonArray resultsArray = results.get("results").getAsJsonArray();
httpEntity = new HttpEntity<String>(payload, headers);
ResponseEntity<String> responseEntity =
restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class);
- String responseString = responseEntity.getBody().toString();
+ String responseString = responseEntity.getBody();
// Confirm that the vserver was returned in the response
Assert.assertTrue(responseString.contains("\"vserver-id\":\"test-vserver-id-2\""));
httpEntity = new HttpEntity<String>(payload, headers);
responseEntity =
restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class);
- responseString = responseEntity.getBody().toString();
+ responseString = responseEntity.getBody();
// Confirm that the vserver was returned in the response
Assert.assertTrue(responseString.contains("\"vserver-id\":\"test-vserver-id-2\""));
}
httpEntity = new HttpEntity<String>(payload, headers);
ResponseEntity<String> responseEntity =
restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class);
- String responseString = responseEntity.getBody().toString();
+ String responseString = responseEntity.getBody();
// Confirm that the l-interface was returned in the response
Assert.assertTrue(responseString.contains("\"interface-name\":\"test-interface-name-02\""));
}
httpEntity = new HttpEntity<String>(payload, headers);
ResponseEntity<String> responseEntity =
restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class);
- String responseString = responseEntity.getBody().toString();
+ String responseString = responseEntity.getBody();
// Confirm that the l-interface was returned in the response
Assert.assertTrue(responseString.contains("\"interface-name\":\"test-interface-name-02\""));
}
httpEntity = new HttpEntity<String>(payload, headers);
ResponseEntity<String> responseEntity =
restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class);
- String responseString = responseEntity.getBody().toString();
+ String responseString = responseEntity.getBody();
// Confirm that the l-interface was returned in the response
Assert
.assertTrue(!responseString.contains("\"interface-name\":\"test-interface-name-02\""));
httpEntity = new HttpEntity<String>(payload, headers);
ResponseEntity<String> responseEntity =
restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class);
- String responseString = responseEntity.getBody().toString();
+ String responseString = responseEntity.getBody();
// Confirm that the l-interface was returned in the response
Assert
.assertTrue(!responseString.contains("\"interface-name\":\"test-interface-name-02\""));
httpEntity = new HttpEntity<String>(payload, headers);
ResponseEntity<String> responseEntity =
restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class);
- String responseString = responseEntity.getBody().toString();
+ String responseString = responseEntity.getBody();
// Confirm that the l-interface was returned in the response
Assert
.assertTrue(!responseString.contains("\"interface-name\":\"test-interface-name-02\""));
httpEntity = new HttpEntity<String>(payload, headers);
ResponseEntity<String> responseEntity =
restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class);
- String responseString = responseEntity.getBody().toString();
+ String responseString = responseEntity.getBody();
// Confirm that the l-interface was returned in the response
Assert.assertTrue(responseString.contains("\"interface-name\":\"test-interface-name-02\""));
httpEntity = new HttpEntity<String>(payload, headers);
responseEntity =
restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class);
- responseString = responseEntity.getBody().toString();
+ responseString = responseEntity.getBody();
// Confirm that the l-interface was returned in the response
Assert.assertTrue(responseString.contains("\"interface-name\":\"test-interface-name-02\""));
httpEntity = new HttpEntity<String>(payload, headers);
ResponseEntity<String> responseEntity =
restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class);
- String responseString = responseEntity.getBody().toString();
+ String responseString = responseEntity.getBody();
// Confirm that the oam-network was returned in the response
Assert.assertTrue(responseString.contains("\"cvlan-tag\":456"));
httpEntity = new HttpEntity<String>(payload, headers);
responseEntity =
restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class);
- responseString = responseEntity.getBody().toString();
+ responseString = responseEntity.getBody();
// Confirm that the oam-network was returned in the response
Assert.assertTrue(responseString.contains("\"cvlan-tag\":456"));
httpEntity = new HttpEntity<String>(payload, headers);
ResponseEntity<String> responseEntity =
restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class);
- String responseString = responseEntity.getBody().toString();
+ String responseString = responseEntity.getBody();
// Confirm that the pserver was returned in the response
Assert.assertTrue(responseString.contains("\"number-of-cpus\":364"));
httpEntity = new HttpEntity<String>(payload, headers);
responseEntity =
restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class);
- responseString = responseEntity.getBody().toString();
+ responseString = responseEntity.getBody();
// Confirm that the pserver was returned in the response
Assert.assertTrue(responseString.contains("\"number-of-cpus\":364"));