* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@Mock(answer=Answers.RETURNS_DEEP_STUBS)
private RosettaDF<Object> errDF;
private ErrMessage errMessage;
private String attErrJson = "key:value";
@Mock(answer=Answers.RETURNS_DEEP_STUBS)
private RosettaDF<Object> errDF;
private ErrMessage errMessage;
private String attErrJson = "key:value";
error = new Error();
error.setMessageId("Error Message Id");
error.setText("Error Text");
errMessage = new ErrMessage(env);
error = new Error();
error.setMessageId("Error Message Id");
error.setText("Error Text");
errMessage = new ErrMessage(env);
errStream = new ByteArrayOutputStream();
}
@Test
public void testPrintErrMessage() throws APIException {
when(errDF.newData().in(TYPE.JSON).load(attErrJson).asObject()).thenReturn(error);
errStream = new ByteArrayOutputStream();
}
@Test
public void testPrintErrMessage() throws APIException {
when(errDF.newData().in(TYPE.JSON).load(attErrJson).asObject()).thenReturn(error);
errMessage.printErr(new PrintStream(errStream), attErrJson);
assertEquals("Error Message Id Error Text" + System.lineSeparator(), errStream.toString());
}
errMessage.printErr(new PrintStream(errStream), attErrJson);
assertEquals("Error Message Id Error Text" + System.lineSeparator(), errStream.toString());
}
@Test
public void testToMsgJsonErrAttribute() throws APIException {
when(errDF.newData().in(TYPE.JSON).load(attErrJson).asObject()).thenReturn(error);
@Test
public void testToMsgJsonErrAttribute() throws APIException {
when(errDF.newData().in(TYPE.JSON).load(attErrJson).asObject()).thenReturn(error);
StringBuilder sb = new StringBuilder();
errMessage.toMsg(sb,attErrJson);
StringBuilder sb = new StringBuilder();
errMessage.toMsg(sb,attErrJson);
@Test
public void testToMsgFutureWithoutException() throws APIException {
when(errDF.newData().in(TYPE.JSON).load(future.body()).asObject()).thenReturn(error);
@Test
public void testToMsgFutureWithoutException() throws APIException {
when(errDF.newData().in(TYPE.JSON).load(future.body()).asObject()).thenReturn(error);