public AtomicIntegerArrayAssert(AtomicIntegerArray actual) { super(actual, AtomicIntegerArrayAssert.class); array = array(actual); }
public ProxyableObjectArrayAssert(AtomicReferenceArray<ELEMENT> actual) { this(array(actual)); }
public AtomicReferenceArrayAssert(AtomicReferenceArray<T> actual) { super(actual, AtomicReferenceArrayAssert.class); array = array(actual); }
public AtomicLongArrayAssert(AtomicLongArray actual) { super(actual, AtomicLongArrayAssert.class); array = array(actual); }
public ObjectArrayAssert(AtomicReferenceArray<ELEMENT> actual) { this(array(actual)); }
public IntArrayAssert(AtomicIntegerArray actual) { this(array(actual)); }
public LongArrayAssert(AtomicLongArray actual) { this(array(actual)); }
private static <ASSERTION> ASSERTION asAssumption(Class<ASSERTION> assertionType, Class<?>[] constructorTypes, Object... constructorParams) { try { Class<? extends ASSERTION> type = createAssumptionClass(assertionType); Constructor<? extends ASSERTION> constructor = type.getConstructor(constructorTypes); return constructor.newInstance(constructorParams); } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException e) { throw new RuntimeException(e); } }
private static AbstractAssert<?, ?> asIterableSizeAssumption(AbstractAssert<?, ?> assertion) { IterableSizeAssert<?> iterableSizeAssert = (IterableSizeAssert<?>) assertion; Class<?>[] constructorTypes = array(AbstractIterableAssert.class, Integer.class); return asAssumption(IterableSizeAssert.class, constructorTypes, iterableSizeAssert.returnToIterable(), assertion.actual); } }
private static AbstractAssert<?, ?> asMapSizeAssumption(AbstractAssert<?, ?> assertion) { MapSizeAssert<?, ?> mapSizeAssert = (MapSizeAssert<?, ?>) assertion; Class<?>[] constructorTypes = array(AbstractMapAssert.class, Integer.class); return asAssumption(MapSizeAssert.class, constructorTypes, mapSizeAssert.returnToMap(), assertion.actual); }
private Object[] msgArgs(String description) { return array(description, representation.toStringOf(expected), representation.toStringOf(actual)); }
@Test public void fail_with_ISE_when_two_measure_computers_generate_the_same_output_metric() { thrown.expect(IllegalStateException.class); thrown.expectMessage("Output metric 'metric1' is already defined by another measure computer 'TestMeasureComputer'"); MeasureComputer[] computers = new MeasureComputer[] {newMeasureComputer(array(NCLOC_KEY), array(NEW_METRIC_1)), newMeasureComputer(array(CLASSES_KEY), array(NEW_METRIC_1))}; ComputationStep underTest = new LoadMeasureComputersStep(holder, array(new TestMetrics()), computers); underTest.execute(new TestComputationStepContext()); }
@Test public void support_core_metrics_as_input_metrics() { MeasureComputer[] computers = new MeasureComputer[] {newMeasureComputer(array(NCLOC_KEY), array(NEW_METRIC_1))}; ComputationStep underTest = new LoadMeasureComputersStep(holder, array(new TestMetrics()), computers); underTest.execute(new TestComputationStepContext()); assertThat(holder.getMeasureComputers()).hasSize(1); }
@Test public void support_plugin_metrics_as_input_metrics() { MeasureComputer[] computers = new MeasureComputer[] {newMeasureComputer(array(NEW_METRIC_1), array(NEW_METRIC_2))}; ComputationStep underTest = new LoadMeasureComputersStep(holder, array(new TestMetrics()), computers); underTest.execute(new TestComputationStepContext()); assertThat(holder.getMeasureComputers()).hasSize(1); }
@Test public void not_fail_if_input_metrics_are_same_as_output_metrics() { MeasureComputer[] computers = new MeasureComputer[] {newMeasureComputer(array(NEW_METRIC_1), array(NEW_METRIC_1))}; ComputationStep underTest = new LoadMeasureComputersStep(holder, array(new TestMetrics()), computers); underTest.execute(new TestComputationStepContext()); assertThat(holder.getMeasureComputers()).hasSize(1); }
@Test public void fail_with_ISE_when_output_metric_is_not_define_by_plugin() { thrown.expect(IllegalStateException.class); thrown.expectMessage("Metric 'unknown' cannot be used as an output metric because no plugins declare this metric"); MeasureComputer[] computers = new MeasureComputer[] {newMeasureComputer(array(NEW_METRIC_4), array("unknown"))}; ComputationStep underTest = new LoadMeasureComputersStep(holder, array(new TestMetrics()), computers); underTest.execute(new TestComputationStepContext()); }
@Test public void fail_with_ISE_when_input_metric_is_unknown() { thrown.expect(IllegalStateException.class); thrown.expectMessage("Metric 'unknown' cannot be used as an input metric as it's not a core metric and no plugin declare this metric"); MeasureComputer[] computers = new MeasureComputer[] {newMeasureComputer(array("unknown"), array(NEW_METRIC_4))}; ComputationStep underTest = new LoadMeasureComputersStep(holder, array(new TestMetrics()), computers); underTest.execute(new TestComputationStepContext()); }
@Test public void fail_with_ISE_when_output_metric_is_a_core_metric() { thrown.expect(IllegalStateException.class); thrown.expectMessage("Metric 'ncloc' cannot be used as an output metric because it's a core metric"); MeasureComputer[] computers = new MeasureComputer[] {newMeasureComputer(array(NEW_METRIC_4), array(NCLOC_KEY))}; ComputationStep underTest = new LoadMeasureComputersStep(holder, array(new TestMetrics()), computers); underTest.execute(new TestComputationStepContext()); }
@Test public void fail_with_ISE_when_no_metrics_are_defined_by_plugin_but_measure_computer_use_a_new_metric() { thrown.expect(IllegalStateException.class); thrown.expectMessage("Metric 'metric1' cannot be used as an output metric because no plugins declare this metric"); MeasureComputer[] computers = new MeasureComputer[] {newMeasureComputer(array(NCLOC_KEY), array(NEW_METRIC_1))}; ComputationStep underTest = new LoadMeasureComputersStep(holder, computers); underTest.execute(new TestComputationStepContext()); }
@Test public void return_empty_list_when_no_measure_computers() { ComputationStep underTest = new LoadMeasureComputersStep(holder, array(new TestMetrics())); underTest.execute(new TestComputationStepContext()); assertThat(holder.getMeasureComputers()).isEmpty(); }