public Optional<SupervisorSpec> getSupervisorSpec(String id) { Pair<Supervisor, SupervisorSpec> supervisor = supervisors.get(id); return supervisor == null ? Optional.absent() : Optional.fromNullable(supervisor.rhs); }
@Override protected boolean isRowNumberCondition(final List<SelectItem> items, final String columnLabel) { Optional<String> rowNumberAlias = Optional.absent(); for (SelectItem each : items) { if (each.getAlias().isPresent() && "rownum".equalsIgnoreCase(each.getExpression())) { rowNumberAlias = each.getAlias(); break; } } return "rownum".equalsIgnoreCase(columnLabel) || columnLabel.equalsIgnoreCase(rowNumberAlias.orNull()); }
/** * If a {@code desiredType} is specified, returns true only if the {@code actualType} is * identical. Otherwise, returns true as long as {@code actualType} is present. */ private static boolean matchesType( Optional<PublicSuffixType> desiredType, Optional<PublicSuffixType> actualType) { return desiredType.isPresent() ? desiredType.equals(actualType) : actualType.isPresent(); }
public void testListWhenResponseIs404() throws Exception { HttpResponse listResponse = HttpResponse.builder().statusCode(404).build(); EC2Api apiWhenDontExist = requestSendsResponse( list, listResponse); assertEquals(apiWhenDontExist.getTagApi().get().list().toSet(), ImmutableSet.of()); }
@Test public void testFlattenedAndNestedOrcConfig() throws Exception { String testConfFilePath = "convertibleHiveDatasetTest/flattenedAndNestedOrc.conf"; Config config = ConfigFactory.parseResources(testConfFilePath).getConfig("hive.conversion.avro"); ConvertibleHiveDataset cd = createTestConvertibleDataset(config); Assert.assertEquals(cd.getDestFormats(), ImmutableSet.of("flattenedOrc", "nestedOrc")); Assert.assertTrue(cd.getConversionConfigForFormat("flattenedOrc").isPresent()); Assert.assertTrue(cd.getConversionConfigForFormat("nestedOrc").isPresent()); validateFlattenedConfig(cd.getConversionConfigForFormat("flattenedOrc").get()); validateNestedOrc(cd.getConversionConfigForFormat("nestedOrc").get()); }
public void testListSecurityGroupsWhenReponseIs404IsEmpty() throws Exception { HttpRequest listListSecurityGroups = HttpRequest.builder().method("GET").endpoint( URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-groups")).headers( ImmutableMultimap.<String, String> builder().put("Accept", "application/json").put("X-Auth-Token", authToken).build()).build(); HttpResponse listListSecurityGroupsResponse = HttpResponse.builder().statusCode(404).build(); NovaApi apiWhenNoSecurityGroupsExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, listListSecurityGroups, listListSecurityGroupsResponse); assertTrue(apiWhenNoSecurityGroupsExist.getSecurityGroupExtensionForZone("az-1.region-a.geo-1").get() .list().isEmpty()); }
@Test(dependsOnMethods = "testSetupAndSubmitApplication") public void testGetReconnectableApplicationId() throws Exception { // Assert to check if cluster was created correctly by trying to reconnect to it Assert.assertEquals(this.gobblinAwsClusterLauncher.getReconnectableClusterId().get(), this.clusterId); }
@Test public void testBuildClusterWorkerCommand() { final String script = CloudInitScriptBuilder.buildClusterWorkerCommand(this.clusterName, this.nfsParentDir, this.sinkLogRootDir, this.awsConfDir, this.appWorkDir, this.masterPublicIp, this.workerS3ConfUri, this.workerS3ConfFiles, this.workerS3JarsUri, this.workerS3JarFiles, this.workerJarsDir, this.workerJvmMemory, Optional.<String>absent(), gobblinVersion); final String decodedScript = new String(Base64.decodeBase64(script)); Assert.assertEquals(decodedScript, this.expectedWorkerCloudInitScript, "Worker launcher cloud-init script not built as expected"); }
private ExpressionSegment extractPropertyExpressionSegment(final ParserRuleContext expressionNode) { ParserRuleContext columnNode = (ParserRuleContext) expressionNode.getChild(0); Optional<ColumnSegment> columnSegment = new ColumnSegmentExtractor().extract(columnNode); Preconditions.checkState(columnSegment.isPresent()); return new PropertyExpressionSegment(columnSegment.get().getName(), columnSegment.get().getOwner().orNull(), columnNode.getStart().getStartIndex(), columnNode.getStop().getStopIndex()); }
@Test public void testsecurityGroupNamesIterable() { NovaTemplateOptions options = new NovaTemplateOptions(); options.securityGroupNames(ImmutableSet.of("group1", "group2")); assertEquals(options.getSecurityGroupNames(), Optional.of(ImmutableSet.of("group1", "group2"))); }
@Test public void testGetCodecFactoryIgnoresCase() { CodecFactory codecFactory = WriterUtils.getCodecFactory(Optional.of("SNAPPY"), Optional.<String>absent()); Assert.assertEquals(codecFactory.toString(), "snappy"); codecFactory = WriterUtils.getCodecFactory(Optional.of("snappy"), Optional.<String>absent()); Assert.assertEquals(codecFactory.toString(), "snappy"); } }
public void testPresentInstances_somePresent() { List<Optional<String>> optionals = ImmutableList.of(Optional.of("a"), Optional.<String>absent(), Optional.of("c")); assertThat(Optional.presentInstances(optionals)).containsExactly("a", "c").inOrder(); }
@GwtIncompatible // weak references private WeakReference<?> doTestClassUnloading() throws Exception { URLClassLoader shadowLoader = new URLClassLoader(getClassPathUrls(), null); @SuppressWarnings("unchecked") Class<TestEnum> shadowTestEnum = (Class<TestEnum>) Class.forName(TestEnum.class.getName(), false, shadowLoader); assertNotSame(shadowTestEnum, TestEnum.class); // We can't write Set<TestEnum> because that is a Set of the TestEnum from the original // ClassLoader. Set<Object> shadowConstants = new HashSet<>(); for (TestEnum constant : TestEnum.values()) { Optional<TestEnum> result = Enums.getIfPresent(shadowTestEnum, constant.name()); assertThat(result).isPresent(); shadowConstants.add(result.get()); } assertEquals(ImmutableSet.<Object>copyOf(shadowTestEnum.getEnumConstants()), shadowConstants); Optional<TestEnum> result = Enums.getIfPresent(shadowTestEnum, "blibby"); assertThat(result).isAbsent(); return new WeakReference<>(shadowLoader); }
@Test public void testInvalidFormat() throws Exception { Config config = ConfigFactory.parseMap(ImmutableMap.<String, String>of("destinationFormats", "flattenedOrc,nestedOrc")); ConvertibleHiveDataset cd = createTestConvertibleDataset(config); Assert.assertFalse(cd.getConversionConfigForFormat("invalidFormat").isPresent()); }