spotify / heroic

The Heroic Time Series Database
https://spotify.github.io/heroic/
Apache License 2.0
848 stars 109 forks source link

In affected IT.java's, replace inheritance flags with polymorphism #687

Open sming opened 4 years ago

sming commented 4 years ago

or in more mechanical terms:

replace:

flags in IT.java base classes like protected boolean subclassHasFeatureX = true; + tests for that flag in the base class e.g. assumeTrue("Test huge row key write", hugeRowKey) + setting of said flag in concrete subclasses e.g. this.subclassHasFeatureX = false;

with:

  1. remove the flag
  2. keep the test in the base class but move the body of the test to a virtual method e.g.
    
    @Test
    public void FeatureXTest() {
    FeatureXTestImpl();
    }

public void FeatureXTestImpl() { // test guts }

1. in subclasses that ***do not*** support FeatureX, override `FeatureTestImpl` to be a no-op:
```java
@Override
public void FeatureXTestImpl() { /* no-op */ }

et voila

no more flags or run time exceptions if the developer forgets that the subclass doesn't support feature X.

See the original comment here.