src_fm_fc_ms_ff
stringlengths
43
86.8k
target
stringlengths
20
276k
PseudoDistributedFileSystem extends FileSystem implements PathCanonicalizer { @Override public FSDataOutputStream create(Path f, FsPermission permission, boolean overwrite, int bufferSize, short replication, long blockSize, Progressable progress) throws IOException { final Path absolutePath = toAbsolutePath(f); checkPa...
@Test public void testCreateRoot() throws IOException { Path root = new Path("/"); try { fs.create(root, FsPermission.getFileDefault(), true, 0, (short) 1, 4096, null); fail("Expected create call to throw an exception"); } catch (AccessControlException e) { } } @Test public void testCreateFile() throws IOException { FS...
PseudoDistributedFileSystem extends FileSystem implements PathCanonicalizer { @Override public FSDataOutputStream append(Path f, int bufferSize, Progressable progress) throws IOException { Path absolutePath = toAbsolutePath(f); checkPath(absolutePath); if (absolutePath.isRoot()) { throw new AccessControlException("Cann...
@Test public void testAppendRoot() throws IOException { Path root = new Path("/"); try { fs.append(root, 4096, null); fail("Expected append call to throw an exception"); } catch (AccessControlException e) { } } @Test public void testAppendFile() throws IOException { FSDataOutputStream mockFDOS = mock(FSDataOutputStream...
PseudoDistributedFileSystem extends FileSystem implements PathCanonicalizer { @Override public boolean delete(Path f, boolean recursive) throws IOException { Path absolutePath = toAbsolutePath(f); checkPath(absolutePath); if (absolutePath.isRoot()) { throw new AccessControlException("Cannot delete " + f); } if (!isRemo...
@Test public void testDeleteRoot() throws IOException { Path root = new Path("/"); try { fs.delete(root, false); fail("Expected delete call to throw an exception"); } catch (AccessControlException e) { } } @Test public void testDeleteLocalFile() throws IOException { try { Path path = new Path("/foo/bar/file"); fs.delet...
SQLGenerator { public static String generateSQL(VirtualDatasetState vss){ return new SQLGenerator().innerGenerateSQL(vss); } SQLGenerator(); static String generateSQL(VirtualDatasetState vss); static String getTableAlias(From from); }
@Test public void testReplaceInvalidReplacedValues() { boolean exThrown = false; try { VirtualDatasetState state = new VirtualDatasetState() .setFrom(nameDSRef); Expression exp0 = new ExpColumnReference("bar").wrap(); FieldTransformationBase transf1 = new FieldReplaceValue() .setReplacedValuesList(Collections.<String>e...
PseudoDistributedFileSystem extends FileSystem implements PathCanonicalizer { @Override public boolean mkdirs(Path f, FsPermission permission) throws IOException { Path absolutePath = toAbsolutePath(f); checkPath(absolutePath); if (absolutePath.isRoot()) { return true; } if (isRemoteFile(absolutePath)) { throw new IOEx...
@Test public void testMkdirsRoot() throws IOException { Path root = new Path("/"); assertTrue(fs.mkdirs(root, FsPermission.getDirDefault())); } @Test public void testMkdirsRemoteFile() throws IOException { doReturn(true).when(mockLocalFS).mkdirs( new Path("/foo/bar/dir2"), FsPermission.getFileDefault()); doReturn(true)...
PseudoDistributedFileSystem extends FileSystem implements PathCanonicalizer { @Override public boolean rename(Path src, Path dst) throws IOException { Path absoluteSrc = toAbsolutePath(src); Path absoluteDst = toAbsolutePath(dst); checkPath(absoluteSrc); checkPath(absoluteDst); if (absoluteSrc.isRoot()) { throw new IOE...
@Test public void testRenameFromRoot() throws IOException { Path root = new Path("/"); Path dst = new Path("/foo/baz"); try { fs.rename(root, dst); fail("Expected rename to throw an exception"); } catch(IOException e) { } } @Test public void testRenameToRoot() throws IOException { Path root = new Path("/"); Path src = ...
PseudoDistributedFileSystem extends FileSystem implements PathCanonicalizer { @Override public BlockLocation[] getFileBlockLocations(FileStatus file, long start, long len) throws IOException { Preconditions.checkArgument(start >= 0, "start should be positive"); Preconditions.checkArgument(len >= 0, "len should be posit...
@Test public void testGetFileBlockLocations() throws IOException { Path path = new Path("/foo/10.0.0.1@bar"); BlockLocation[] locations = fs.getFileBlockLocations(new FileStatus(1027, false, 1, 4096, 123456, path), 7, 1024); assertEquals(1, locations.length); BlockLocation location = locations[0]; assertArrayEquals(new...
HistogramGenerator { @VisibleForTesting protected static LocalDateTime roundTime(LocalDateTime tmpValue, TruncEvalEnum trucateTo, boolean isRoundDown) { switch (trucateTo) { case SECOND: if (isRoundDown) { return tmpValue.secondOfMinute().roundFloorCopy(); } else { return tmpValue.secondOfMinute().roundCeilingCopy(); }...
@Test public void testTimeIntervals() throws Exception { HistogramGenerator hg = new HistogramGenerator(null); String myTimeStr = "2016-02-29 13:59:01"; DateTimeFormatter dtf = DateFunctionsUtils.getISOFormatterForFormatString("YYYY-MM-DD HH24:MI:SS"); LocalDateTime myTime = dtf.parseLocalDateTime(myTimeStr); System.ou...
PseudoDistributedFileSystem extends FileSystem implements PathCanonicalizer { @Override public Path canonicalizePath(Path p) throws IOException { Path absolutePath = toAbsolutePath(p); checkPath(absolutePath); if (isRemoteFile(absolutePath)) { return absolutePath; } if (isDirectory(absolutePath)) { return absolutePath;...
@Test public void testCanonicalizeRemoteFile() throws IOException { Path path = new Path("/foo/bar/10.0.0.2@file"); Path resolvedPath = fs.canonicalizePath(path); assertEquals(new Path("/foo/bar/10.0.0.2@file"), resolvedPath); } @Test public void testCanonicalizeDirectoryFile() throws IOException { Path path = new Path...
Hive3StoragePlugin extends BaseHiveStoragePlugin implements StoragePluginCreator.PF4JStoragePlugin, SupportsReadSignature, SupportsListingDatasets, SupportsAlteringDatasetMetadata, SupportsPF4JStoragePlugin { public String getUsername(String name) { if (isStorageImpersonationEnabled()) { return name; } return Syste...
@Test public void impersonationDisabledShouldReturnSystemUser() { final HiveConf hiveConf = new HiveConf(); hiveConf.setBoolVar(HIVE_SERVER2_ENABLE_DOAS, false); final SabotContext context = mock(SabotContext.class); final Hive3StoragePlugin plugin = createHiveStoragePlugin(hiveConf, context); final String userName = p...
HiveScanBatchCreator implements HiveProxiedScanBatchCreator { @VisibleForTesting public UserGroupInformation getUGI(Hive3StoragePlugin storagePlugin, HiveProxyingSubScan config) { final String userName = storagePlugin.getUsername(config.getProps().getUserName()); return HiveImpersonationUtil.createProxyUgi(userName); }...
@Test public void ensureStoragePluginIsUsedForUsername() throws Exception { final String originalName = "Test"; final String finalName = "Replaced"; final HiveScanBatchCreator creator = new HiveScanBatchCreator(); final Hive3StoragePlugin plugin = mock(Hive3StoragePlugin.class); when(plugin.getUsername(originalName)).t...
NativeLibPluginManager extends DefaultPluginManager { @Override protected Path createPluginsRoot() { final Path pluginsPath = this.isDevelopment() ? Paths.get(PLUGINS_PATH_DEV_MODE) : DremioConfig.getPluginsRootPath().resolve("connectors"); return pluginsPath; } }
@Test public void testShouldReturnPluginRoot() { properties.set(DremioConfig.PLUGINS_ROOT_PATH_PROPERTY, "/tmp/plugins"); Path expectedPath = Paths.get("/tmp/plugins/connectors"); Path actualPath = nativeLibPluginManager.createPluginsRoot(); Assert.assertEquals(expectedPath, actualPath); }
HistogramGenerator { @VisibleForTesting static void produceRanges(List<Number> ranges, LocalDateTime min, LocalDateTime max, TruncEvalEnum truncateTo) { long timeValue = toMillis(roundTime(min, truncateTo, true)); long maxTimeValue = toMillis(roundTime(max, truncateTo, false)); ranges.add(timeValue); while ( timeValue ...
@Test public void testProduceRanges() { List<Number> ranges = new ArrayList<>(); HistogramGenerator.produceRanges(ranges , new LocalDateTime(1970, 1, 1, 1, 0, 0), new LocalDateTime(1970, 1, 1, 11, 59, 0), TruncEvalEnum.HOUR); List<Number> expected = new ArrayList<>(); for (int i = 0; i < 13; i++) { expected.add((i + 1 ...
NativeLibPluginClassLoader extends PluginClassLoader { @VisibleForTesting static void validateZipDirectory(Path tempDirectory, final ZipEntry entry) throws IOException { final Path destinationPath = tempDirectory.resolve(entry.getName()).normalize(); if (!destinationPath.startsWith(tempDirectory)) { throw new IOExcepti...
@Test public void validateZipDirectoryValidNatural() throws IOException { ZipEntry entry = new ZipEntry("somedir/somefile"); NativeLibPluginClassLoader.validateZipDirectory(mockTempDir, entry); NativeLibPluginClassLoader.validateZipDirectory(mockTempDirWithTrailingSlash, entry); NativeLibPluginClassLoader.validateZipDi...
ExtractMapRecommender extends Recommender<ExtractMapRule, MapSelection> { @Override public List<ExtractMapRule> getRules(MapSelection selection, DataType selColType) { checkArgument(selColType == DataType.MAP, "Extract map entries is supported only on MAP type columns"); return Collections.singletonList(new ExtractMapR...
@Test public void testExtractMapRules() throws Exception { List<ExtractMapRule> rules = recommender.getRules(new MapSelection("foo", ImmutableList.of("a")), DataType.MAP); assertEquals(1, rules.size()); assertEquals("a", rules.get(0).getPath()); }
YarnController { public YarnController() { this(DremioConfig.create()); } YarnController(); YarnController(DremioConfig config); TwillRunnerService getTwillService(ClusterId key); void invalidateTwillService(final ClusterId key); TwillRunnerService startTwillRunner(YarnConfiguration yarnConfiguration); TwillController...
@Test public void testYarnController() throws Exception { assumeNonMaprProfile(); YarnController yarnController = new YarnController(); YarnConfiguration yarnConfiguration = createYarnConfig("resource-manager", "hdfs: String jvmOptions = yarnController.prepareCommandOptions(yarnConfiguration, getProperties()); logger.i...
YarnService implements ProvisioningServiceDelegate { @Override public ClusterEnriched startCluster(Cluster cluster) throws YarnProvisioningHandlingException { Preconditions.checkArgument(cluster.getState() != ClusterState.RUNNING); return startClusterAsync(cluster); } YarnService(DremioConfig config, ProvisioningStateL...
@Test public void testStartCluster() throws Exception { assumeNonMaprProfile(); YarnController controller = Mockito.mock(YarnController.class); YarnService yarnService = new YarnService(new TestListener(), controller, Mockito.mock(NodeProvider.class)); Cluster cluster = new Cluster(); cluster.setState(ClusterState.CREA...
YarnService implements ProvisioningServiceDelegate { @VisibleForTesting protected String updateYarnConfiguration(Cluster cluster, YarnConfiguration yarnConfiguration) { String rmAddress = null; setYarnDefaults(cluster, yarnConfiguration); List<Property> keyValues = cluster.getClusterConfig().getSubPropertyList(); if ( ...
@Test public void testDistroDefaults() throws Exception { assumeNonMaprProfile(); YarnController controller = Mockito.mock(YarnController.class); YarnService yarnService = new YarnService(new TestListener(), controller, Mockito.mock(NodeProvider.class)); Cluster cluster = new Cluster(); cluster.setState(ClusterState.CR...
ExtractMapRecommender extends Recommender<ExtractMapRule, MapSelection> { @Override public TransformRuleWrapper<ExtractMapRule> wrapRule(ExtractMapRule rule) { return new ExtractMapTransformRuleWrapper(rule); } @Override List<ExtractMapRule> getRules(MapSelection selection, DataType selColType); @Override TransformRul...
@Test public void testGenExtractMapRuleWrapper() throws Exception { TransformRuleWrapper<ExtractMapRule> wrapper = recommender.wrapRule(new ExtractMapRule("a")); assertEquals("a", wrapper.getRule().getPath()); assertEquals("extract from map a", wrapper.describe()); assertEquals("tbl.foo.a IS NOT NULL", wrapper.getMatch...
YarnService implements ProvisioningServiceDelegate { @Override public void stopCluster(Cluster cluster) throws YarnProvisioningHandlingException { stopClusterAsync(cluster); } YarnService(DremioConfig config, ProvisioningStateListener stateListener, NodeProvider executionNodeProvider, OptionManager...
@Test public void testStopCluster() throws Exception { assumeNonMaprProfile(); Cluster myCluster = createCluster(); myCluster.setState(ClusterState.RUNNING); myCluster.setStateChangeTime(System.currentTimeMillis()); YarnController controller = Mockito.mock(YarnController.class); YarnService yarnService = new YarnServic...
YarnService implements ProvisioningServiceDelegate { @Override public ClusterEnriched getClusterInfo(final Cluster cluster) throws YarnProvisioningHandlingException { TwillController controller = getTwillControllerHelper(cluster); final ClusterEnriched clusterEnriched = new ClusterEnriched(cluster); if (controller != n...
@Test public void testGetClusterInfo() throws Exception { assumeNonMaprProfile(); YarnController controller = Mockito.mock(YarnController.class); YarnService yarnService = new YarnService(new TestListener(), controller, Mockito.mock(NodeProvider.class)); Cluster cluster = new Cluster(); cluster.setState(ClusterState.CR...
AppBundleGenerator { @VisibleForTesting static Stream<Path> toPathStream(ClassLoader classLoader) { if (classLoader == null) { return Stream.of(); } if (classLoader != ClassLoader.getSystemClassLoader()) { return Stream.concat(toPathStream(classLoader.getParent()), getPaths(classLoader)); } else { return getPaths(class...
@Test public void testToPathStream() throws MalformedURLException, IOException { try ( URLClassLoader clA = new URLClassLoader( new URL[] { new URL("file:/foo/bar.jar"), new URL("file:/foo/baz.jar") }, null); URLClassLoader clB = new URLClassLoader( new URL[] { new URL("file:/test/ab.jar"), new URL("file:/test/cd.jar")...
CardGenerator { <T> String generateCardGenQuery(String inputColName, String datasetPreviewTable, List<TransformRuleWrapper<T>> evaluators) { StringBuilder queryBuilder = new StringBuilder(); String inputExpr = String.format("%s.%s", quoteIdentifier("dremio_preview_data"), quoteIdentifier(inputColName)); List<String> ex...
@Test public void exampleGeneratorQuery() { String outputQuery1 = cardGenerator.generateCardGenQuery("col.with.dots", "TABLE(\"jobstore\".\"path\"(type => 'arrow))", rules); String expQuery1 = "SELECT\n" + "match_pattern_example(dremio_preview_data.\"col.with.dots\", 'CONTAINS', 'test pattern', false) AS example_0,\n" ...
YarnContainerHealthMonitor implements LiveHealthMonitor { @Override public boolean isHealthy() { return isHealthy; } YarnContainerHealthMonitor(); @Override boolean isHealthy(); }
@Test public void testUnavailableContainer() throws Exception { when(connection.getResponseCode()).thenReturn(HttpStatus.SC_NOT_FOUND); assertNull(healthMonitorThread.getContainerState(connection)); assertFalse(healthMonitorThread.isHealthy()); } @Test public void testHealthyContainer() throws Exception { String contai...
CardGenerator { <T> String generateMatchCountQuery(String inputColName, String datasetPreviewTable, List<TransformRuleWrapper<T>> evaluators) { StringBuilder queryBuilder = new StringBuilder(); String inputExpr = String.format("%s.%s", quoteIdentifier("dremio_preview_data"), quoteIdentifier(inputColName)); List<String>...
@Test public void matchCountGeneratorQuery() { String outputQuery1 = cardGenerator.generateMatchCountQuery("col with spaces", "TABLE(\"jobstore\".\"path\"(type => 'arrow))", rules); String expQuery1 = "SELECT\n" + "sum(CASE WHEN regexp_like(dremio_preview_data.\"col with spaces\", '.*?\\Qtest pattern\\E.*?') THEN 1 ELS...
ExtractRecommender extends Recommender<ExtractRule, Selection> { @Override public List<ExtractRule> getRules(Selection selection, DataType selColType) { checkArgument(selColType == DataType.TEXT, "Extract text is supported only on TEXT type columns"); if (selection.getLength() <= 0) { throw UserException.validationErro...
@Test public void ruleSuggestionsSelNumberInTheBeginning() { Selection selection = new Selection("col", "883 N Shoreline Blvd., Mountain View, CA 94043", 0, 3); List<ExtractRule> rules = recommender.getRules(selection, TEXT); assertEquals(5, rules.size()); comparePattern("\\d+", 0, INDEX, rules.get(0).getPattern()); co...
ExtractRecommender extends Recommender<ExtractRule, Selection> { List<ExtractRule> recommendCharacterGroup(Selection selection) { List<ExtractRule> rules = new ArrayList<>(); String cellText = selection.getCellText(); int start = selection.getOffset(); int end = start + selection.getLength(); String selected = cellText...
@Test public void testRecommendCharacterGroup() { List<ExtractRule> cards = recommender.recommendCharacterGroup(new Selection("col", "abc def,ghi", 4, 3)); assertEquals(1, cards.size()); assertEquals(pattern, cards.get(0).getType()); ExtractRulePattern pattern = cards.get(0).getPattern(); assertEquals(1, pattern.getInd...
QuerySemantics { public static VirtualDatasetState extract(QueryMetadata metadata) { final com.dremio.service.jobs.metadata.proto.VirtualDatasetState pState = metadata.getState(); final VirtualDatasetState state = new VirtualDatasetState(); if (pState.hasFrom()) { state.setFrom(fromBuf(pState.getFrom())); } if (pState....
@Test public void testStar() { VirtualDatasetState ds = extract( getQueryFromSQL("select * from " + table)); assertEquals( new VirtualDatasetState() .setFrom(from) .setContextList(Collections.<String>emptyList()) .setReferredTablesList(Arrays.asList("tpch/supplier.parquet")) .setColumnsList(cols("s_suppkey", "s_name", ...
PowerBIMessageBodyGenerator extends BaseBIToolMessageBodyGenerator { @VisibleForTesting static DSRFile createDSRFile(String hostname, DatasetConfig datasetConfig) { final DSRConnectionInfo connInfo = new DSRConnectionInfo(); connInfo.server = hostname; final DatasetPath dataset = new DatasetPath(datasetConfig.getFullPa...
@Test public void verifyDSRFile() { final PowerBIMessageBodyGenerator.DSRFile dsrFile = PowerBIMessageBodyGenerator.createDSRFile(server, datasetConfig); assertEquals("0.1", dsrFile.getVersion()); final PowerBIMessageBodyGenerator.Connection connection = dsrFile.getConnections()[0]; assertEquals("DirectQuery", connecti...
SourceResource extends BaseResourceWithAllocator { @RolesAllowed("admin") @DELETE @Produces(MediaType.APPLICATION_JSON) public void deleteSource(@QueryParam("version") String version) throws NamespaceException, SourceNotFoundException { if (version == null) { throw new ClientErrorException("missing version parameter");...
@Test public void testAddSourceWithAccelerationTTL() throws Exception { final String sourceName = "src"; final long refreshPeriod = TimeUnit.HOURS.toMillis(4); final long gracePeriod = TimeUnit.HOURS.toMillis(12); { final NASConf nas = new NASConf(); nas.path = folder.getRoot().getPath(); SourceUI source = new SourceUI...
BaseBIToolResource { @VisibleForTesting Response.ResponseBuilder buildResponseWithHost(Response.ResponseBuilder builder, String host) { if (host == null) { return builder; } final String hostOnly; final int portIndex = host.indexOf(":"); if (portIndex == -1) { hostOnly = host; } else { hostOnly = host.substring(0, port...
@Test public void verifyHeaders() { final Response response = resource.buildResponseWithHost(Response.ok(), inputHost).build(); if (expectedHost == null) { assertFalse(response.getHeaders().containsKey(WebServer.X_DREMIO_HOSTNAME)); return; } assertEquals(expectedHost, response.getHeaders().get(WebServer.X_DREMIO_HOSTN...
ReflectionResource { @GET @Path("/{id}") public Reflection getReflection(@PathParam("id") String id) { Optional<ReflectionGoal> goal = reflectionServiceHelper.getReflectionById(id); if (!goal.isPresent()) { throw new ReflectionNotFound(id); } String reflectionId = goal.get().getId().getId(); return new Reflection(goal....
@Test public void testGetReflection() { Reflection newReflection = createReflection(); Reflection response = expectSuccess(getBuilder(getPublicAPI(3).path(REFLECTIONS_PATH)).buildPost(Entity.entity(newReflection, JSON)), Reflection.class); Reflection response2 = expectSuccess(getBuilder(getPublicAPI(3).path(REFLECTIONS...
ScorePair { public ScorePair(MatchingConfig mc) { this.mc = mc; vt = new VectorTable(mc); modifiers = new ArrayList<Modifier>(); observed_vectors = new Hashtable<MatchVector, Long>(); } ScorePair(MatchingConfig mc); void addScoreModifier(Modifier sm); MatchResult scorePair(Record rec1, Record rec2); Hashtable<MatchVect...
@Test public void scorePair_shouldIndicateAMatchOnPatientsWithMultipleIdentifiersForAnIdentifierType() throws Exception { Record rec1 = new Record(1, "foo"); Record rec2 = new Record(2, "foo"); rec1.addDemographic("(Identifier) Old OpenMRS Identifier", "111,222,333"); rec2.addDemographic("(Identifier) Old OpenMRS Ident...
ScorePair { protected List<String[]> getCandidatesFromMultiFieldDemographics(String data1, String data2) { String[] a = data1.split(MatchingConstants.MULTI_FIELD_DELIMITER); String[] b = data2.split(MatchingConstants.MULTI_FIELD_DELIMITER); List<String[]> res = new ArrayList<String[]>(); for (String i : a) { for (Strin...
@Test public void getCandidatesFromMultiFieldDemographics_shouldReturnAListOfAllPossiblePermutations() throws Exception { MatchingConfigRow mcr = new MatchingConfigRow("ack"); mcr.setInclude(true); MatchingConfig mc = new MatchingConfig("foo", new MatchingConfigRow[]{ mcr }); ScorePair sp = new ScorePair(mc); String da...
Employee { public void salaryIncrement(Double percentage) { Double newSalary = salary + percentage * salary / 100; setSalary(newSalary); } Employee(Integer id, String name, Double salary); Integer getId(); void setId(Integer id); String getName(); void setName(String name); Double getSalary(); void setSalary(Double sal...
@Test public void whenIncrementSalaryForEachEmployee_thenApplyNewSalary() { Employee[] arrayOfEmps = { new Employee(1, "Jeff Bezos", 100000.0), new Employee(2, "Bill Gates", 200000.0), new Employee(3, "Mark Zuckerberg", 300000.0) }; List<Employee> empList = Arrays.asList(arrayOfEmps); empList.stream().forEach(e -> e.sa...
WebConfigurer implements ServletContextInitializer, WebServerFactoryCustomizer<WebServerFactory> { @Override public void customize(WebServerFactory server) { setMimeMappings(server); setLocationForStaticAssets(server); if (jHipsterProperties.getHttp().getVersion().equals(JHipsterProperties.Http.Version.V_2_0) && server...
@Test public void testUndertowHttp2Enabled() { props.getHttp().setVersion(JHipsterProperties.Http.Version.V_2_0); UndertowServletWebServerFactory container = new UndertowServletWebServerFactory(); webConfigurer.customize(container); Builder builder = Undertow.builder(); container.getBuilderCustomizers().forEach(c -> c....
WebConfigurer implements ServletContextInitializer, WebServerFactoryCustomizer<WebServerFactory> { @Bean public CorsFilter corsFilter() { UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); CorsConfiguration config = jHipsterProperties.getCors(); if (config.getAllowedOrigins() != null && !co...
@Test public void testCorsFilterOnApiPath() throws Exception { props.getCors().setAllowedOrigins(Collections.singletonList("*")); props.getCors().setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "DELETE")); props.getCors().setAllowedHeaders(Collections.singletonList("*")); props.getCors().setMaxAge(1800L); props.g...
SwaggerBasePathRewritingFilter extends SendResponseFilter { @Override public boolean shouldFilter() { return RequestContext.getCurrentContext().getRequest().getRequestURI().endsWith(Swagger2Controller.DEFAULT_URL); } SwaggerBasePathRewritingFilter(); @Override String filterType(); @Override int filterOrder(); @Override...
@Test public void shouldFilter_on_default_swagger_url() { MockHttpServletRequest request = new MockHttpServletRequest("GET", DEFAULT_URL); RequestContext.getCurrentContext().setRequest(request); assertTrue(filter.shouldFilter()); } @Test public void shouldFilter_on_default_swagger_url_with_param() { MockHttpServletRequ...
SwaggerBasePathRewritingFilter extends SendResponseFilter { @Override public Object run() { RequestContext context = RequestContext.getCurrentContext(); context.getResponse().setCharacterEncoding("UTF-8"); String rewrittenResponse = rewriteBasePath(context); if (context.getResponseGZipped()) { try { context.setResponse...
@Test public void run_on_valid_response() throws Exception { MockHttpServletRequest request = new MockHttpServletRequest("GET", "/service1" + DEFAULT_URL); RequestContext context = RequestContext.getCurrentContext(); context.setRequest(request); MockHttpServletResponse response = new MockHttpServletResponse(); context....
Employee { public String getName() { return name; } Employee(Integer id, String name, Double salary); Integer getId(); void setId(Integer id); String getName(); void setName(String name); Double getSalary(); void setSalary(Double salary); void salaryIncrement(Double percentage); String toString(); }
@Test public void whenStreamMapping_thenGetMap() { Map<Character, List<Integer>> idGroupedByAlphabet = empList.stream().collect( Collectors.groupingBy(e -> new Character(e.getName().charAt(0)), Collectors.mapping(Employee::getId, Collectors.toList()))); assertEquals(idGroupedByAlphabet.get('B').get(0), new Integer(2));...
Employee { public Double getSalary() { return salary; } Employee(Integer id, String name, Double salary); Integer getId(); void setId(Integer id); String getName(); void setName(String name); Double getSalary(); void setSalary(Double salary); void salaryIncrement(Double percentage); String toString(); }
@Test public void whenStreamReducing_thenGetValue() { Double percentage = 10.0; Double salIncrOverhead = empList.stream().collect(Collectors.reducing( 0.0, e -> e.getSalary() * percentage / 100, (s1, s2) -> s1 + s2)); assertEquals(salIncrOverhead, 60000.0, 0); } @Test public void whenFilterEmployees_thenGetFilteredStre...
TshirtSizeController { @RequestMapping(value ="convertSize", method = RequestMethod.GET) public int convertSize(@RequestParam(value = "label") final String label, @RequestParam(value = "countryCode", required = false) final String countryCode) { return service.convertSize(label, countryCode); } TshirtSizeController(Siz...
@Test void whenConvertSize_thenOK() { String label = "S"; String countryCode = "fr"; int result = 36; when(service.convertSize(label, countryCode)).thenReturn(result); int actual = tested.convertSize(label, countryCode); assertEquals(actual, result); }
Order { public Order id(Long id) { this.id = id; return this; } Order id(Long id); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Long getId(); void setId(Long id); Order petId(Long petId); @javax.annotation.Nullable @ApiM...
@Test public void idTest() { }
Order { public Order petId(Long petId) { this.petId = petId; return this; } Order id(Long id); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Long getId(); void setId(Long id); Order petId(Long petId); @javax.annotation.Nu...
@Test public void petIdTest() { }
Order { public Order quantity(Integer quantity) { this.quantity = quantity; return this; } Order id(Long id); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Long getId(); void setId(Long id); Order petId(Long petId); @java...
@Test public void quantityTest() { }
Order { public Order shipDate(OffsetDateTime shipDate) { this.shipDate = shipDate; return this; } Order id(Long id); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Long getId(); void setId(Long id); Order petId(Long petId)...
@Test public void shipDateTest() { }
Order { public Order status(StatusEnum status) { this.status = status; return this; } Order id(Long id); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Long getId(); void setId(Long id); Order petId(Long petId); @javax.ann...
@Test public void statusTest() { }
Order { public Order complete(Boolean complete) { this.complete = complete; return this; } Order id(Long id); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Long getId(); void setId(Long id); Order petId(Long petId); @java...
@Test public void completeTest() { }
User { public User id(Long id) { this.id = id; return this; } User id(Long id); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Long getId(); void setId(Long id); User username(String username); @javax.annotation.Nullable @...
@Test public void idTest() { }
User { public User username(String username) { this.username = username; return this; } User id(Long id); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Long getId(); void setId(Long id); User username(String username); @j...
@Test public void usernameTest() { }
User { public User firstName(String firstName) { this.firstName = firstName; return this; } User id(Long id); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Long getId(); void setId(Long id); User username(String username)...
@Test public void firstNameTest() { }
User { public User lastName(String lastName) { this.lastName = lastName; return this; } User id(Long id); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Long getId(); void setId(Long id); User username(String username); @j...
@Test public void lastNameTest() { }
User { public User email(String email) { this.email = email; return this; } User id(Long id); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Long getId(); void setId(Long id); User username(String username); @javax.annotat...
@Test public void emailTest() { }
User { public User password(String password) { this.password = password; return this; } User id(Long id); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Long getId(); void setId(Long id); User username(String username); @j...
@Test public void passwordTest() { }
User { public User phone(String phone) { this.phone = phone; return this; } User id(Long id); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Long getId(); void setId(Long id); User username(String username); @javax.annotat...
@Test public void phoneTest() { }
User { public User userStatus(Integer userStatus) { this.userStatus = userStatus; return this; } User id(Long id); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Long getId(); void setId(Long id); User username(String user...
@Test public void userStatusTest() { }
Pet { public Pet id(Long id) { this.id = id; return this; } Pet id(Long id); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Long getId(); void setId(Long id); Pet category(Category category); @javax.annotation.Nullable @Ap...
@Test public void idTest() { }
Pet { public Pet category(Category category) { this.category = category; return this; } Pet id(Long id); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Long getId(); void setId(Long id); Pet category(Category category); @j...
@Test public void categoryTest() { }
Pet { public Pet name(String name) { this.name = name; return this; } Pet id(Long id); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Long getId(); void setId(Long id); Pet category(Category category); @javax.annotation.Nu...
@Test public void nameTest() { }
Pet { public Pet photoUrls(List<String> photoUrls) { this.photoUrls = photoUrls; return this; } Pet id(Long id); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Long getId(); void setId(Long id); Pet category(Category categ...
@Test public void photoUrlsTest() { }
Pet { public Pet tags(List<Tag> tags) { this.tags = tags; return this; } Pet id(Long id); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Long getId(); void setId(Long id); Pet category(Category category); @javax.annotation...
@Test public void tagsTest() { }
Pet { public Pet status(StatusEnum status) { this.status = status; return this; } Pet id(Long id); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Long getId(); void setId(Long id); Pet category(Category category); @javax.a...
@Test public void statusTest() { }
Category { public Category id(Long id) { this.id = id; return this; } Category id(Long id); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Long getId(); void setId(Long id); Category name(String name); @javax.annotation.Nu...
@Test public void idTest() { }
Category { public Category name(String name) { this.name = name; return this; } Category id(Long id); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Long getId(); void setId(Long id); Category name(String name); @javax.ann...
@Test public void nameTest() { }
ModelApiResponse { public ModelApiResponse code(Integer code) { this.code = code; return this; } ModelApiResponse code(Integer code); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_CODE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Integer getCode(); void setCode(Integer...
@Test public void codeTest() { }
ModelApiResponse { public ModelApiResponse type(String type) { this.type = type; return this; } ModelApiResponse code(Integer code); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_CODE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Integer getCode(); void setCode(Integer ...
@Test public void typeTest() { }
ModelApiResponse { public ModelApiResponse message(String message) { this.message = message; return this; } ModelApiResponse code(Integer code); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_CODE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Integer getCode(); void setC...
@Test public void messageTest() { }
Tag { public Tag id(Long id) { this.id = id; return this; } Tag id(Long id); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Long getId(); void setId(Long id); Tag name(String name); @javax.annotation.Nullable @ApiModelProp...
@Test public void idTest() { }
Tag { public Tag name(String name) { this.name = name; return this; } Tag id(Long id); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Long getId(); void setId(Long id); Tag name(String name); @javax.annotation.Nullable @Ap...
@Test public void nameTest() { }
UserApi { public void createUser(User body) throws RestClientException { createUserWithHttpInfo(body); } UserApi(); @Autowired UserApi(ApiClient apiClient); ApiClient getApiClient(); void setApiClient(ApiClient apiClient); void createUser(User body); ResponseEntity<Void> createUserWithHttpInfo(User body); void createU...
@Test public void createUserTest() { User body = null; api.createUser(body); }
UserApi { public void createUsersWithArrayInput(List<User> body) throws RestClientException { createUsersWithArrayInputWithHttpInfo(body); } UserApi(); @Autowired UserApi(ApiClient apiClient); ApiClient getApiClient(); void setApiClient(ApiClient apiClient); void createUser(User body); ResponseEntity<Void> createUserW...
@Test public void createUsersWithArrayInputTest() { List<User> body = null; api.createUsersWithArrayInput(body); }
UserApi { public void createUsersWithListInput(List<User> body) throws RestClientException { createUsersWithListInputWithHttpInfo(body); } UserApi(); @Autowired UserApi(ApiClient apiClient); ApiClient getApiClient(); void setApiClient(ApiClient apiClient); void createUser(User body); ResponseEntity<Void> createUserWit...
@Test public void createUsersWithListInputTest() { List<User> body = null; api.createUsersWithListInput(body); }
UserApi { public void deleteUser(String username) throws RestClientException { deleteUserWithHttpInfo(username); } UserApi(); @Autowired UserApi(ApiClient apiClient); ApiClient getApiClient(); void setApiClient(ApiClient apiClient); void createUser(User body); ResponseEntity<Void> createUserWithHttpInfo(User body); vo...
@Test public void deleteUserTest() { String username = null; api.deleteUser(username); }
UserApi { public User getUserByName(String username) throws RestClientException { return getUserByNameWithHttpInfo(username).getBody(); } UserApi(); @Autowired UserApi(ApiClient apiClient); ApiClient getApiClient(); void setApiClient(ApiClient apiClient); void createUser(User body); ResponseEntity<Void> createUserWith...
@Test public void getUserByNameTest() { String username = null; User response = api.getUserByName(username); }
UserApi { public String loginUser(String username, String password) throws RestClientException { return loginUserWithHttpInfo(username, password).getBody(); } UserApi(); @Autowired UserApi(ApiClient apiClient); ApiClient getApiClient(); void setApiClient(ApiClient apiClient); void createUser(User body); ResponseEntity...
@Test public void loginUserTest() { String username = null; String password = null; String response = api.loginUser(username, password); }
UserApi { public void logoutUser() throws RestClientException { logoutUserWithHttpInfo(); } UserApi(); @Autowired UserApi(ApiClient apiClient); ApiClient getApiClient(); void setApiClient(ApiClient apiClient); void createUser(User body); ResponseEntity<Void> createUserWithHttpInfo(User body); void createUsersWithArray...
@Test public void logoutUserTest() { api.logoutUser(); }
UserApi { public void updateUser(String username, User body) throws RestClientException { updateUserWithHttpInfo(username, body); } UserApi(); @Autowired UserApi(ApiClient apiClient); ApiClient getApiClient(); void setApiClient(ApiClient apiClient); void createUser(User body); ResponseEntity<Void> createUserWithHttpIn...
@Test public void updateUserTest() { String username = null; User body = null; api.updateUser(username, body); }
StoreApi { public void deleteOrder(Long orderId) throws RestClientException { deleteOrderWithHttpInfo(orderId); } StoreApi(); @Autowired StoreApi(ApiClient apiClient); ApiClient getApiClient(); void setApiClient(ApiClient apiClient); void deleteOrder(Long orderId); ResponseEntity<Void> deleteOrderWithHttpInfo(Long ord...
@Test public void deleteOrderTest() { Long orderId = null; api.deleteOrder(orderId); }
StoreApi { public Map<String, Integer> getInventory() throws RestClientException { return getInventoryWithHttpInfo().getBody(); } StoreApi(); @Autowired StoreApi(ApiClient apiClient); ApiClient getApiClient(); void setApiClient(ApiClient apiClient); void deleteOrder(Long orderId); ResponseEntity<Void> deleteOrderWithH...
@Test public void getInventoryTest() { Map<String, Integer> response = api.getInventory(); }
StoreApi { public Order getOrderById(Long orderId) throws RestClientException { return getOrderByIdWithHttpInfo(orderId).getBody(); } StoreApi(); @Autowired StoreApi(ApiClient apiClient); ApiClient getApiClient(); void setApiClient(ApiClient apiClient); void deleteOrder(Long orderId); ResponseEntity<Void> deleteOrderW...
@Test public void getOrderByIdTest() { Long orderId = null; Order response = api.getOrderById(orderId); }
StoreApi { public Order placeOrder(Order body) throws RestClientException { return placeOrderWithHttpInfo(body).getBody(); } StoreApi(); @Autowired StoreApi(ApiClient apiClient); ApiClient getApiClient(); void setApiClient(ApiClient apiClient); void deleteOrder(Long orderId); ResponseEntity<Void> deleteOrderWithHttpIn...
@Test public void placeOrderTest() { Order body = null; Order response = api.placeOrder(body); }
PetApi { public void addPet(Pet body) throws RestClientException { addPetWithHttpInfo(body); } PetApi(); @Autowired PetApi(ApiClient apiClient); ApiClient getApiClient(); void setApiClient(ApiClient apiClient); void addPet(Pet body); ResponseEntity<Void> addPetWithHttpInfo(Pet body); void deletePet(Long petId, String ...
@Test public void addPetTest() { Pet body = null; api.addPet(body); }
PetApi { public void deletePet(Long petId, String apiKey) throws RestClientException { deletePetWithHttpInfo(petId, apiKey); } PetApi(); @Autowired PetApi(ApiClient apiClient); ApiClient getApiClient(); void setApiClient(ApiClient apiClient); void addPet(Pet body); ResponseEntity<Void> addPetWithHttpInfo(Pet body); vo...
@Test public void deletePetTest() { Long petId = null; String apiKey = null; api.deletePet(petId, apiKey); }
PetApi { public List<Pet> findPetsByStatus(List<String> status) throws RestClientException { return findPetsByStatusWithHttpInfo(status).getBody(); } PetApi(); @Autowired PetApi(ApiClient apiClient); ApiClient getApiClient(); void setApiClient(ApiClient apiClient); void addPet(Pet body); ResponseEntity<Void> addPetWit...
@Test public void findPetsByStatusTest() { List<String> status = null; List<Pet> response = api.findPetsByStatus(status); }
PetApi { @Deprecated public List<Pet> findPetsByTags(List<String> tags) throws RestClientException { return findPetsByTagsWithHttpInfo(tags).getBody(); } PetApi(); @Autowired PetApi(ApiClient apiClient); ApiClient getApiClient(); void setApiClient(ApiClient apiClient); void addPet(Pet body); ResponseEntity<Void> addPe...
@Test public void findPetsByTagsTest() { List<String> tags = null; List<Pet> response = api.findPetsByTags(tags); }
PetApi { public Pet getPetById(Long petId) throws RestClientException { return getPetByIdWithHttpInfo(petId).getBody(); } PetApi(); @Autowired PetApi(ApiClient apiClient); ApiClient getApiClient(); void setApiClient(ApiClient apiClient); void addPet(Pet body); ResponseEntity<Void> addPetWithHttpInfo(Pet body); void de...
@Test public void getPetByIdTest() { Long petId = null; Pet response = api.getPetById(petId); }
PetApi { public void updatePet(Pet body) throws RestClientException { updatePetWithHttpInfo(body); } PetApi(); @Autowired PetApi(ApiClient apiClient); ApiClient getApiClient(); void setApiClient(ApiClient apiClient); void addPet(Pet body); ResponseEntity<Void> addPetWithHttpInfo(Pet body); void deletePet(Long petId, S...
@Test public void updatePetTest() { Pet body = null; api.updatePet(body); }
PetApi { public void updatePetWithForm(Long petId, String name, String status) throws RestClientException { updatePetWithFormWithHttpInfo(petId, name, status); } PetApi(); @Autowired PetApi(ApiClient apiClient); ApiClient getApiClient(); void setApiClient(ApiClient apiClient); void addPet(Pet body); ResponseEntity<Voi...
@Test public void updatePetWithFormTest() { Long petId = null; String name = null; String status = null; api.updatePetWithForm(petId, name, status); }
PetApi { public ModelApiResponse uploadFile(Long petId, String additionalMetadata, File file) throws RestClientException { return uploadFileWithHttpInfo(petId, additionalMetadata, file).getBody(); } PetApi(); @Autowired PetApi(ApiClient apiClient); ApiClient getApiClient(); void setApiClient(ApiClient apiClient); void...
@Test public void uploadFileTest() { Long petId = null; String additionalMetadata = null; File file = null; ModelApiResponse response = api.uploadFile(petId, additionalMetadata, file); }
Formatter { public static String getFormattedDate() { DateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss"); Date date = new Date(); return dateFormat.format(date); } static String getFormattedDate(); }
@Test public void testFormatter() { String dateRegex1 = "^((19|20)\\d\\d)-(0?[1-9]|1[012])-(0?[1-9]|[12][0-9]|3[01]) ([2][0-3]|[0-1][0-9]|[1-9]):[0-5][0-9]:([0-5][0-9]|[6][0])$"; String dateString = Formatter.getFormattedDate(); assertTrue(Pattern .matches(dateRegex1, dateString)); }
WebConfigurer implements ServletContextInitializer, WebServerFactoryCustomizer<WebServerFactory> { @Override public void onStartup(ServletContext servletContext) throws ServletException { if (env.getActiveProfiles().length != 0) { log.info("Web application configuration, using profiles: {}", (Object[]) env.getActivePro...
@Test public void testStartUpProdServletContext() throws ServletException { env.setActiveProfiles(JHipsterConstants.SPRING_PROFILE_PRODUCTION); webConfigurer.onStartup(servletContext); assertThat(servletContext.getAttribute(InstrumentedFilter.REGISTRY_ATTRIBUTE)).isEqualTo(metricRegistry); assertThat(servletContext.get...
WebConfigurer implements ServletContextInitializer, WebServerFactoryCustomizer<WebServerFactory> { @Override public void customize(WebServerFactory server) { setMimeMappings(server); if (jHipsterProperties.getHttp().getVersion().equals(JHipsterProperties.Http.Version.V_2_0) && server instanceof UndertowServletWebServer...
@Test public void testCustomizeServletContainer() { env.setActiveProfiles(JHipsterConstants.SPRING_PROFILE_PRODUCTION); UndertowServletWebServerFactory container = new UndertowServletWebServerFactory(); webConfigurer.customize(container); assertThat(container.getMimeMappings().get("abs")).isEqualTo("audio/x-mpeg"); ass...
WebConfigurer implements ServletContextInitializer, WebServerFactoryCustomizer<WebServerFactory> { @Bean public CorsFilter corsFilter() { UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); CorsConfiguration config = jHipsterProperties.getCors(); if (config.getAllowedOrigins() != null && !co...
@Test public void testCorsFilterOnApiPath() throws Exception { props.getCors().setAllowedOrigins(Collections.singletonList("*")); props.getCors().setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "DELETE")); props.getCors().setAllowedHeaders(Collections.singletonList("*")); props.getCors().setMaxAge(1800L); props.g...
Employee { public Integer getId() { return id; } Employee(Integer id, String name, Double salary); Integer getId(); void setId(Integer id); String getName(); void setName(String name); Double getSalary(); void setSalary(Double salary); void salaryIncrement(Double percentage); String toString(); }
@Test public void whenFindMin_thenGetMinElementFromStream() { Employee firstEmp = empList.stream() .min((e1, e2) -> e1.getId() - e2.getId()) .orElseThrow(NoSuchElementException::new); assertEquals(firstEmp.getId(), new Integer(1)); }
OAuth2AuthenticationService { public ResponseEntity<OAuth2AccessToken> authenticate(HttpServletRequest request, HttpServletResponse response, Map<String, String> params) { try { String username = params.get("username"); String password = params.get("password"); boolean rememberMe = Boolean.valueOf(params.get("rememberM...
@Test public void testAuthenticationCookies() { MockHttpServletRequest request = new MockHttpServletRequest(); request.setServerName("www.test.com"); request.addHeader("Authorization", CLIENT_AUTHORIZATION); Map<String, String> params = new HashMap<>(); params.put("username", "user"); params.put("password", "user"); pa...
OAuth2AuthenticationService { public void logout(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) { cookieHelper.clearCookies(httpServletRequest, httpServletResponse); } OAuth2AuthenticationService(OAuth2TokenEndpointClient authorizationClient, OAuth2CookieHelper cookieHelper); ResponseEn...
@Test public void testLogout() { MockHttpServletRequest request = new MockHttpServletRequest(); Cookie accessTokenCookie = new Cookie(OAuth2CookieHelper.ACCESS_TOKEN_COOKIE, ACCESS_TOKEN_VALUE); Cookie refreshTokenCookie = new Cookie(OAuth2CookieHelper.REFRESH_TOKEN_COOKIE, REFRESH_TOKEN_VALUE); request.setCookies(acce...
OAuth2AuthenticationService { public HttpServletRequest stripTokens(HttpServletRequest httpServletRequest) { Cookie[] cookies = cookieHelper.stripCookies(httpServletRequest.getCookies()); return new CookiesHttpServletRequestWrapper(httpServletRequest, cookies); } OAuth2AuthenticationService(OAuth2TokenEndpointClient au...
@Test public void testStripTokens() { MockHttpServletRequest request = createMockHttpServletRequest(); HttpServletRequest newRequest = authenticationService.stripTokens(request); CookieCollection cookies = new CookieCollection(newRequest.getCookies()); Assert.assertFalse(cookies.contains(OAuth2CookieHelper.ACCESS_TOKEN...
CookieCollection implements Collection<Cookie> { @Override public int size() { return cookieMap.size(); } CookieCollection(); CookieCollection(Cookie... cookies); CookieCollection(Collection<? extends Cookie> cookies); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override ...
@Test public void size() throws Exception { CookieCollection cookies = new CookieCollection(); Assert.assertEquals(0, cookies.size()); cookies.add(cookie); Assert.assertEquals(1, cookies.size()); }
CookieCollection implements Collection<Cookie> { @Override public boolean isEmpty() { return cookieMap.isEmpty(); } CookieCollection(); CookieCollection(Cookie... cookies); CookieCollection(Collection<? extends Cookie> cookies); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); ...
@Test public void isEmpty() throws Exception { CookieCollection cookies = new CookieCollection(); Assert.assertTrue(cookies.isEmpty()); cookies.add(cookie); Assert.assertFalse(cookies.isEmpty()); }
CookieCollection implements Collection<Cookie> { @Override public boolean contains(Object o) { if (o instanceof String) { return cookieMap.containsKey(o); } if (o instanceof Cookie) { return cookieMap.containsValue(o); } return false; } CookieCollection(); CookieCollection(Cookie... cookies); CookieCollection(Collect...
@Test public void contains() throws Exception { CookieCollection cookies = new CookieCollection(cookie); Assert.assertTrue(cookies.contains(cookie)); Assert.assertTrue(cookies.contains(COOKIE_NAME)); Assert.assertFalse(cookies.contains("yuck")); }