@Test @Parameters(method = "classGenericDefinitionSuccess") public void testClassGenericDefinitionSuccess(Class<?> type) { testXKindGenericDefinitionSuccess(type); }
private Object[] getProfileWithSerializer() { return $(new Object[] {getDefaultSerializerCreationProfile(), "HeterogeneousLuceneSerializer"}, new Object[] {getDummySerializerCreationProfile(), "DummyLuceneSerializer"}, new Object[] { getHeterogeneousLuceneSerializerCreationProfile(), "HeterogeneousLuceneSerializer"}); }
@Test @Parameters(method = "methodGenericDefinitionSuccess") public void testMethodGenericDefinitionSuccess(Class<?> type) { testXKindGenericDefinitionSuccess(type); }
private Object[] getSerializationProfiles() { return $(new Object[] {getOneFieldLuceneIndexCreationProfile()}, new Object[] {getTwoFieldLuceneIndexCreationProfile()}, new Object[] {getTwoAnalyzersLuceneIndexCreationProfile()}, new Object[] {getDummySerializerCreationProfile()}, new Object[] {getNullField1AnalyzerLuceneIndexCreationProfile()}); }
@Test(expected = FallbackDefinitionException.class) @Parameters(method = "methodGenericDefinitionFailure") public void testMethodGenericDefinitionFailure(Class<?> type) { Object p = createProxy(type); executeCommand(p); }
protected Object[] getXmlAndExpectedElements() { return $( new Object[] {getDuplicateReceiversWithDefaultPropertiesXml(), 2, 1}, new Object[] {getDuplicateReceiversWithDifferentHostNameForSendersXml(), 2, 0}, new Object[] {getDuplicateReceiversWithDifferentBindAddressesXml(), 2, 0}, new Object[] {getSingleReceiverWithDefaultBindAddressXml(), 1, 1}, new Object[] {getDuplicateReceiversWithDefaultBindAddressesXml(), 2, 1}, new Object[] {getValidReceiversXml(), 1, 1}, new Object[] {getNoReceiversXml(), 0, 0}); } }
@Test(expected = FallbackDefinitionException.class) @Parameters(method = "classGenericDefinitionFailure") public void testClassGenericDefinitionFailure(Class<?> type) { Object p = createProxy(type); executeCommand(p); }
@Test @Parameters public void testGetCacheKey(DimensionSpec dimensionSpec, boolean expectedResult) { Assert.assertEquals(expectedResult, Arrays.equals(lookupDimSpec.getCacheKey(), dimensionSpec.getCacheKey())); }
@Test @Parameters(method = "getCommands") public void whenLastReceivedIsSetThenCheckAndSetLastResultSentIfValidMustNotSetIt( BaseCommand baseCommand) { ServerToClientFunctionResultSender resultSender = mock(ServerToClientFunctionResultSender.class); when(resultSender.isLastResultReceived()).thenReturn(true); baseCommand.setLastResultReceived(resultSender); verify(resultSender, times(0)).setLastResultReceived(true); }
@Test @Parameters(method = "getCommands") public void whenLastReceivedIsNotSetThenCheckAndSetLastResultSentIfValidMustSetIt( BaseCommand baseCommand) { ServerToClientFunctionResultSender resultSender = mock(ServerToClientFunctionResultSender.class); when(resultSender.isLastResultReceived()).thenReturn(false); baseCommand.setLastResultReceived(resultSender); verify(resultSender, times(1)).setLastResultReceived(true); }
@Test @Parameters(method = "getCompiledValuesWhichDoNotImplementGetReceiver") public void whenGetReceiverIsNotImplementedThenHasIdentifierAtLeafMustReturnFalse( CompiledValue compiledValue) { assertFalse(compiledValue.hasIdentifierAtLeafNode()); }
@Test @Parameters(method = "getCompiledValuesWhichImplementGetReceiver") public void whenGetReceiverIsImplementedThenHasIdentifierAtLeafMustReturnTrue( CompiledValue compiledValue) { assertTrue(compiledValue.hasIdentifierAtLeafNode()); }
@Test @Parameters public void testApply(DimensionSpec dimensionSpec, Map<String, String> map) { for (Map.Entry<String, String> entry : map.entrySet()) { Assert.assertEquals( NullHandling.emptyToNullIfNeeded(entry.getValue()), dimensionSpec.getExtractionFn().apply(entry.getKey()) ); } }
@Test @Parameters(method = "getCheckCompatibilityProfiles") public void testCheckCompatibility(LuceneIndexCreationProfile myProfile, LuceneIndexCreationProfile otherProfile, String expectedResult) { assertEquals(expectedResult, otherProfile.checkCompatibility("/" + REGION_NAME, myProfile)); }
@Test @Parameters({MAC_OSX_NAME, LINUX_OS_NAME, SOLARIS_OS_NAME, WINDOWS_OS_NAME}) public void shouldUseComputerNameIfAvailableOnOS(String osName) throws IOException { setHostNameProperties(osName); String result = new HostName().determineHostName(); assertThat(result).isEqualTo(EXPECTED_HOSTNAME); }
@Test @Parameters({"EXECUTE_IN_SERIES", "EXECUTE_IN_PARALLEL"}) public void runAndExpectException(Execution execution) { Throwable expected = new NullPointerException("my custom message"); concurrencyRule.add(() -> { throw new NullPointerException("my custom message"); }).expectException(expected); execution.execute(concurrencyRule); }
@Test @Parameters({MAC_OSX_NAME, LINUX_OS_NAME, SOLARIS_OS_NAME, WINDOWS_OS_NAME}) public void shouldBeNullIfEnvValueNotAvailableOnOS(String osName) throws IOException { setHostNamePropertiesNull(osName); String result = new HostName().getHostNameFromEnv(); assertThat(result).isEqualTo(null); }
@Parameters @Test public void testSerDesr(DimensionSpec lookupDimSpec) throws IOException { ObjectMapper mapper = new DefaultObjectMapper(); mapper.registerSubtypes(new NamedType(LookupDimensionSpec.class, "lookup")); InjectableValues injectableValues = new InjectableValues.Std().addValue( LookupReferencesManager.class, LOOKUP_REF_MANAGER ); String serLookup = mapper.writeValueAsString(lookupDimSpec); Assert.assertEquals(lookupDimSpec, mapper.readerFor(DimensionSpec.class).with(injectableValues).readValue(serLookup)); }
@Test @Parameters({"EXECUTE_IN_SERIES", "EXECUTE_IN_PARALLEL"}) public void runAndExpectException_throwableInstanceWithCauses(Execution execution) { concurrencyRule.add(callWithExceptionAndCause).expectException(expectedExceptionWithCause); execution.execute(concurrencyRule); }
@Test @Parameters({MAC_OSX_NAME, LINUX_OS_NAME, SOLARIS_OS_NAME, WINDOWS_OS_NAME}) public void shouldExecHostNameIfEnvValueNotAvailableOnOS(String osName) throws IOException { setHostNamePropertiesNull(osName); String result = new HostName().determineHostName(); assertThat(result).isNotNull(); }