Java Code Examples for org.eclipse.che.commons.lang.Pair#of()
The following examples show how to use
org.eclipse.che.commons.lang.Pair#of() .
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
Source File: EnvVarEnvironmentProvisionerTest.java From che with Eclipse Public License 2.0 | 6 votes |
@Test public void shouldNotRemoveExistingEnvVarsWithDifferentNames() throws Exception { // given EnvVarEnvironmentProvisioner provisioner = new EnvVarEnvironmentProvisioner(singleton(provider1)); Pair<String, String> existingEnvVar = Pair.of("existingEnvVar", "some-value"); machine1Env.put(existingEnvVar.first, existingEnvVar.second); Pair<String, String> envVar1 = Pair.of("env1", "value1"); when(provider1.get(any(RuntimeIdentity.class))).thenReturn(envVar1); // when provisioner.provision(RUNTIME_IDENTITY, internalEnvironment); // then assertEquals( ImmutableMap.of(existingEnvVar.first, existingEnvVar.second, envVar1.first, envVar1.second), machine1Env); }
Example 2
Source File: EnvVarEnvironmentProvisionerTest.java From che with Eclipse Public License 2.0 | 6 votes |
@Test public void shouldAddAllEnvVarsToAllContainers() throws Exception { // given EnvVarEnvironmentProvisioner provisioner = new EnvVarEnvironmentProvisioner(ImmutableSet.of(provider1, provider2)); Pair<String, String> envVar1 = Pair.of("env1", "value1"); Pair<String, String> envVar2 = Pair.of("env2", "value2"); ImmutableMap<String, String> envVarsFromProviders = ImmutableMap.of( envVar1.first, envVar1.second, envVar2.first, envVar2.second); when(provider1.get(any(RuntimeIdentity.class))).thenReturn(envVar1); when(provider2.get(any(RuntimeIdentity.class))).thenReturn(envVar2); // when provisioner.provision(RUNTIME_IDENTITY, internalEnvironment); // then assertEquals(machine1Env, envVarsFromProviders); assertEquals(machine2Env, envVarsFromProviders); }
Example 3
Source File: JpaFactoryDao.java From che with Eclipse Public License 2.0 | 6 votes |
@Override @Transactional(rollbackOn = {ServerException.class}) public Page<FactoryImpl> getByUser(String userId, int maxItems, long skipCount) throws ServerException { requireNonNull(userId); final Pair<String, String> factoryCreator = Pair.of("creator.userId", userId); try { long totalCount = countFactoriesByAttributes(singletonList(factoryCreator)); return new Page<>( getFactoriesByAttributes(maxItems, skipCount, singletonList(factoryCreator)), skipCount, maxItems, totalCount); } catch (RuntimeException ex) { throw new ServerException(ex.getMessage(), ex); } }
Example 4
Source File: SignaturePublicKeyEnvProvider.java From che with Eclipse Public License 2.0 | 6 votes |
@Override public Pair<String, String> get(RuntimeIdentity runtimeIdentity) throws InfrastructureException { try { return Pair.of( SIGNATURE_PUBLIC_KEY_ENV, new String( Base64.getEncoder() .encode( keyManager .getOrCreateKeyPair(runtimeIdentity.getWorkspaceId()) .getPublic() .getEncoded()))); } catch (SignatureKeyManagerException e) { throw new InfrastructureException( "Signature key pair for machine authentication cannot be retrieved. Reason: " + e.getMessage()); } }
Example 5
Source File: GitConfigProvisioner.java From che with Eclipse Public License 2.0 | 5 votes |
private Pair<String, String> getUserFromPreferences() throws ServerException, JsonSyntaxException { String preferenceJson = getPreferenceJson(PREFERENCES_KEY_FILTER); Map<String, Object> preferences = getMapFromJsonObject(preferenceJson); String name = getStringValueOrNull(preferences, GIT_USER_NAME_PROPERTY); String email = getStringValueOrNull(preferences, GIT_USER_EMAIL_PROPERTY); return isNullOrEmpty(name) && isNullOrEmpty(email) ? null : Pair.of(name, email); }
Example 6
Source File: ProfileMapperTest.java From codenvy with Eclipse Public License 1.0 | 5 votes |
@Test public void testMappingFromLdapAttributesToProfile() throws Exception { final LdapEntry entry = new LdapEntry("uid=user123,dc=codenvy,dc=com"); entry.addAttribute(new LdapAttribute("uid", "user123")); entry.addAttribute(new LdapAttribute("cn", "name")); entry.addAttribute(new LdapAttribute("mail", "[email protected]")); entry.addAttribute(new LdapAttribute("sn", "LastName")); entry.addAttribute(new LdapAttribute("givenName", "FirstName")); entry.addAttribute(new LdapAttribute("telephoneNumber", "0123456789")); @SuppressWarnings("unchecked") // all the values are strings final ProfileMapper profileMapper = new ProfileMapper( "uid", new Pair[] { Pair.of("lastName", "sn"), Pair.of("firstName", "givenName"), Pair.of("phone", "telephoneNumber") }); final ProfileImpl profile = profileMapper.apply(entry); assertEquals( profile, new ProfileImpl( "user123", ImmutableMap.of( "lastName", "LastName", "firstName", "FirstName", "phone", "0123456789"))); }
Example 7
Source File: MachineTokenEnvVarProvider.java From che with Eclipse Public License 2.0 | 5 votes |
@Override public Pair<String, String> get(RuntimeIdentity runtimeIdentity) throws MachineTokenException { return Pair.of( MACHINE_TOKEN, machineTokenProvider.getToken( runtimeIdentity.getOwnerId(), runtimeIdentity.getWorkspaceId())); }
Example 8
Source File: DTOHelper.java From che with Eclipse Public License 2.0 | 5 votes |
/** Extract field name from the setter method */ public static Pair<String, String> getSetterFieldName(Method method) { String methodName = method.getName(); if (methodName.startsWith("set")) { String name = methodName.substring(3); return Pair.of(getFieldName(name), getArgumentName(name)); } throw new IllegalArgumentException("Invalid setter method" + method.getName()); }
Example 9
Source File: WorkspaceNamespaceNameEnvVarProvider.java From che with Eclipse Public License 2.0 | 5 votes |
@Override public Pair<String, String> get(RuntimeIdentity runtimeIdentity) throws InfrastructureException { try { WorkspaceImpl workspace = workspaceDao.get(runtimeIdentity.getWorkspaceId()); return Pair.of(CHE_WORKSPACE_NAMESPACE, workspace.getNamespace()); } catch (NotFoundException | ServerException e) { throw new InfrastructureException( "Not able to get workspace namespace for workspace with id " + runtimeIdentity.getWorkspaceId(), e); } }
Example 10
Source File: DTOHelper.java From che with Eclipse Public License 2.0 | 5 votes |
/** Extract field name and argument name from the with method */ public static Pair<String, String> getWithFieldName(Method method) { String methodName = method.getName(); if (methodName.startsWith("with")) { String name = methodName.substring(4); return Pair.of(getFieldName(name), getArgumentName(name)); } throw new IllegalArgumentException("Invalid with method" + method.getName()); }
Example 11
Source File: PairConverter.java From che with Eclipse Public License 2.0 | 5 votes |
static Pair<String, String> fromString(String value) { final int p = value.indexOf('='); if (p < 0) { return Pair.of(value, null); } final int length = value.length(); if (p == length) { return Pair.of(value.substring(0, p), ""); } return Pair.of(value.substring(0, p), value.substring(p + 1, length)); }
Example 12
Source File: KubernetesCheApiInternalEnvVarProvider.java From che with Eclipse Public License 2.0 | 4 votes |
@Override public Pair<String, String> get(RuntimeIdentity runtimeIdentity) throws InfrastructureException { return Pair.of(CHE_API_INTERNAL_VARIABLE, cheServerEndpoint); }
Example 13
Source File: MavenOptsEnvVariableProvider.java From che with Eclipse Public License 2.0 | 4 votes |
@Override public Pair<String, String> get(RuntimeIdentity runtimeIdentity) { return Pair.of("MAVEN_OPTS", javaOpts); }
Example 14
Source File: KubernetesCheApiExternalEnvVarProvider.java From che with Eclipse Public License 2.0 | 4 votes |
@Override public Pair<String, String> get(RuntimeIdentity runtimeIdentity) throws InfrastructureException { return Pair.of(CHE_API_EXTERNAL_VARIABLE, cheServerEndpoint); }
Example 15
Source File: AgentAuthEnableEnvVarProvider.java From che with Eclipse Public License 2.0 | 4 votes |
@Override public Pair<String, String> get(RuntimeIdentity runtimeIdentity) { return Pair.of(CHE_AUTH_ENABLED_ENV, Boolean.toString(agentsAuthEnabled)); }
Example 16
Source File: GitConfigProvisioner.java From che with Eclipse Public License 2.0 | 4 votes |
private Pair<String, String> getUserFromUserManager() throws NotFoundException, ServerException { String userId = EnvironmentContext.getCurrent().getSubject().getUserId(); User user = userManager.getById(userId); return Pair.of(user.getName(), user.getEmail()); }
Example 17
Source File: WorkspaceManagerTest.java From che with Eclipse Public License 2.0 | 4 votes |
private Pair<String, Environment> getEnvironment(Workspace workspace, String envName) { return Pair.of(envName, workspace.getConfig().getEnvironments().get(envName)); }
Example 18
Source File: JavaOptsEnvVariableProvider.java From che with Eclipse Public License 2.0 | 4 votes |
@Override public Pair<String, String> get(RuntimeIdentity runtimeIdentity) { return Pair.of(JAVA_OPTS_VARIABLE, javaOpts); }
Example 19
Source File: SignatureAlgorithmEnvProvider.java From che with Eclipse Public License 2.0 | 4 votes |
@Override public Pair<String, String> get(RuntimeIdentity runtimeIdentity) { return Pair.of(Constants.SIGNATURE_ALGORITHM_ENV, algorithm); }
Example 20
Source File: CheApiEnvVarProvider.java From che with Eclipse Public License 2.0 | 2 votes |
/** * Returns Che API environment variable which should be injected into machines. * * @param runtimeIdentity which may be needed to evaluate environment variable value */ @Override public Pair<String, String> get(RuntimeIdentity runtimeIdentity) throws InfrastructureException { return Pair.of(CHE_API_VARIABLE, cheApiInternalEnvVarProvider.get(runtimeIdentity).second); }