Skip to content
Snippets Groups Projects
Commit cdf84379 authored by Aalekh Jain's avatar Aalekh Jain
Browse files

Used helper function ValidateAppException in `LegalTagRepositoryImplTest.java`

parent fc40591b
No related branches found
No related tags found
1 merge request!61Improve code coverage
Pipeline #9827 failed
...@@ -73,8 +73,7 @@ public class LegalTagRepositoryImplTest { ...@@ -73,8 +73,7 @@ public class LegalTagRepositoryImplTest {
} catch (AppException e) { } catch (AppException e) {
int errorCode = 409; int errorCode = 409;
String errorMessage = "LegalTag already exists"; String errorMessage = "LegalTag already exists";
assertEquals(errorCode, e.getError().getCode()); validateAppException(e, errorCode, errorMessage);
assertThat(e.getError().getMessage(), containsString(errorMessage));
throw (e); throw (e);
} }
} }
...@@ -158,8 +157,7 @@ public class LegalTagRepositoryImplTest { ...@@ -158,8 +157,7 @@ public class LegalTagRepositoryImplTest {
} catch (AppException e) { } catch (AppException e) {
int errorCode = 404; int errorCode = 404;
String errorMessage = "Cannot update a LegalTag that does not exist"; String errorMessage = "Cannot update a LegalTag that does not exist";
assertEquals(errorCode, e.getError().getCode()); validateAppException(e, errorCode, errorMessage);
assertThat(e.getError().getMessage(), containsString(errorMessage));
throw (e); throw (e);
} }
} }
...@@ -214,4 +212,9 @@ public class LegalTagRepositoryImplTest { ...@@ -214,4 +212,9 @@ public class LegalTagRepositoryImplTest {
legalTag.setId(id); legalTag.setId(id);
return legalTag; return legalTag;
} }
private void validateAppException(AppException e, int errorCode, String errorMessage) {
assertEquals(errorCode, e.getError().getCode());
assertThat(e.getError().getMessage(), containsString(errorMessage));
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment