Java Code Examples for org.apache.commons.compress.utils.Sets

The following examples show how to use org.apache.commons.compress.utils.Sets. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@SuppressWarnings("unchecked")
@Test(expected = IllegalStateException.class)
public void deployWithMultipleRoutesAndHostOrDomainMutuallyExclusive() {
	Resource resource = new FileSystemResource("src/test/resources/demo-0.0.1-SNAPSHOT.jar");

	given(this.applicationNameGenerator.generateAppName("test-application")).willReturn("test-application-id");

	givenRequestGetApplication("test-application-id",
			Mono.error(new IllegalArgumentException()),
			Mono.just(ApplicationDetail.builder()
					.id("test-application-id")
					.name("test-application")
					.build()));

	this.deploymentProperties.setHost("route0");
	this.deploymentProperties.setDomain("test-domain");
	this.deploymentProperties.setRoutes(Sets.newHashSet("route1.test-domain", "route2.test-domain"));

	this.deployer.deploy(new AppDeploymentRequest(
			new AppDefinition("test-application", Collections.emptyMap()),
			resource,
			Collections.emptyMap()));

	fail("routes and hosts cannot be set, expect cf java client to throw an exception");
}
 
Example 2
Source Project: flink-tutorials   Source File: HeapMonitorPipelineTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testPipeline() throws Exception {

	final String alertMask = "42";

	StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

	HeapMetrics alert1 = testStats(0.42);
	HeapMetrics regular1 = testStats(0.452);
	HeapMetrics regular2 = testStats(0.245);
	HeapMetrics alert2 = testStats(0.9423);

	DataStreamSource<HeapMetrics> testInput = env.fromElements(alert1, alert2, regular1, regular2);
	HeapMonitorPipeline.computeHeapAlerts(testInput, ParameterTool.fromArgs(new String[]{"--alertMask", alertMask}))
		.addSink(new SinkFunction<HeapAlert>() {
			@Override
			public void invoke(HeapAlert value, Context context) {
				testOutput.add(value);
			}
		})
		.setParallelism(1);

	env.execute();

	assertEquals(Sets.newHashSet(HeapAlert.maskRatioMatch(alertMask, alert1),
			HeapAlert.maskRatioMatch(alertMask, alert2)), testOutput);
}
 
Example 3
@Test
public void givenMultiplePackageWithResourceFilesWhenQueryThenReturnCorrectFilenameList() {
    long currentTimeMillis = System.currentTimeMillis();
    PluginPackage serviceManagementV1PluginPackage = new PluginPackage("1", SERVICE_MANAGEMENT, "v0.1", DECOMMISSIONED, new Timestamp(currentTimeMillis - 500000), false);
    PluginPackage serviceManagementV2PluginPackage = new PluginPackage("2", SERVICE_MANAGEMENT, "v0.2", STOPPED, new Timestamp(currentTimeMillis - 400000), false);
    PluginPackage serviceManagementV3PluginPackage = new PluginPackage("3", SERVICE_MANAGEMENT, "v0.3", RUNNING, new Timestamp(currentTimeMillis - 300000), false);
    PluginPackage serviceManagementV4PluginPackage = new PluginPackage("4", SERVICE_MANAGEMENT, "v0.4", UNREGISTERED, new Timestamp(currentTimeMillis - 200000), false);
    PluginPackage cmdbPluginPackage = new PluginPackage("5", CMDB, "v1.0", REGISTERED, new Timestamp(currentTimeMillis - 100000), false);
    PluginPackage cmdbPluginPackage2 = new PluginPackage("6", CMDB, "v2.0", UNREGISTERED, new Timestamp(currentTimeMillis), false);

    PluginPackageResourceFile sm1PluginPackageResourceFile = new PluginPackageResourceFile("1", serviceManagementV1PluginPackage, SERVICE_MANAGEMENT, "v0.1", UI_ZIP, SERVICE_MANAGEMENT + "/" + "dist/sm-v1.js");
    PluginPackageResourceFile sm2PluginPackageResourceFile = new PluginPackageResourceFile("2", serviceManagementV2PluginPackage, SERVICE_MANAGEMENT, "v0.2", UI_ZIP, SERVICE_MANAGEMENT + "/" + "dist/sm-v2.js");
    PluginPackageResourceFile sm3PluginPackageResourceFile = new PluginPackageResourceFile("3", serviceManagementV3PluginPackage, SERVICE_MANAGEMENT, "v0.3", UI_ZIP, SERVICE_MANAGEMENT + "/" + "dist/sm-v3.js");
    PluginPackageResourceFile sm4PluginPackageResourceFile = new PluginPackageResourceFile("4", serviceManagementV4PluginPackage, SERVICE_MANAGEMENT, "v0.4", UI_ZIP, SERVICE_MANAGEMENT + "/" + "dist/sm-v4.js");
    PluginPackageResourceFile cmdb1PluginPackageResourceFile = new PluginPackageResourceFile("5", cmdbPluginPackage, CMDB, "v1.0", UI_ZIP, CMDB + "/" + "dist/cmdb-v1.js");
    PluginPackageResourceFile cmdb2PluginPackageResourceFile = new PluginPackageResourceFile("6", cmdbPluginPackage2, CMDB, "v2.0", UI_ZIP, CMDB + "/" + "dist/cmdb-v2.js");

    serviceManagementV1PluginPackage.setPluginPackageResourceFiles(Sets.newHashSet(sm1PluginPackageResourceFile));
    serviceManagementV2PluginPackage.setPluginPackageResourceFiles(Sets.newHashSet(sm2PluginPackageResourceFile));
    serviceManagementV3PluginPackage.setPluginPackageResourceFiles(Sets.newHashSet(sm3PluginPackageResourceFile));
    serviceManagementV4PluginPackage.setPluginPackageResourceFiles(Sets.newHashSet(sm4PluginPackageResourceFile));
    cmdbPluginPackage.setPluginPackageResourceFiles(Sets.newHashSet(cmdb1PluginPackageResourceFile));
    cmdbPluginPackage2.setPluginPackageResourceFiles(Sets.newHashSet(cmdb2PluginPackageResourceFile));

    pluginPackageRepository.saveAll(Arrays.asList(serviceManagementV1PluginPackage, serviceManagementV2PluginPackage, serviceManagementV3PluginPackage, serviceManagementV4PluginPackage, cmdbPluginPackage, cmdbPluginPackage2));

    pluginPackageResourceFileRepository.saveAll(Arrays.asList(sm1PluginPackageResourceFile, sm2PluginPackageResourceFile, sm3PluginPackageResourceFile, sm4PluginPackageResourceFile, cmdb1PluginPackageResourceFile, cmdb2PluginPackageResourceFile));

    Optional<Set<PluginPackage>> pluginPackagesOptional = pluginPackageRepository.findLatestPluginPackagesByStatusGroupByPackageName(REGISTERED, RUNNING, STOPPED);
    assertThat(pluginPackagesOptional.isPresent()).isTrue();

    Set<PluginPackage> pluginPackages = pluginPackagesOptional.get();

    assertThat(pluginPackages).hasSize(2);
    assertThat(pluginPackages.contains(serviceManagementV3PluginPackage)).isTrue();
    assertThat(pluginPackages.contains(cmdbPluginPackage)).isTrue();
    Optional<List<PluginPackageResourceFile>> pluginPackageResourceFilesOptional = pluginPackageResourceFileRepository.findPluginPackageResourceFileByPluginPackageIds(pluginPackages.stream().map(p -> p.getId()).collect(Collectors.toSet()).toArray(new String[pluginPackages.size()]));

    assertThat(pluginPackageResourceFilesOptional.isPresent()).isTrue();
    List<PluginPackageResourceFile> pluginPackageResourceFiles = pluginPackageResourceFilesOptional.get();
    assertThat(pluginPackageResourceFiles).hasSize(2);
    assertThat(pluginPackageResourceFiles.contains(sm3PluginPackageResourceFile)).isTrue();
    assertThat(pluginPackageResourceFiles.contains(cmdb1PluginPackageResourceFile)).isTrue();

}
 
Example 4
public ResilientCloudOperationExecutor withStatusesToIgnore(HttpStatus... statusesToIgnore) {
    this.additionalStatusesToIgnore = Sets.newHashSet(statusesToIgnore);
    return this;
}
 
Example 5
@SuppressWarnings("unchecked")
@Test
public void deployWithMultipleRoutes() throws IOException {
	Resource resource = new FileSystemResource("src/test/resources/demo-0.0.1-SNAPSHOT.jar");

	given(this.applicationNameGenerator.generateAppName("test-application")).willReturn("test-application-id");

	givenRequestGetApplication("test-application-id",
			Mono.error(new IllegalArgumentException()),
			Mono.just(ApplicationDetail.builder()
					.diskQuota(0)
					.id("test-application-id")
					.instances(1)
					.memoryLimit(0)
					.name("test-application")
					.requestedState("RUNNING")
					.runningInstances(0)
					.stack("test-stack")
					.build()));

	this.deploymentProperties.setBuildpack("test-buildpack");
	this.deploymentProperties.setDisk("0");
	this.deploymentProperties.setHealthCheck(ApplicationHealthCheck.NONE);
	this.deploymentProperties.setRoutes(Sets.newHashSet("route1.test-domain", "route2.test-domain"));
	this.deploymentProperties.setInstances(0);
	this.deploymentProperties.setMemory("0");

	givenRequestPushApplication(PushApplicationManifestRequest.builder()
			.manifest(ApplicationManifest.builder()
					.path(resource.getFile().toPath())
					.buildpack("test-buildpack")
					.disk(0)
					.routes(Sets.newHashSet(
							Route.builder().route("route1.test-domain").build(),
							Route.builder().route("route2.test-domain").build()
					))
					.environmentVariables(defaultEnvironmentVariables())
					.healthCheckType(ApplicationHealthCheck.NONE)
					.instances(0)
					.memory(0)
					.name("test-application-id")
					.service("test-service-2")
					.service("test-service-1")
					.build())
			.stagingTimeout(this.deploymentProperties.getStagingTimeout())
			.startupTimeout(this.deploymentProperties.getStartupTimeout())
			.build(), Mono.empty());

	String deploymentId = this.deployer.deploy(new AppDeploymentRequest(
			new AppDefinition("test-application", Collections.emptyMap()),
			resource,
			Collections.emptyMap()));

	assertThat(deploymentId, equalTo("test-application-id"));
}