SmellPlugin implements Plugin { @Override public void define(final Context context) { context.addExtension(SmellChecksRegistrar.class); context.addExtension(SmellRulesDefinition.class); context.addExtension(SmellMetrics.class); context.addExtension(SmellMeasuresSensor.class); context.addExtension(SmellDebtComputer.class); context.addExtension(SmellCountByTypeMeasuresComputer.class); context.addExtension(SmellCountTotalMeasureComputer.class); if (!context.getSonarQubeVersion() .isGreaterThanOrEqual(NO_MORE_WIDGETS_VERSION)) { context.addExtension(SmellWidget.class); } }  @Override void define(final Context context);  }
@Test public void define_should_addExpectedExtensions_when_usingSQSmallerThan61() { Mockito.when(this.context.getSonarQubeVersion()) .thenReturn(STILL_WIDGETS_VERSION); final SmellPlugin sut = new SmellPlugin(); sut.define(this.context); verify(this.context).addExtension(Mockito.same(SmellChecksRegistrar.class)); verify(this.context).addExtension(Mockito.same(SmellRulesDefinition.class)); verify(this.context).addExtension(Mockito.same(SmellMetrics.class)); verify(this.context).addExtension(Mockito.same(SmellMeasuresSensor.class)); verify(this.context).addExtension(Mockito.same(SmellDebtComputer.class)); verify(this.context).addExtension(Mockito.same(SmellCountByTypeMeasuresComputer.class)); verify(this.context).addExtension(Mockito.same(SmellCountTotalMeasureComputer.class)); verify(this.context).addExtension(Mockito.same(SmellWidget.class)); verify(this.context).getSonarQubeVersion(); verifyNoMoreInteractions(this.context); }
@Test public void define_should_addExpectedExtensions_when_usingSQGreaterOrEqualTo61() { Mockito.when(this.context.getSonarQubeVersion()) .thenReturn(NO_MORE_WIDGETS_VERSION); final SmellPlugin sut = new SmellPlugin(); sut.define(this.context); verify(this.context).addExtension(Mockito.same(SmellChecksRegistrar.class)); verify(this.context).addExtension(Mockito.same(SmellRulesDefinition.class)); verify(this.context).addExtension(Mockito.same(SmellMetrics.class)); verify(this.context).addExtension(Mockito.same(SmellMeasuresSensor.class)); verify(this.context).addExtension(Mockito.same(SmellDebtComputer.class)); verify(this.context).addExtension(Mockito.same(SmellCountByTypeMeasuresComputer.class)); verify(this.context).addExtension(Mockito.same(SmellCountTotalMeasureComputer.class)); verify(this.context).getSonarQubeVersion(); verifyNoMoreInteractions(this.context); }