/** * Selects the unique object in this iterable that matches the given hamcrest Matcher * @param matcher The hamcrest Matcher used to retain the given iterable * @return The only object in the given iterable that matches the given hamcrest Matcher or null if there is no such object * @throws RuntimeException if there is more than one object that matches the given hamcrest Matcher */ public T unique(Matcher<?> matcher) { return (T)Lambda.selectUnique(getInner(), matcher); }
private File getJammJar(File[] cassandraJars) { File jammJar = selectUnique(cassandraJars, having(on(File.class).getName(), startsWith("jamm"))); return jammJar; }
private File getJammJar(File[] cassandraJars) { File jammJar = selectUnique(cassandraJars, having(on(File.class).getName(), startsWith("jamm"))); return jammJar; }
private static ColumnFamilyDefinition checkColumnFamilyName(List<ColumnFamilyDefinition> columnFamilyDefinitions, ColumnFamilyModel expectedColumnFamilyModel) throws Error { ColumnFamilyDefinition columnFamily = selectUnique(columnFamilyDefinitions, having(on(ColumnFamilyDefinition.class).getName(), equalTo(expectedColumnFamilyModel.getName()))); if (columnFamily == null) { throw FailureHandler.createFailure("Expected name of column family is %s but was not found.", expectedColumnFamilyModel.getName()); } return columnFamily; }
private static ColumnFamilyDefinition checkColumnFamilyName(List<ColumnFamilyDefinition> columnFamilyDefinitions, ColumnFamilyModel expectedColumnFamilyModel) throws Error { ColumnFamilyDefinition columnFamily = selectUnique(columnFamilyDefinitions, having(on(ColumnFamilyDefinition.class).getName(), equalTo(expectedColumnFamilyModel.getName()))); if (columnFamily == null) { throw FailureHandler.createFailure("Expected name of column family is %s but was not found.", expectedColumnFamilyModel.getName()); } return columnFamily; }
private void setPersonAttributes(MRSPatient patient, Patient openMRSPatient, List<PersonAttributeType> allPersonAttributeTypes) { MRSPerson mrsPerson = patient.getPerson(); if (CollectionUtils.isNotEmpty(mrsPerson.getAttributes())) { for (MRSAttribute attribute : mrsPerson.getAttributes()) { PersonAttributeType attributeType = (PersonAttributeType) selectUnique(allPersonAttributeTypes, having(on(PersonAttributeType.class).getName(), equalTo(attribute.getName()))); openMRSPatient.addAttribute(new PersonAttribute(attributeType, attribute.getValue())); } } } }
@Test public void testDiff() throws DockerException { ContainerConfig containerConfig = new ContainerConfig(); containerConfig.setImage("busybox"); containerConfig.setCmd(new String[] { "touch", "/test" }); ContainerCreateResponse container = dockerClient .createContainer(containerConfig); LOG.info("Created container: {}", container.toString()); assertThat(container.getId(), not(isEmptyString())); dockerClient.startContainer(container.getId()); boolean add = tmpContainers.add(container.getId()); int exitCode = dockerClient.waitContainer(container.getId()); assertThat(exitCode, equalTo(0)); List filesystemDiff = dockerClient.containerDiff(container.getId()); LOG.info("Container DIFF: {}", filesystemDiff.toString()); assertThat(filesystemDiff.size(), equalTo(1)); ChangeLog testChangeLog = selectUnique(filesystemDiff, hasField("path", equalTo("/test"))); assertThat(testChangeLog, hasField("path", equalTo("/test"))); assertThat(testChangeLog, hasField("kind", equalTo(1))); }
public static Person createPerson(MRSPerson person, List<PersonAttributeType> allPersonAttributeTypes) { Person converted = new Person(); if (person.getDateOfBirth() != null) { converted.setBirthdate(person.getDateOfBirth().toDate()); } if (person.getDeathDate() != null) { converted.setDeathDate(person.getDeathDate().toDate()); } converted.setBirthdateEstimated((Boolean) ObjectUtils.defaultIfNull(person.getBirthDateEstimated(), false)); converted.setDead(person.isDead()); converted.setGender(person.getGender()); converted.addName(new PersonName(person.getFirstName(), person.getMiddleName(), person.getLastName())); if (person.getAddress() != null) { PersonAddress personAddress = new PersonAddress(); personAddress.setAddress1(person.getAddress()); converted.addAddress(personAddress); } for (MRSAttribute attribute : person.getAttributes()) { PersonAttributeType attributeType = (PersonAttributeType) selectUnique(allPersonAttributeTypes, having(on(PersonAttributeType.class).getName(), equalTo(attribute.getName()))); converted.addAttribute(new PersonAttribute(attributeType, attribute.getValue())); } return converted; }