use of mockit.StrictExpectations in project swagger-parser by swagger-api.
the class ExternalRefProcessorTest method testProcessRefToExternalDefinition_NoNameConflict.
@Test
public void testProcessRefToExternalDefinition_NoNameConflict(@Injectable final Model mockedModel) throws Exception {
final String ref = "http://my.company.com/path/to/file.json#/foo/bar";
final RefFormat refFormat = RefFormat.URL;
new StrictExpectations() {
{
cache.getRenamedRef(ref);
times = 1;
result = null;
cache.loadRef(ref, refFormat, Model.class);
times = 1;
result = mockedModel;
swagger.getDefinitions();
times = 1;
result = null;
cache.putRenamedRef(ref, "bar");
swagger.addDefinition("bar", mockedModel);
times = 1;
cache.addReferencedKey("bar");
times = 1;
result = null;
}
};
String newRef = new ExternalRefProcessor(cache, swagger).processRefToExternalDefinition(ref, refFormat);
assertEquals(newRef, "bar");
}
use of mockit.StrictExpectations in project docker-maven-plugin by fabric8io.
the class DockerAccessWithHcClientTest method givenTheGetWillFail.
private void givenTheGetWillFail() throws IOException {
new StrictExpectations() {
{
mockDelegate.get(anyString, (ResponseHandler) any, 200);
result = new HttpResponseException(HTTP_INTERNAL_ERROR, "error");
}
};
}
use of mockit.StrictExpectations in project docker-maven-plugin by fabric8io.
the class DockerAccessWithHcClientTest method givenThePushWillFail.
@SuppressWarnings({ "rawtypes", "unchecked" })
private void givenThePushWillFail(final int retries, final boolean suceedAtEnd) throws IOException {
new StrictExpectations() {
{
int fail = retries + (suceedAtEnd ? 0 : 1);
mockDelegate.post(anyString, null, (Map<String, String>) any, (ResponseHandler) any, 200);
minTimes = fail;
maxTimes = fail;
result = new HttpResponseException(HTTP_INTERNAL_ERROR, "error");
mockDelegate.post(anyString, null, (Map<String, String>) any, (ResponseHandler) any, 200);
minTimes = suceedAtEnd ? 1 : 0;
maxTimes = suceedAtEnd ? 1 : 0;
}
};
}
use of mockit.StrictExpectations in project docker-maven-plugin by fabric8io.
the class DockerAccessWithHcClientTest method givenThePostWillFail.
private void givenThePostWillFail() throws IOException {
new StrictExpectations() {
{
mockDelegate.post(anyString, any, (ResponseHandler) any, 200);
result = new HttpResponseException(HTTP_INTERNAL_ERROR, "error");
}
};
}
use of mockit.StrictExpectations in project swagger-parser by swagger-api.
the class ResponseProcessorTest method testProcessResponse.
@Test
public void testProcessResponse(@Injectable final Model responseSchema, @Injectable final Property responseHeader) throws Exception {
new StrictExpectations() {
{
new ModelProcessor(cache, swagger);
times = 1;
result = modelProcessor;
modelProcessor.processModel(responseSchema);
times = 1;
}
};
Response response = new Response();
response.setResponseSchema(responseSchema);
response.addHeader("foo", responseHeader);
new ResponseProcessor(cache, swagger).processResponse(response);
new FullVerifications() {
{
}
};
}
Aggregations