Search in sources :

Example 1 with ErrorCode

use of gov.cms.qpp.conversion.model.error.ErrorCode in project qpp-conversion-tool by CMSgov.

the class ErrorCodeDocumentationGenerator method main.

public static void main(String... args) throws IOException {
    MustacheFactory mf = new DefaultMustacheFactory();
    Mustache mdTemplate = mf.compile("error-code/error-code-tempate.md");
    try (FileWriter fw = new FileWriter("./ERROR_MESSAGES.md")) {
        List<ErrorCode> errorCodes = Arrays.asList(ErrorCode.values());
        mdTemplate.execute(fw, errorCodes).flush();
        fw.flush();
    }
}
Also used : DefaultMustacheFactory(com.github.mustachejava.DefaultMustacheFactory) FileWriter(java.io.FileWriter) Mustache(com.github.mustachejava.Mustache) ErrorCode(gov.cms.qpp.conversion.model.error.ErrorCode) DefaultMustacheFactory(com.github.mustachejava.DefaultMustacheFactory) MustacheFactory(com.github.mustachejava.MustacheFactory)

Example 2 with ErrorCode

use of gov.cms.qpp.conversion.model.error.ErrorCode in project qpp-conversion-tool by CMSgov.

the class ErrorCodeTest method testGetMessagePrependsConversionToolLabel.

@Test
void testGetMessagePrependsConversionToolLabel() {
    ErrorCode code = ErrorCode.NUMERATOR_DENOMINATOR_INVALID_VALUE;
    Truth.assertThat(code.getMessage()).startsWith(ErrorCode.CT_LABEL);
}
Also used : ErrorCode(gov.cms.qpp.conversion.model.error.ErrorCode) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 3 with ErrorCode

use of gov.cms.qpp.conversion.model.error.ErrorCode in project qpp-conversion-tool by CMSgov.

the class ErrorCodeTest method testFormatOnFormattedErrorCode.

@Test
void testFormatOnFormattedErrorCode() {
    ErrorCode code = ErrorCode.NUMERATOR_DENOMINATOR_INVALID_VALUE;
    Truth.assertThat(code.format("mock").getMessage()).isEqualTo(code.getMessage().replace("`(Numerator or Denominator)`", "mock"));
}
Also used : ErrorCode(gov.cms.qpp.conversion.model.error.ErrorCode) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 4 with ErrorCode

use of gov.cms.qpp.conversion.model.error.ErrorCode in project qpp-conversion-tool by CMSgov.

the class FixtureErrorData method getMessage.

/**
 * Get or generate an {@link ErrorCode}'s message.
 *
 * @return generated error message
 */
public String getMessage() {
    if (message == null) {
        ErrorCode ec = ErrorCode.getByCode(errorCode);
        message = (subs != null) ? ec.format(subs.toArray()).getMessage() : ec.getMessage();
    }
    return message;
}
Also used : ErrorCode(gov.cms.qpp.conversion.model.error.ErrorCode)

Aggregations

ErrorCode (gov.cms.qpp.conversion.model.error.ErrorCode)4 Test (org.junit.jupiter.api.Test)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 DefaultMustacheFactory (com.github.mustachejava.DefaultMustacheFactory)1 Mustache (com.github.mustachejava.Mustache)1 MustacheFactory (com.github.mustachejava.MustacheFactory)1 FileWriter (java.io.FileWriter)1