src_fm_fc_ms_ff
stringlengths
43
86.8k
target
stringlengths
20
276k
JsonRpcInvoker { public <T> T get(final JsonRpcClientTransport transport, final String handle, final Class<T>... classes) { for (Class<T> clazz : classes) { typeChecker.isValidInterface(clazz); } return (T) Proxy.newProxyInstance(JsonRpcInvoker.class.getClassLoader(), classes, new InvocationHandler() { public Object in...
@Test public void testErrorWithPrimitiveData() { final String errorMessage = "some error message"; JsonObject resp = new JsonObject(); resp.addProperty("jsonrpc", "2.0"); resp.addProperty("error", errorMessage); TestInterface handle = invoker.get(getTransport(resp), "someHandler", TestInterface.class); try { handle.cal...
CrashesViewModel { public ViewState getCrashNotFoundViewState() { return new ViewState.Builder().withVisible(crashViewModels.isEmpty()).build(); } CrashesViewModel(List<CrashViewModel> crashViewModels); List<CrashViewModel> getCrashViewModels(); ViewState getCrashNotFoundViewState(); }
@Test public void shouldReturnCrashNotFoundVisibilityAsVISBILEWhenThereAreNoCrashes() throws Exception { CrashesViewModel viewModel = new CrashesViewModel(new ArrayList<CrashViewModel>()); assertThat(viewModel.getCrashNotFoundViewState().getVisibility(), is(View.VISIBLE)); } @Test public void shouldReturnCrashNotFoundV...
ViewState { public int getVisibility() { return visibility; } private ViewState(int visibility); int getVisibility(); }
@Test public void shouldReturnViewStateBasedOnVisibilityCriteria() throws Exception { assertThat(new ViewState.Builder().withVisible(true).build().getVisibility(), is(View.VISIBLE)); assertThat(new ViewState.Builder().withVisible(false).build().getVisibility(), is(View.GONE)); }
CrashAnalyzer { public Crash getAnalysis() { StringBuilder factsBuilder = new StringBuilder(); String placeOfCrash; factsBuilder.append(throwable.getLocalizedMessage()); factsBuilder.append("\n"); factsBuilder.append(stackTrace(throwable.getStackTrace())); factsBuilder.append("\n"); if (throwable.getCause() != null) { ...
@Test public void shouldBuildStackTrace() throws Exception { Throwable throwable = mock(Throwable.class); when(throwable.getLocalizedMessage()).thenReturn("Full Message"); StackTraceElement stackTraceElement1 = new StackTraceElement("Class1", "method1", "file1", 1); StackTraceElement stackTraceElement2 = new StackTrace...
CrashViewModel { public String getPlace() { String[] placeTrail = crash.getPlace().split("\\."); return placeTrail[placeTrail.length - 1]; } CrashViewModel(); CrashViewModel(Crash crash); String getPlace(); String getExactLocationOfCrash(); String getReasonOfCrash(); String getStackTrace(); String getCrashInfo(); Stri...
@Test public void shouldReturnPlaceOfCrash() throws Exception { Crash crash = mock(Crash.class); when(crash.getPlace()).thenReturn("com.singhajit.sherlock.core.Crash:20"); when(crash.getAppInfo()).thenReturn(mock(AppInfo.class)); CrashViewModel viewModel = new CrashViewModel(crash); assertThat(viewModel.getPlace(), is(...
CrashViewModel { public String getDate() { SimpleDateFormat simpleDateFormat = new SimpleDateFormat("h:mm a EEE, MMM d, yyyy"); return simpleDateFormat.format(crash.getDate()); } CrashViewModel(); CrashViewModel(Crash crash); String getPlace(); String getExactLocationOfCrash(); String getReasonOfCrash(); String getSta...
@Test public void shouldReturnDateOfCrash() throws Exception { Crash crash = mock(Crash.class); Calendar calendar = Calendar.getInstance(); calendar.set(2017, 4, 15, 10, 50, 55); when(crash.getDate()).thenReturn(calendar.getTime()); when(crash.getAppInfo()).thenReturn(mock(AppInfo.class)); CrashViewModel viewModel = ne...
CrashViewModel { public int getIdentifier() { return crash.getId(); } CrashViewModel(); CrashViewModel(Crash crash); String getPlace(); String getExactLocationOfCrash(); String getReasonOfCrash(); String getStackTrace(); String getCrashInfo(); String getDeviceManufacturer(); String getDeviceName(); String getDeviceAnd...
@Test public void shouldReturnIdentifier() throws Exception { Crash crash = mock(Crash.class); when(crash.getId()).thenReturn(1); when(crash.getAppInfo()).thenReturn(mock(AppInfo.class)); CrashViewModel viewModel = new CrashViewModel(crash); assertThat(viewModel.getIdentifier(), is(1)); }
BazelExternalIdGenerator { public List<BazelExternalId> generate(final BazelExternalIdExtractionFullRule xPathRule) { final List<BazelExternalId> projectExternalIds = new ArrayList<>(); final List<String> dependencyListQueryArgs = deriveDependencyListQueryArgs(xPathRule); Optional<String[]> rawDependencies = executeDep...
@Test public void test() throws ExecutableRunnerException { final ExecutableRunner executableRunner = Mockito.mock(ExecutableRunner.class); final String bazelExe = "notUsed"; final XPathParser xPathParser = new XPathParser(); final BazelQueryXmlOutputParser parser = new BazelQueryXmlOutputParser(xPathParser); final Fil...
MavenCodeLocationPackager { boolean isLineRelevant(final String line) { final String editableLine = line; if (!doesLineContainSegmentsInOrder(line, "[", "INFO", "]")) { return false; } final int index = indexOfEndOfSegments(line, "[", "INFO", "]"); final String trimmedLine = editableLine.substring(index); if (StringUti...
@Test public void testIsLineRelevant() { final MavenCodeLocationPackager mavenCodeLocationPackager = new MavenCodeLocationPackager(null); assertTrue(mavenCodeLocationPackager.isLineRelevant("weird garbage 3525356 [thingsINFO 346534623465] stuff")); assertTrue(mavenCodeLocationPackager.isLineRelevant("[thingsINFO 346534...
MavenCodeLocationPackager { String trimLogLevel(final String line) { final String editableLine = line; final int index = indexOfEndOfSegments(line, "[", "INFO", "]"); String trimmedLine = editableLine.substring(index); if (trimmedLine.startsWith(" ")) { trimmedLine = trimmedLine.substring(1); } return trimmedLine; } Ma...
@Test public void testTrimLogLevel() { final MavenCodeLocationPackager mavenCodeLocationPackager = new MavenCodeLocationPackager(null); String actualLine = ""; final String expectedValue = "thing"; actualLine = mavenCodeLocationPackager.trimLogLevel("weird garbage 3525356 [thingsINFO 346534623465]" + expectedValue); as...
MavenCodeLocationPackager { boolean isProjectSection(final String line) { return doesLineContainSegmentsInOrder(line, "---", "dependency", ":", "tree"); } MavenCodeLocationPackager(final ExternalIdFactory externalIdFactory); List<MavenParseResult> extractCodeLocations(final String sourcePath, final String mavenOutputTe...
@Test public void testIsProjectSection() { final MavenCodeLocationPackager mavenCodeLocationPackager = new MavenCodeLocationPackager(null); assertFalse(mavenCodeLocationPackager.isProjectSection(" ")); assertFalse(mavenCodeLocationPackager.isProjectSection(" ")); assertFalse(mavenCodeLocationPackager.isProjectSection("...
MavenCodeLocationPackager { boolean isDependencyTreeUpdates(final String line) { if (line.contains("checking for updates")) { return true; } else { return false; } } MavenCodeLocationPackager(final ExternalIdFactory externalIdFactory); List<MavenParseResult> extractCodeLocations(final String sourcePath, final String ma...
@Test public void testIsDependencyTreeUpdates() { final MavenCodeLocationPackager mavenCodeLocationPackager = new MavenCodeLocationPackager(null); assertTrue(mavenCodeLocationPackager.isDependencyTreeUpdates("artifact com.google.guava:guava:jar:15.0:compile checking for updates from")); assertTrue(mavenCodeLocationPack...
MavenCodeLocationPackager { boolean isGav(final String componentText) { final String debugMessage = String.format("%s does not look like a GAV we recognize", componentText); final String[] gavParts = componentText.split(":"); if (gavParts.length >= 4) { for (final String part : gavParts) { if (StringUtils.isBlank(part)...
@Test public void testIsGav() { final MavenCodeLocationPackager mavenCodeLocationPackager = new MavenCodeLocationPackager(null); assertFalse(mavenCodeLocationPackager.isGav(" ")); assertFalse(mavenCodeLocationPackager.isGav(" ")); assertFalse(mavenCodeLocationPackager.isGav("::::")); assertFalse(mavenCodeLocationPackag...
MavenCodeLocationPackager { int indexOfEndOfSegments(final String line, final String... segments) { int endOfSegments = -1; if (segments.length > 0) { endOfSegments = 0; } String editableLine = line; for (final String segment : segments) { final int index = editableLine.indexOf(segment); if (index == -1) { endOfSegment...
@Test public void testIndexOfEndOfSegments() { final MavenCodeLocationPackager mavenCodeLocationPackager = new MavenCodeLocationPackager(null); assertEquals(-1, mavenCodeLocationPackager.indexOfEndOfSegments("")); assertEquals(-1, mavenCodeLocationPackager.indexOfEndOfSegments("stuff and things")); assertEquals(-1, mav...
MavenCodeLocationPackager { boolean doesLineContainSegmentsInOrder(final String line, final String... segments) { Boolean lineContainsSegments = true; final int index = indexOfEndOfSegments(line, segments); if (index == -1) { lineContainsSegments = false; } return lineContainsSegments; } MavenCodeLocationPackager(final...
@Test public void testDoesLineContainSegmentsInOrder() { final MavenCodeLocationPackager mavenCodeLocationPackager = new MavenCodeLocationPackager(null); assertFalse(mavenCodeLocationPackager.doesLineContainSegmentsInOrder("")); assertFalse(mavenCodeLocationPackager.doesLineContainSegmentsInOrder("stuff and things")); ...
GoVendorExtractor { public Extraction extract(final File directory, final File vendorJsonFile) { try { final GoVendorJsonParser vendorJsonParser = new GoVendorJsonParser(externalIdFactory); final String vendorJsonContents = FileUtils.readFileToString(vendorJsonFile, StandardCharsets.UTF_8); logger.debug(vendorJsonConte...
@Test public void test() { GoVendorExtractor extractor = new GoVendorExtractor(new Gson(), new ExternalIdFactory()); Extraction extraction = extractor.extract(new File("src/test/resources/go"), new File("src/test/resources/go/vendor/vendor.json")); DependencyGraph graph = extraction.codeLocations.get(0).getDependencyGr...
GoVendorJsonParser { public DependencyGraph parseVendorJson(final Gson gson, final String vendorJsonContents) { final MutableDependencyGraph graph = new MutableMapDependencyGraph(); GoVendorJsonData vendorJsonData = gson.fromJson(vendorJsonContents, GoVendorJsonData.class); logger.trace(String.format("vendorJsonData: %...
@Test public void test() throws IOException { ExternalIdFactory externalIdFactory = new ExternalIdFactory(); GoVendorJsonParser parser = new GoVendorJsonParser(externalIdFactory); File vendorJsonFile = new File("src/test/resources/go/vendor/vendor.json"); String vendorJsonContents = FileUtils.readFileToString(vendorJso...
GopkgLockParser { public DependencyGraph parseDepLock(final String depLockContents) { final MutableDependencyGraph graph = new MutableMapDependencyGraph(); final GopkgLock gopkgLock = new Toml().read(depLockContents).to(GopkgLock.class); for (final Project project : gopkgLock.getProjects()) { if (project != null) { fin...
@Test public void gopkgParserTest() throws IOException { final GopkgLockParser gopkgLockParser = new GopkgLockParser(new ExternalIdFactory()); final String gopkgLockContents = IOUtils.toString(getClass().getResourceAsStream("/go/Gopkg.lock"), StandardCharsets.UTF_8); final DependencyGraph dependencyGraph = gopkgLockPar...
BazelVariableSubstitutor { public List<String> substitute(final List<String> origStrings) { final List<String> modifiedStrings = new ArrayList<>(origStrings.size()); for (String origString : origStrings) { modifiedStrings.add(substitute(origString)); } return modifiedStrings; } BazelVariableSubstitutor(final String baz...
@Test public void testTargetOnly() { BazelVariableSubstitutor substitutor = new BazelVariableSubstitutor(" final List<String> origArgs = new ArrayList<>(); origArgs.add("query"); origArgs.add("filter(\"@.*:jar\", deps(${detect.bazel.target}))"); final List<String> adjustedArgs = substitutor.substitute(origArgs); assert...
VndrParser { public VndrParser(final ExternalIdFactory externalIdFactory) { this.externalIdFactory = externalIdFactory; } VndrParser(final ExternalIdFactory externalIdFactory); DependencyGraph parseVendorConf(final List<String> vendorConfContents); public ExternalIdFactory externalIdFactory; }
@Test public void vndrParserTest() throws IOException { final TestUtil testUtil = new TestUtil(); final VndrParser vndrParser = new VndrParser(new ExternalIdFactory()); final String text = testUtil.getResourceAsUTF8String("/go/vendor.conf"); final List<String> vendorConfContents = Arrays.asList(text.split("\r?\n")); fi...
BitbakeListTasksParser { public Optional<String> parseTargetArchitecture(final String standardOutput) { return Arrays.stream(standardOutput.split(System.lineSeparator())) .filter(this::lineContainsArchitecture) .map(this::getArchitectureFromLine) .findFirst(); } Optional<String> parseTargetArchitecture(final String st...
@Test public void parseTargetArchitectureTest() { final TestUtil testUtil = new TestUtil(); final String listtaskOutput = testUtil.getResourceAsUTF8String("/bitbake/listtasks_output.txt"); final BitbakeListTasksParser bitbakeListTasksParser = new BitbakeListTasksParser(); final Optional<String> architecture = bitbakeLi...
GraphParserTransformer { public DependencyGraph transform(final GraphParser graphParser, final String targetArchitecture) { final Map<String, GraphNode> nodes = graphParser.getNodes(); final Map<String, GraphEdge> edges = graphParser.getEdges(); final LazyExternalIdDependencyGraphBuilder graphBuilder = new LazyExternal...
@Test public void transform() throws IOException { final GraphParserTransformer graphParserTransformer = new GraphParserTransformer(); final InputStream inputStream = new ClassPathResource("/bitbake/recipe-depends.dot").getInputStream(); final GraphParser graphParser = new GraphParser(inputStream); final DependencyGrap...
YarnListParser extends BaseYarnParser { public DependencyGraph parseYarnList(final List<String> yarnLockText, final List<String> yarnListAsList) { final MutableDependencyGraph graph = new MutableMapDependencyGraph(); final DependencyHistory history = new DependencyHistory(); final Map<String, String> yarnLockVersionMap...
@Test public void parseYarnListTest() { final List<String> designedYarnLock = new ArrayList<>(); designedYarnLock.add("async@~0.9.0:"); designedYarnLock.add(" version \"0.9.2\""); designedYarnLock.add(" resolved \"http: designedYarnLock.add(" dependencies:"); designedYarnLock.add(" minimist \"0.0.8\""); designedYarnLoc...
YarnLockParser extends BaseYarnParser { public Map<String, String> getYarnLockResolvedVersionMap(final List<String> yarnLockFileAsList) { final Map<String, String> yarnLockResolvedVersions = new HashMap<>(); final List<String> fuzzyIds = new ArrayList<>(); for (final String line : yarnLockFileAsList) { if (StringUtils....
@Test public void testThatYarnLockIsParsedCorrectlyToMap() { final List<String> yarnLockText = new ArrayList<>(); yarnLockText.add("# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY."); yarnLockText.add("# yarn lockfile v1"); yarnLockText.add(""); yarnLockText.add(""); yarnLockText.add("async@0.9.0:"); ya...
PipInspectorTreeParser { public Optional<PipParseResult> parse(final List<String> pipInspectorOutputAsList, final String sourcePath) { PipParseResult parseResult = null; final MutableDependencyGraph graph = new MutableMapDependencyGraph(); final DependencyHistory history = new DependencyHistory(); Dependency project = ...
@Test public void indendtationAndLineToNodeTest() { final List<String> pipInspectorOutput = new ArrayList<>(); pipInspectorOutput.add("projectName==projectVersionName"); pipInspectorOutput.add(" appnope==0.1.0"); pipInspectorOutput.add(" decorator==4.3.0"); pipInspectorOutput.add(" dj-database-url==0.5.0"); pipInspecto...
ClangCompileCommandParser { public String getCompilerCommand(final String origCompileCommand) { final String[] parts = origCompileCommand.trim().split("\\s+"); return parts[0]; } String getCompilerCommand(final String origCompileCommand); List<String> getCompilerArgsForGeneratingDepsMkFile(final String origCompileComm...
@Test public void testGetCompilerCmd() { ClangCompileCommandParser compileCommandParser = new ClangCompileCommandParser(); Map<String, String> optionOverrides = new HashMap<>(1); optionOverrides.put("-o", "/dev/null"); String compilerCommand = compileCommandParser.getCompilerCommand( "g++ -DDOUBLEQUOTED=\"A value for t...
ClangCompileCommandParser { public List<String> getCompilerArgsForGeneratingDepsMkFile(final String origCompileCommand, final String depsMkFilePath, final Map<String, String> optionOverrides) { logger.trace(String.format("origCompileCommand : %s", origCompileCommand)); String quotesRemovedCompileCommand = escapeQuotedW...
@Test public void testGetCompilerArgs() { ClangCompileCommandParser compileCommandParser = new ClangCompileCommandParser(); Map<String, String> optionOverrides = new HashMap<>(1); optionOverrides.put("-o", "/dev/null"); List<String> result = compileCommandParser.getCompilerArgsForGeneratingDepsMkFile( "g++ -DDOUBLEQUOT...
CodeLocationNameGenerator { public String createScanCodeLocationName(final String sourcePath, final String scanTargetPath, final String projectName, final String projectVersionName, final String prefix, final String suffix) { final String pathPiece = cleanScanTargetPath(scanTargetPath, sourcePath); final String codeLoc...
@Test public void testScanCodeLocationName() { final String expected = "hub-common-rest/target/hub-common-rest/2.5.1-SNAPSHOT scan"; final DetectFileFinder detectFileFinder = mock(DetectFileFinder.class); when(detectFileFinder.extractFinalPieceFromPath("/Users/ekerwin/Documents/source/integration/hub-common-rest")).the...
ClangExtractor { public Extraction extract(final ClangLinuxPackageManager pkgMgr, final File givenDir, final int depth, final ExtractionId extractionId, final File jsonCompilationDatabaseFile) { try { logger.info(String.format("Analyzing %s", jsonCompilationDatabaseFile.getAbsolutePath())); final File rootDir = fileFin...
@Test public void testSimple() throws ExecutableRunnerException { Assume.assumeFalse(SystemUtils.IS_OS_WINDOWS); final CompileCommand compileCommandWrapper = createCompileCommand("src/test/resources/clang/source/hello_world.cpp", "gcc hello_world.cpp", null); final Set<String> dependencyFilePaths = createDependencyFile...
CpanListParser { public DependencyGraph parse(final List<String> cpanListText, final List<String> directDependenciesText) { final Map<String, String> nameVersionMap = createNameVersionMap(cpanListText); final List<String> directModuleNames = getDirectModuleNames(directDependenciesText); final MutableDependencyGraph gra...
@Test public void parseTest() { String cpanList = "Test::More\t1.2.3" + "\n"; cpanList += "Test::Less\t1.2.4" + "\n"; cpanList += "This is an invalid line" + "\n"; cpanList += "This\t1\t1also\t1invalid" + "\n"; cpanList += "Invalid" + "\n"; final List<String> tokens = Arrays.asList(StringUtils.tokenizeToStringArray(cpa...
CpanListParser { List<String> getDirectModuleNames(final List<String> directDependenciesText) { final List<String> modules = new ArrayList<>(); for (final String line : directDependenciesText) { if (StringUtils.isBlank(line)) { continue; } if (line.contains("-->") || ((line.contains(" ... ") && line.contains("Configuri...
@Test public void getDirectModuleNamesTest() { final List<String> names = cpanListParser.getDirectModuleNames(showDepsText); assertEquals(4, names.size()); assertTrue(names.contains("ExtUtils::MakeMaker")); assertTrue(names.contains("Test::More")); assertTrue(names.contains("perl")); assertTrue(names.contains("ExtUtils...
CondaListParser { public Dependency condaListElementToDependency(final String platform, final CondaListElement element) { final String name = element.name; final String version = String.format("%s-%s-%s", element.version, element.buildString, platform); final ExternalId externalId = externalIdFactory.createNameVersionE...
@Test public void condaListElementToDependencyNodeTransformerTest() { final String platform = "linux"; final CondaListElement element = new CondaListElement(); element.name = "sampleName"; element.version = "sampleVersion"; element.buildString = "py36_0"; final Dependency dependency = condaListParser.condaListElementTo...
CondaListParser { public DependencyGraph parse(final String listJsonText, final String infoJsonText) { final Type listType = new TypeToken<ArrayList<CondaListElement>>() { }.getType(); final List<CondaListElement> condaList = gson.fromJson(listJsonText, listType); final CondaInfo condaInfo = gson.fromJson(infoJsonText,...
@Test public void smallParseTest() { final String condaInfoJson = testUtil.getResourceAsUTF8String("/conda/condaInfo.json"); final String condaListJson = testUtil.getResourceAsUTF8String("/conda/condaListSmall.json"); final DependencyGraph dependencyGraph = condaListParser.parse(condaListJson, condaInfoJson); Dependenc...
CodeLocationNameGenerator { public String createDockerScanCodeLocationName(final String dockerTarFilename, final String projectName, final String projectVersionName, final String prefix, final String suffix) { final String codeLocationTypeString = CodeLocationNameType.SCAN.toString().toLowerCase(); final List<String> f...
@Test public void testDockerScanCodeLocationName() { final String expected = "dockerTar.tar.gz/hub-common-rest/2.5.1-SNAPSHOT scan"; final DetectFileFinder detectFileFinder = mock(DetectFileFinder.class); when(detectFileFinder.extractFinalPieceFromPath("")).thenReturn("hub-common-rest"); final CodeLocationNameGenerator...
GradleReportParser { public Optional<DetectCodeLocation> parseDependencies(final File codeLocationFile) { DetectCodeLocation codeLocation = null; String projectSourcePath = ""; String projectGroup = ""; String projectName = ""; String projectVersionName = ""; boolean processingMetaData = false; final MutableDependencyG...
@Test public void testSpringFrameworkAop() throws IOException { final File file = new File("src/test/resources/gradle/spring-framework/spring_aop_dependencyGraph.txt"); final GradleReportParser gradleReportParser = new GradleReportParser(new ExternalIdFactory()); final Optional<DetectCodeLocation> result = gradleReport...
NugetInspectorPackager { public NugetParseResult createDetectCodeLocation(final File dependencyNodeFile) throws IOException { final String text = FileUtils.readFileToString(dependencyNodeFile, StandardCharsets.UTF_8); final NugetInspection nugetInspection = gson.fromJson(text, NugetInspection.class); final List<DetectC...
@Test(timeout = 5000L) public void createCodeLocationDWService() throws IOException { final File dependencyNodeFile = new File(getClass().getResource("/nuget/dwCheckApi_inspection_martin.json").getFile()); final ExternalIdFactory externalIdFactory = new ExternalIdFactory(); final NugetInspectorPackager packager = new N...
NpmLockfileParser { public NpmParseResult parse(final String sourcePath, final Optional<String> packageJsonText, final String lockFileText, final boolean includeDevDependencies) { final MutableDependencyGraph dependencyGraph = new MutableMapDependencyGraph(); logger.info("Parsing lock file text: "); logger.debug(lockFi...
@Test public void parseLockFileWithRecreatedJsonTest() { final String lockFileText = testUtil.getResourceAsUTF8String("/npm/package-lock.json"); final NpmParseResult result = npmLockfileParser.parse("source", recreatePackageJsonFromLock(lockFileText), lockFileText, true); Assert.assertEquals(result.projectName, "knocko...
CodeLocationNameGenerator { public String createBomCodeLocationName(final String detectSourcePath, final String sourcePath, final ExternalId externalId, final DetectCodeLocationType detectCodeLocationType, final String prefix, final String suffix) { final String pathPiece = FileNameUtils.relativize(detectSourcePath, so...
@Test public void testBomCodeLocationName() { final String expected = "hub-common-rest/child/group/name/version npm/bom"; final ExternalIdFactory factory = new ExternalIdFactory(); final ExternalId externalId = factory.createMavenExternalId("group", "name", "version"); final DetectFileFinder detectFileFinder = new Dete...
MavenCodeLocationPackager { public List<MavenParseResult> extractCodeLocations(final String sourcePath, final String mavenOutputText, final String targetScope, final String excludedModules, final String includedModules) { final ExcludedIncludedFilter filter = new ExcludedIncludedFilter(excludedModules, includedModules)...
@Test public void extractCodeLocationsTest() { final String mavenOutputText = testUtil.getResourceAsUTF8String("/maven/sonarStashOutput.txt"); createNewCodeLocationTest(mavenOutputText, "/maven/sonarStashCodeLocation.json"); }
MavenCodeLocationPackager { Dependency textToProject(final String componentText) { if (!isGav(componentText)) { return null; } final String[] gavParts = componentText.split(":"); final String group = gavParts[0]; final String artifact = gavParts[1]; String version; if (gavParts.length == 4) { version = gavParts[gavPart...
@Test public void testParseProject() { final MavenCodeLocationPackager mavenCodeLocationPackager = new MavenCodeLocationPackager(new ExternalIdFactory()); Dependency dependency = mavenCodeLocationPackager.textToProject("stuff:things:jar:0.0.1"); assertNotNull(dependency); dependency = mavenCodeLocationPackager.textToPr...
MavenCodeLocationPackager { ScopedDependency textToDependency(final String componentText) { if (!isGav(componentText)) { return null; } final String[] gavParts = componentText.split(":"); final String group = gavParts[0]; final String artifact = gavParts[1]; final String scope = gavParts[gavParts.length - 1]; final boo...
@Test public void testParseDependency() { final MavenCodeLocationPackager mavenCodeLocationPackager = new MavenCodeLocationPackager(new ExternalIdFactory()); ScopedDependency dependency = mavenCodeLocationPackager.textToDependency("stuff:things:jar:0.0.1:compile"); assertNotNull(dependency); dependency = mavenCodeLocat...
ProductMapper { public Product toProduct(ProductDto product) { return this.mapper.map(product, Product.class); } ProductMapper(); ProductDto toProductDto(Product product); List<ProductDto> toProductDtoList(List<Product> products); Product toProduct(ProductDto product); }
@Test public void testProductDto2JpaMapping() { ProductDto productDto = ProductDto.builder() .id("product-1") .name("product-1") .brand("brand-1") .description("description-1") .category(ImmutableList.of("one", "two")) .price(BigDecimal.TEN) .build(); Product productJpa = mapper.toProduct(productDto); softly.then(produ...
ProductMapper { public ProductDto toProductDto(Product product) { return this.mapper.map(product, ProductDto.class); } ProductMapper(); ProductDto toProductDto(Product product); List<ProductDto> toProductDtoList(List<Product> products); Product toProduct(ProductDto product); }
@Test public void testProductJpa2DtoMapping() { Product productJpa = Product.builder() .id("product-1") .name("product-1") .brand("brand-1") .description("description-1") .categories(ImmutableList.of( Category.builder().name("one").build(), Category.builder().name("two").build())) .price(BigDecimal.TEN) .build(); Produ...
OrderMapper { public OrderForm toOrderForm(OrderDto order) { return this.mapper.map(order, OrderForm.class); } OrderMapper(); OrderDto toOrderDto(OrderForm order); OrderForm toOrderForm(OrderDto order); List<OrderDto> toOrderDtoList(List<OrderForm> orders); }
@Test public void testEmptyOrderDto() { OrderDto orderDto = OrderDto.builder() .id("order-1") .userId("user-1") .status(OrderDto.Status.SUBMITTED) .build(); OrderForm orderJpa = mapper.toOrderForm(orderDto); softly.then(orderJpa.getId()).isEqualTo(orderDto.getId()); softly.then(orderJpa.getUserId()).isEqualTo(orderDto....
OrderMapper { public OrderDto toOrderDto(OrderForm order) { return this.mapper.map(order, OrderDto.class); } OrderMapper(); OrderDto toOrderDto(OrderForm order); OrderForm toOrderForm(OrderDto order); List<OrderDto> toOrderDtoList(List<OrderForm> orders); }
@Test public void testOrderJpaToOrderDto() throws IOException { OrderForm orderJpa = OrderForm.builder() .id("orderJpa-1") .userId("user-1") .status(OrderDto.Status.SUBMITTED) .items(ImmutableList.of( OrderItem.builder() .productId("product-1") .quantity(10) .build() )) .build(); OrderDto orderDto = mapper.toOrderDto(o...
UserMapper { public User toUser(UserDto user) { return this.mapper.map(user, User.class); } UserMapper(); UserDto toUserDto(User user); List<UserDto> toUserDtoList(List<User> users); User toUser(UserDto user); }
@Test public void testUserDtoMapping() { UserDto userDto = UserDto.builder() .id("user-1") .title("Mr") .givenName("Mickey") .familyName("Mouse") .email("mickey.mouse@disney.com") .bday(LocalDate.of(1928,1,1).atStartOfDay()) .build(); User userJpa = mapper.toUser(userDto); softly.then(userJpa.getId()).isEqualTo(userDto...
UserMapper { public UserDto toUserDto(User user) { return this.mapper.map(user, UserDto.class); } UserMapper(); UserDto toUserDto(User user); List<UserDto> toUserDtoList(List<User> users); User toUser(UserDto user); }
@Test public void testUserJpaMapping() { User userJpa = User.builder() .id("user-1") .title("Mr") .firstname("Mickey") .lastname("Mouse") .email("mickey.mouse@disney.com") .dob(LocalDate.of(1928,1,1)) .build(); UserDto userDto = mapper.toUserDto(userJpa); softly.then(userDto.getId()).isEqualTo(userJpa.getId()); softly....
UserRepository { public List<User> findAll() { return Collections.unmodifiableList(new ArrayList<>(mapUsers.values())); } UserRepository(); List<User> findAll(); Optional<User> findOne(String id); User save(User newUser); Optional<User> remove(String id); }
@Test public void testLoadedProducts(){ List<User> allUsers = userRepository.findAll(); log.info(name+" loaded User data = " + allUsers); assertThat(allUsers).isNotNull().hasSize(3); }
SudokuArguments { @Param(value = 1, mappedBy = Mapper.class) abstract List<List<List<List<List<List<List<Set<Set<Set<Set<Set<Set<Collection<Integer>>>>>>>>>>>>>> number(); }
@Test void testSudoku() { SudokuArguments_Parser.ParseResult parsed = new SudokuArguments_Parser().parse(new String[]{""}); assertTrue(parsed instanceof SudokuArguments_Parser.ParsingSuccess); SudokuArguments args = ((SudokuArguments_Parser.ParsingSuccess) parsed).getResult(); assertTrue(args.number().isEmpty()); }
OptionalIntegerArguments { @Option(value = "a", mnemonic = 'a', mappedBy = Mapper.class) abstract Optional<Integer> a(); }
@Test void testPresent() { OptionalIntegerArguments args = new OptionalIntegerArguments_Parser().parseOrExit(new String[]{"-a", "1"}); assertEquals(Optional.of(1), args.a()); }
AllDoublesArguments { @Param(1) abstract List<Double> positional(); }
@Test void positional() { f.assertThat("--obj=1.5", "--prim=1.5", "5.5", "3.5").succeeds( "positional", asList(5.5d, 3.5d), "listOfDoubles", emptyList(), "optionalDouble", Optional.empty(), "doubleObject", 1.5d, "primitiveDouble", 1.5d); }
CpArguments { @Option("backup") abstract Optional<Control> backup(); }
@Test void testEnum() { assertEquals(Optional.of(Control.NUMBERED), f.parse("a", "b", "--backup=NUMBERED").backup()); f.assertThat("-r", "a", "b", "--backup", "SIMPLE") .succeeds( "source", "a", "dest", "b", "recursive", true, "backup", Optional.of(Control.SIMPLE), "suffix", Optional.empty()); }
AllFloatsArguments { @Param(1) abstract List<Float> positional(); }
@Test void positional() { f.assertThat("--obj=1.5", "--prim=1.5", "5.5", "3.5").succeeds( "positional", asList(5.5f, 3.5f), "listOfFloats", emptyList(), "optionalFloat", Optional.empty(), "floatObject", 1.5f, "primitiveFloat", 1.5f); }
TarArguments { @Option(value = "x", mnemonic = 'x') abstract boolean extract(); }
@Test void testExtract() { f.assertThat("-x", "-f", "foo.tar").succeeds( "extract", true, "create", false, "verbose", false, "compress", false, "file", "foo.tar"); f.assertThat("-v", "-x", "-f", "foo.tar").succeeds( "extract", true, "create", false, "verbose", true, "compress", false, "file", "foo.tar"); }
ListIntegerArguments { @Option(value = "a", mnemonic = 'a', mappedBy = Mapper.class) abstract List<Integer> a(); }
@Test void testPresent() { ListIntegerArguments args = new ListIntegerArguments_Parser().parseOrExit(new String[]{"-a", "1"}); assertEquals(Collections.singletonList(1), args.a()); }
OptionalIntArguments { @Option(value = "a", mnemonic = 'a', mappedBy = Mapper.class) abstract OptionalInt a(); }
@Test void testPresent() { OptionalIntArguments args = new OptionalIntArguments_Parser().parseOrExit(new String[]{"-a", "1"}); assertEquals(OptionalInt.of(1), args.a()); }
Main { public static void main(String[] arguments) { Arguments args = new Main_Arguments_Parser().parseOrExit(arguments); System.out.println("The file '" + args.file() + "' was provided and verbosity is set to '" + args.verbose() + "'."); } static void main(String[] arguments); }
@Test void testMain() { String[] argv = new String[]{"-v", "-f", "file.txt"}; Main.Arguments args = new Main_Arguments_Parser().parseOrExit(argv); assertEquals("file.txt", args.file()); assertTrue(args.verbose()); }
OptionalIntArgumentsOptional { @Option(value = "a", mnemonic = 'a', mappedBy = Mapper.class) abstract OptionalInt a(); }
@Test void testPresent() { OptionalIntArgumentsOptional args = new OptionalIntArgumentsOptional_Parser().parseOrExit(new String[]{"-a", "1"}); assertEquals(OptionalInt.of(1), args.a()); } @Test void testAbsent() { OptionalIntArgumentsOptional args = new OptionalIntArgumentsOptional_Parser().parseOrExit(new String[]{});...
AllLongsArguments { @Param(1) abstract List<Long> positional(); }
@Test void positional() { f.assertThat("--obj=1", "--prim=1", "5", "3").succeeds( "positional", asList(5L, 3L), "listOfLongs", emptyList(), "optionalLong", Optional.empty(), "longObject", 1L, "primitiveLong", 1L); }
VariousArguments { @Option("bigDecimal") abstract BigDecimal bigDecimal(); }
@Test void bigDecimal() { VariousArguments_Parser.ParseResult parsed = new VariousArguments_Parser().parse(new String[]{ "--bigDecimal", "3.14159265358979323846264338327950288419716939937510", "--bigInteger", "60221407600000000000000", "--path", "/home", "--localDate", "2001-02-01", "--uri", "http: "--pattern", "^[abc]...
AllIntegersArguments { @Option("opt") abstract Optional<Integer> optionalInteger(); }
@Test void optionalInteger() { f.assertThat("--opt", "1", "--obj=1", "--prim=1").succeeds( "positional", emptyList(), "listOfIntegers", emptyList(), "optionalInteger", Optional.of(1), "integer", 1, "primitiveInt", 1); }
AllIntegersArguments { @Param(1) abstract List<Integer> positional(); }
@Test void positional() { f.assertThat("--obj=1", "--prim=1", "5", "3").succeeds( "positional", asList(5, 3), "listOfIntegers", emptyList(), "optionalInteger", Optional.empty(), "integer", 1, "primitiveInt", 1); }
Optionalish { static Optional<Optionalish> unwrap(TypeMirror type, TypeTool tool) { Optional<Optionalish> optionalPrimtive = getOptionalPrimitive(type, tool); if (optionalPrimtive.isPresent()) { return optionalPrimtive; } return tool.unwrap(Optional.class, type) .map(wrapped -> new Optionalish(p -> CodeBlock.of("$N", p...
@Test void testLiftPrimitiveInt() { EvaluatingProcessor.source().run((elements, types) -> { TypeMirror primitiveInt = types.getPrimitiveType(TypeKind.INT); Optional<Optionalish> opt = Optionalish.unwrap(primitiveInt, new TypeTool(elements, types)); assertFalse(opt.isPresent()); }); } @Test void testLiftString() { Evalu...
ReferenceTool { public ReferencedType<E> getReferencedType() { return resolver.typecheck(referencedClass, Supplier.class) .fold(this::handleNotSupplier, this::handleSupplier); } ReferenceTool(ExpectedType<E> expectedType, Function<String, ValidationException> errorHandler, TypeTool tool, TypeElement referencedClass); R...
@Test void simpleTest() { EvaluatingProcessor.source( "import java.util.List;", "import java.util.function.Supplier;", "import java.util.function.Function;", "", "class Mapper<AA1, AA2> implements A<AA1, AA2> { public Function<AA1, List<AA2>> get() { return null; } }", "interface A<BB1, BB2> extends B<BB1, List<BB2>> {...
Resolver { <E> Either<TypecheckFailure, List<? extends TypeMirror>> typecheck(TypeElement dog, Class<E> animal) { List<ImplementsRelation> hierarchy = new HierarchyUtil(tool).getHierarchy(dog); List<ImplementsRelation> path = findPath(hierarchy, animal); if (path.isEmpty()) { return left(nonFatal("not a " + animal.getC...
@Test void testTypecheckSuccess() { EvaluatingProcessor.source( "package test;", "", "import java.util.function.Supplier;", "", "interface StringSupplier extends Supplier<String> { }", "", "abstract class Foo implements StringSupplier { }" ).run("Mapper", (elements, types) -> { TypeTool tool = new TypeTool(elements, ty...
CollectorClassValidator { CollectorInfo getCollectorInfo() { commonChecks(collectorClass); checkNotAbstract(collectorClass); ReferencedType<Collector> collectorType = new ReferenceTool<>(COLLECTOR, errorHandler, tool, collectorClass) .getReferencedType(); TypeMirror inputType = collectorType.typeArguments().get(0); Typ...
@Test void simpleTest() { EvaluatingProcessor.source( "import java.util.Set;", "import java.util.function.Supplier;", "import java.util.stream.Collector;", "import java.util.stream.Collectors;", "", "class ToSetCollector<E> implements Supplier<Collector<E, ?, Set<E>>> {", " public Collector<E, ?, Set<E>> get() {", " re...
ExtremelySimpleArguments { @Param(value = 1) abstract int hello(); }
@Test void simpleTest() { assertEquals(1, f.parse("1").hello()); }
MapperClassValidator { public Either<String, CodeBlock> getMapExpr() { commonChecks(mapperClass); checkNotAbstract(mapperClass); ReferencedType<Function> functionType = new ReferenceTool<>(FUNCTION, errorHandler, tool, mapperClass).getReferencedType(); TypeMirror inputType = functionType.typeArguments().get(0); TypeMir...
@Test void simpleTest() { EvaluatingProcessor.source( "import java.util.List;", "import java.util.function.Supplier;", "import java.util.function.Function;", "", "class Mapper<AA1, AA2> implements A<AA1, AA2> { public Function<AA1, List<AA2>> get() { return null; } }", "interface A<BB1, BB2> extends B<BB1, List<BB2>> {...
TypevarMapping { public TypeMirror get(String key) { return map.get(key); } TypevarMapping(Map<String, TypeMirror> map, TypeTool tool); Set<Map.Entry<String, TypeMirror>> entries(); TypeMirror get(String key); Either<TypecheckFailure, TypeMirror> substitute(TypeMirror input); Either<TypecheckFailure, DeclaredType> subs...
@Test void unifyTest() { EvaluatingProcessor.source( "import java.util.Set;", "", "abstract class Foo { abstract <E> Set<E> getSet(); }" ).run((elements, types) -> { TypeTool tool = new TypeTool(elements, types); TypeElement set = elements.getTypeElement("java.util.Set"); TypeElement string = elements.getTypeElement("j...
TypevarMapping { public Either<TypecheckFailure, TypeMirror> substitute(TypeMirror input) { if (input.getKind() == TypeKind.TYPEVAR) { return right(map.getOrDefault(input.toString(), input)); } if (input.getKind() == TypeKind.ARRAY) { return right(input); } return substitute(input.accept(AS_DECLARED, null)) .map(Functi...
@Test void substituteTest() { EvaluatingProcessor.source().run((elements, types) -> { TypeTool tool = new TypeTool(elements, types); TypeElement string = elements.getTypeElement("java.lang.String"); TypevarMapping mapping = new TypevarMapping(Collections.emptyMap(), tool); Either<TypecheckFailure, TypeMirror> substitut...
CustomCollectorArguments { @Option(value = "H", mnemonic = 'H', collectedBy = MyStringCollector.class) abstract Set<String> strings(); }
@Test void testNoMapper() { CustomCollectorArguments parsed = f.parse( "-H", "A", "-H", "A", "-H", "HA"); assertEquals(new HashSet<>(asList("A", "HA")), parsed.strings()); }
CustomCollectorArguments { @Option(value = "B", mnemonic = 'B', collectedBy = MyIntegerCollector.class) abstract Set<Integer> integers(); }
@Test void testBuiltinMapper() { CustomCollectorArguments parsed = f.parse( "-B", "1", "-B", "1", "-B", "2"); assertEquals(new HashSet<>(asList(1, 2)), parsed.integers()); }
CustomCollectorArguments { @Option( value = "M", mnemonic = 'M', mappedBy = CustomBigIntegerMapper.class, collectedBy = ToSetCollector.class) abstract Set<BigInteger> bigIntegers(); }
@Test void testCustomMapper() { CustomCollectorArguments parsed = f.parse( "-M", "0x5", "-M", "0xA", "-M", "10"); assertEquals(Stream.of(5L, 10L).map(BigInteger::valueOf).collect(toSet()), parsed.bigIntegers()); }
CustomCollectorArguments { @Option(value = "K", mnemonic = 'K', collectedBy = ToSetCollector.class) abstract Set<Giddy> moneySet(); }
@Test void testCustomEnum() { CustomCollectorArguments parsed = f.parse( "-K", "SOME", "-K", "NONE"); assertEquals(Stream.of( CustomCollectorArguments.Giddy.SOME, CustomCollectorArguments.Giddy.NONE).collect(toSet()), parsed.moneySet()); }
CustomCollectorArguments { @Option( value = "T", mnemonic = 'T', mappedBy = MapEntryTokenizer.class, collectedBy = ToMapCollector.class) abstract Map<String, LocalDate> dateMap(); }
@Test void testMap() { CustomCollectorArguments parsed = f.parse( "-T", "A:2004-11-11", "-T", "B:2018-11-12"); assertEquals(LocalDate.parse("2004-11-11"), parsed.dateMap().get("A")); assertEquals(LocalDate.parse("2018-11-12"), parsed.dateMap().get("B")); }
ComplicatedMapperArguments { @Option( value = "number", mappedBy = Mapper.class) abstract Integer number(); }
@Test void number() { ComplicatedMapperArguments parsed = f.parse( "--number", "12", "--numbers", "3", "--numbers", "oops"); assertEquals(1, parsed.number().intValue()); assertEquals(2, parsed.numbers().size()); assertEquals(Integer.valueOf(3), parsed.numbers().get(0).get()); assertThrows(NumberFormatException.class, (...
AdditionArguments { final int sum() { return a() + b() + c().orElse(0); } }
@Test void dashesIgnored() { f.assertThat("--", "1", "-2", "3").satisfies(e -> e.sum() == 2); f.assertThat("--", "-1", "-2", "-3").satisfies(e -> e.sum() == -6); f.assertThat("--", "-1", "-2", "3").satisfies(e -> e.sum() == 0); f.assertThat("--", "-1", "-2").satisfies(e -> e.sum() == -3); }
CustomStringSpanName implements QuerySpanNameProvider { CustomStringSpanName(String customString) { if (customString == null) { this.customString = "execute"; } else { this.customString = customString; } } CustomStringSpanName(String customString); @Override String querySpanName(String query); static Builder newBuilder...
@Test public void customStringSpanNameTest() { QuerySpanNameProvider customStringSpanName = CustomStringSpanName.newBuilder().build(); assertEquals("execute", customStringSpanName.querySpanName("SELECT * FROM test.table_name;")); customStringSpanName = CustomStringSpanName.newBuilder().build(null); assertEquals("execut...
PrefixedFullQuerySpanName implements QuerySpanNameProvider { PrefixedFullQuerySpanName(String prefix) { if (prefix == null || prefix.equals("")) { this.prefix = ""; } else { this.prefix = prefix + ": "; } } PrefixedFullQuerySpanName(String prefix); @Override String querySpanName(String query); static Builder newBuilder...
@Test public void prefixedFullQuerySpanNameTest() { QuerySpanNameProvider fullQuerySpanName = PrefixedFullQuerySpanName.newBuilder().build(); assertEquals("Cassandra: SELECT * FROM test.table_name;", fullQuerySpanName.querySpanName("SELECT * FROM test.table_name;")); assertEquals("Cassandra: N/A", fullQuerySpanName.que...
FullQuerySpanName implements QuerySpanNameProvider { FullQuerySpanName() { } FullQuerySpanName(); @Override String querySpanName(String query); static Builder newBuilder(); }
@Test public void fullQuerySpanNameTest() { QuerySpanNameProvider fullQuerySpanName = FullQuerySpanName.newBuilder().build(); assertEquals("SELECT * FROM test.table_name;", fullQuerySpanName.querySpanName("SELECT * FROM test.table_name;")); assertEquals("N/A", fullQuerySpanName.querySpanName("")); assertEquals("N/A", f...
GuavaCompatibilityUtil { static boolean isGuavaCompatibilityFound() { return INSTANCE.isGuavaCompatibilityFound; } private GuavaCompatibilityUtil(); }
@Test public void isGuavaCompatibilityFound() { assertTrue(GuavaCompatibilityUtil.isGuavaCompatibilityFound()); }
LiveFrameRateMonitor implements IFeedRtcp { @Override public void feed(JFGMsgVideoRtcp rtcp) { Log.d("rtcp", "此消息在smartcall已有打印,无需再打印.rtcp:" + rtcp.frameRate); badFrameCount = rtcp.frameRate == 0 ? ++badFrameCount : 0; if (monitorListener == null) return; boolean isFrameFailed = badFrameCount >= FAILED_TARGET; boolean ...
@Test public void feed() throws Exception { feedRtcp = new LiveFrameRateMonitor(); feedRtcp.setMonitorListener(this); System.out.println(feedRtcp); new Thread(() -> { for (int i = 0; i < 100; i++) { JFGMsgVideoRtcp rtcp = new JFGMsgVideoRtcp(); rtcp.frameRate = new Random().nextInt(4); try { Thread.sleep(10); } catch (...
HomeMinePresenterImpl extends AbstractFragmentPresenter<HomeMineContract.View> implements HomeMineContract.Presenter { @Override public void start() { super.start(); addSubscription(getAccountBack()); addSubscription(loginInMe()); } HomeMinePresenterImpl(HomeMineContract.View view); @Override void start(); @Override vo...
@Test public void testStart() throws Exception { HomeMinePresenterImpl homeMinePresenter = Mockito.mock(HomeMinePresenterImpl.class); assertTrue(homeMinePresenter.createRandomName().contains("d")); }
HomeMinePresenterImpl extends AbstractFragmentPresenter<HomeMineContract.View> implements HomeMineContract.Presenter { @Override public void stop() { super.stop(); } HomeMinePresenterImpl(HomeMineContract.View view); @Override void start(); @Override void stop(); @Override void portraitBlur(Bitmap bitmap); @Override St...
@Test public void testStop() throws Exception { }
HomeMinePresenterImpl extends AbstractFragmentPresenter<HomeMineContract.View> implements HomeMineContract.Presenter { @Override public void portraitBlur(Bitmap bitmap) { AppLogger.e("需要在io线程操作."); Observable.just(bitmap) .subscribeOn(Schedulers.io()) .map(b -> { if (b == null) { b = BitmapFactory.decodeResource(mView....
@Test public void testPortraitBlur() throws Exception { }
HomeMinePresenterImpl extends AbstractFragmentPresenter<HomeMineContract.View> implements HomeMineContract.Presenter { @Override public String createRandomName() { String[] firtPart = {"a", "isFriend", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l" , "m", "n", "o", "p", "q", "r", "account", "t", "u", "v", "w", "x", "...
@Test public void testCreateRandomName() throws Exception { }
TimeUtils { public static long getTodayStartTime() { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); return calendar.getTimeInMillis(); } static String getMM_SS(long time); static String getYHM(long time); static Str...
@Test public void getTodayStartTime() throws Exception { }
TimeUtils { public static long getTodayEndTime() { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.HOUR_OF_DAY, 23); calendar.set(Calendar.MINUTE, 59); calendar.set(Calendar.SECOND, 59); return calendar.getTimeInMillis(); } static String getMM_SS(long time); static String getYHM(long time); static St...
@Test public void getTodayEndTime() throws Exception { }
TimeUtils { public static long getSpecificDayEndTime(long time) { Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(time); calendar.set(Calendar.HOUR_OF_DAY, 23); calendar.set(Calendar.MINUTE, 59); calendar.set(Calendar.SECOND, 59); return calendar.getTimeInMillis(); } static String getMM_SS(long ti...
@Test public void getSpecificDayEndTime() throws Exception { }
TimeUtils { public static long getSpecificDayStartTime(long time) { Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(time); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); return calendar.getTimeInMillis(); } static String getMM_SS(long tim...
@Test public void getSpecificDayStartTime() throws Exception { System.out.println("" + TimeUtils.getSpecificDayStartTime(1490410868253L)); long result = 1490371200253L + 24 * 3600 * 1000L; System.out.println(result); }
TimeUtils { public static String getMediaPicTimeInString(final long time) { boolean isSameYear = sameYear(System.currentTimeMillis(), time); if (isSameYear) { return getSimpleDateFormat_2.get().format(new Date(time)); } else { return getSimpleDateFormat_3.get().format(new Date(time)); } } static String getMM_SS(long t...
@Test public void getMediaPicTimeInString() throws Exception { }
TimeUtils { public static String getMediaVideoTimeInString(final long time) { return getSimpleDateFormatVideo.get().format(new Date(time)); } static String getMM_SS(long time); static String getYHM(long time); static String getHistoryTime(long timeInLong); static String getHistoryTime1(long timeInLong); static String ...
@Test public void getMediaVideoTimeInString() throws Exception { }
LiveFrameRateMonitor implements IFeedRtcp { @Override public void stop() { preStatus = false; badFrameCount = 0; } @Override void feed(JFGMsgVideoRtcp rtcp); @Override void stop(); void setMonitorListener(MonitorListener monitorListener); }
@Test public void stop() throws Exception { }
TimeUtils { public static String getTodayString() { return new SimpleDateFormat("yyyy.MM.dd", Locale.getDefault()) .format(new Date(System.currentTimeMillis())); } static String getMM_SS(long time); static String getYHM(long time); static String getHistoryTime(long timeInLong); static String getHistoryTime1(long timeI...
@Test public void getTodayString() throws Exception { }
TimeUtils { public static String getDayString(long time) { return new SimpleDateFormat("yyyy.MM.dd", Locale.getDefault()) .format(new Date(time)); } static String getMM_SS(long time); static String getYHM(long time); static String getHistoryTime(long timeInLong); static String getHistoryTime1(long timeInLong); static ...
@Test public void getDayString() throws Exception { }
TimeUtils { public static String getUptime(long time) { if (time == 0) return ContextUtils.getContext().getString(R.string.STANBY_TIME, 0, 0, 0); time = System.currentTimeMillis() / 1000 - time; int temp = (int) time / 60; int minute = temp % 60; temp = temp / 60; int hour = temp % 24; temp = temp / 24; int day = temp;...
@Test public void testGetUptime() throws Exception { long time = System.currentTimeMillis() / 1000 - RandomUtils.getRandom(50) * 1000; time = 0; int temp = (int) time / 60; int minute = temp % 60; temp = temp / 60; int hour = temp % 24; temp = temp / 24; int day = temp; if (day > 0 && hour > 0) { System.out.println(Str...
TimeUtils { public static String getDayInMonth(long time) { Calendar instance = Calendar.getInstance(); instance.setTimeInMillis(time); int i = instance.get(Calendar.DAY_OF_MONTH); return i + ""; } static String getMM_SS(long time); static String getYHM(long time); static String getHistoryTime(long timeInLong); static...
@Test public void getDayInMonth() throws Exception { }
TimeUtils { public static String getMM_DD(long time) { return new SimpleDateFormat("MM月dd日", Locale.getDefault()) .format(new Date(time)); } static String getMM_SS(long time); static String getYHM(long time); static String getHistoryTime(long timeInLong); static String getHistoryTime1(long timeInLong); static String g...
@Test public void getMM_DD() throws Exception { }
TimeUtils { public static String getHH_MM(long time) { return getSimpleDateFormatHHMM.get().format(new Date(time)); } static String getMM_SS(long time); static String getYHM(long time); static String getHistoryTime(long timeInLong); static String getHistoryTime1(long timeInLong); static String getLiveTime(long timeInL...
@Test public void getHH_MM() throws Exception { }
TimeUtils { public static String getHH_MM_Remain(long timeMs) { int totalMinutes = (int) (timeMs / 1000 / 60); int minutes = totalMinutes % 60; int hours = totalMinutes / 60; String str_hour = hours > 9 ? "" + hours : "0" + hours; String str_minute = minutes > 9 ? "" + minutes : "0" + minutes; return str_hour + ":" + s...
@Test public void getHH_MM_Remain() throws Exception { }