### Question:
ObjectTypeHandler { public void assertObjectTypeNotExists(String name) throws InvalidArgumentException { if (objectManager.getObjectType(name) != null) { throw new InvalidArgumentException() .addValidationError(String.format("ObjectType with name = %s already exists.", name), "object.type.exist", "name", name); } } @Inject  ObjectTypeHandler(ObjectManager objectManager); void assertObjectTypeExists(String name, String property); void assertObjectTypeNotExists(String name);  }### Answer:
@Test public void testAssertObjectTypeNotExists() throws InvalidArgumentException { handler.assertObjectTypeNotExists("someObjectType"); verify(objectManager).getObjectType("someObjectType"); }
@Test public void testExistingObjectTypeThrowsException(){ when(objectManager.getObjectType("someObjectType")).thenReturn(new ObjectTypeEntity()); InvalidArgumentException ex = assertThrows(InvalidArgumentException.class, () -> handler.assertObjectTypeNotExists("someObjectType")); assertEquals(set("object.type.exist"), set(ex.getValidationErrors(), InvalidArgumentException.ValidationError::getMessageTemplate)); }