java.util.Collections Java Examples

The following examples show how to use java.util.Collections. 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: StreamObjectMapReplayDecoder.java    From redisson with Apache License 2.0 8 votes vote down vote up
@Override
public Map<Object, Object> decode(List<Object> parts, State state) {
    if (parts.get(0) == null
            || (parts.get(0) instanceof List && ((List) parts.get(0)).isEmpty())) {
        parts.clear();
        return Collections.emptyMap();
    }

    if (parts.get(0) instanceof Map) {
        Map<Object, Object> result = new LinkedHashMap<Object, Object>(parts.size());
        for (int i = 0; i < parts.size(); i++) {
            result.putAll((Map<? extends Object, ? extends Object>) parts.get(i));
        }
        return result;
    }
    return super.decode(parts, state);
}
 
Example #2
Source File: DefaultStager.java    From james-project with Apache License 2.0 6 votes vote down vote up
/**
 * @param stage the annotation that specifies this stage
 * @param mode  execution order
 */
public DefaultStager(Class<A> stage, Order mode) {
    this.stage = stage;

    Queue<Stageable> localStageables;
    switch (mode) {
        case FIRST_IN_FIRST_OUT: {
            localStageables = new ArrayDeque<>();
            break;
        }

        case FIRST_IN_LAST_OUT: {
            localStageables = Collections.asLifoQueue(new ArrayDeque<>());
            break;
        }

        default: {
            throw new IllegalArgumentException("Unknown mode: " + mode);
        }
    }
    stageables = localStageables;
}
 
Example #3
Source File: OperatorServiceBeanWithDataServiceIT.java    From development with Apache License 2.0 6 votes vote down vote up
@Test
public void addAvailablePaymentTypes_FindsExistingEntry() throws Exception {
    OrganizationReference createdOrgRef = runTX(new Callable<OrganizationReference>() {
        @Override
        public OrganizationReference call() throws Exception {
            OrganizationReference orgRef = new OrganizationReference(
                    platformOp, supplier,
                    OrganizationReferenceType.PLATFORM_OPERATOR_TO_SUPPLIER);
            dataService.persist(orgRef);
            dataService.flush();
            return orgRef;
        }
    });
    operatorService
            .addAvailablePaymentTypes(OrganizationAssembler
                    .toVOOrganization(supplier, false, new LocalizerFacade(
                            localizer, "en")), Collections
                    .singleton("CREDIT_CARD"));
    validate(createdOrgRef, true);
}
 
Example #4
Source File: GridClientImpl.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * Maps Collection of strings to collection of {@code InetSocketAddress}es.
 *
 * @param cfgAddrs Collection fo string representations of addresses.
 * @return Collection of {@code InetSocketAddress}es
 * @throws GridClientException In case of error.
 */
private static Collection<InetSocketAddress> parseAddresses(Collection<String> cfgAddrs)
    throws GridClientException {
    Collection<InetSocketAddress> addrs = new ArrayList<>(cfgAddrs.size());

    for (String srvStr : cfgAddrs) {
        try {
            String[] split = srvStr.split(":");

            InetSocketAddress addr = new InetSocketAddress(split[0], Integer.parseInt(split[1]));

            addrs.add(addr);
        }
        catch (RuntimeException e) {
            throw new GridClientException("Failed to create client (invalid server address specified): " +
                srvStr, e);
        }
    }

    return Collections.unmodifiableCollection(addrs);
}
 
Example #5
Source File: GithubDiffReader.java    From cover-checker with Apache License 2.0 6 votes vote down vote up
@Override
public RawDiff next() {
	CommitFile file = files.next();
	log.info("get file {}", file.getFilename());
	List<String> lines;
	if (file.getPatch() != null && file.getPatch().length() > 0) {
		lines = Arrays.asList(file.getPatch().split("\r?\n"));
	} else {
		lines = Collections.emptyList();
	}
	return RawDiff.builder()
			.fileName(file.getFilename())
			.rawDiff(lines)
			.type(file.getPatch() != null ? FileType.SOURCE : FileType.BINARY)
			.build();
}
 
Example #6
Source File: DatabaseUpgradeHandler.java    From development with Apache License 2.0 6 votes vote down vote up
/**
 * Determines the files that have to be executed (according to the provided
 * version information) and orders them in ascending order.
 * 
 * @param fileList
 *            The list of files to be investigated. The names must have
 *            passed the test in method
 *            {@link #getScriptFilesFromDirectory(String, String)}.
 * @return The files to be executed in the execution order.
 */
protected List<File> getFileExecutionOrder(List<File> fileList,
        DatabaseVersionInfo currentVersion, DatabaseVersionInfo toVersion) {
    List<File> result = new ArrayList<File>();
    // if the file contains statements for a newer schema, add the file to
    // the list
    for (File file : fileList) {
        DatabaseVersionInfo info = determineVersionInfoForFile(file);
        if (info.compareTo(currentVersion) > 0
                && info.compareTo(toVersion) <= 0) {
            result.add(file);
        }
    }
    // now sort the list ascending
    Collections.sort(result);

    return result;
}
 
Example #7
Source File: FormatManagerTest.java    From validatar with Apache License 2.0 6 votes vote down vote up
@Test
public void testWriteReportOnlyOnFailureForFailingQueriesAndTests() throws IOException {
    String[] args = {"--report-on-failure-only", "true"};
    MockFormatter formatter = new MockFormatter();
    FormatManager manager = new FormatManager(args);
    manager.setAvailableFormatters(Collections.singletonMap("MockFormat", formatter));
    manager.setFormattersToUse(new ArrayList<>());
    manager.setupFormatter("MockFormat", args);
    TestSuite suite = new TestSuite();

    Assert.assertFalse(formatter.wroteReport);

    com.yahoo.validatar.common.Test failingTest = new com.yahoo.validatar.common.Test();
    failingTest.setFailed();
    Query failingQuery = new Query();
    failingQuery.setFailed();
    suite.queries = Collections.singletonList(failingQuery);
    suite.tests = Collections.singletonList(failingTest);
    manager.writeReports(Collections.singletonList(suite));
    Assert.assertTrue(formatter.wroteReport);
}
 
Example #8
Source File: EvaluatorTest.java    From spectator with Apache License 2.0 6 votes vote down vote up
@Test
public void updateSub() {

  // Eval with sum
  List<Subscription> sumSub = new ArrayList<>();
  sumSub.add(newSubscription("sum", ":true,:sum"));
  Evaluator evaluator = newEvaluator();
  evaluator.sync(sumSub);
  EvalPayload payload = evaluator.eval(0L, data("foo", 1.0, 2.0, 3.0));
  List<EvalPayload.Metric> metrics = new ArrayList<>();
  metrics.add(new EvalPayload.Metric("sum", Collections.emptyMap(), 6.0));
  EvalPayload expected = new EvalPayload(0L, metrics);
  Assertions.assertEquals(expected, payload);

  // Update to use max instead
  List<Subscription> maxSub = new ArrayList<>();
  maxSub.add(newSubscription("sum", ":true,:max"));
  evaluator.sync(maxSub);
  payload = evaluator.eval(0L, data("foo", 1.0, 2.0, 3.0));
  metrics = new ArrayList<>();
  metrics.add(new EvalPayload.Metric("sum", Collections.emptyMap(), 3.0));
  expected = new EvalPayload(0L, metrics);
  Assertions.assertEquals(expected, payload);
}
 
Example #9
Source File: ClusterAgentAutoScalerTest.java    From titus-control-plane with Apache License 2.0 6 votes vote down vote up
@Test
public void testScaleUpMinIdle() {
    AgentInstanceGroup instanceGroup = createPartition("instanceGroup1", InstanceGroupLifecycleState.Active, "r4.16xlarge", 0, 0, 10);
    when(agentManagementService.getInstanceGroups()).thenReturn(singletonList(instanceGroup));

    when(agentManagementService.getAgentInstances("instanceGroup1")).thenReturn(Collections.emptyList());
    when(agentManagementService.scaleUp(eq("instanceGroup1"), anyInt())).thenReturn(Completable.complete());

    testScheduler.advanceTimeBy(6, TimeUnit.MINUTES);

    ClusterAgentAutoScaler clusterAgentAutoScaler = new ClusterAgentAutoScaler(titusRuntime, configuration,
            agentManagementService, v3JobOperations, schedulingService, testScheduler);

    clusterAgentAutoScaler.doAgentScaling().await();

    verify(agentManagementService).scaleUp("instanceGroup1", 5);
}
 
Example #10
Source File: MicrometerMetricsReporterTest.java    From java-metrics with Apache License 2.0 6 votes vote down vote up
@Test
public void testReportSpan() {
    // prepare
    SpanData spanData = defaultMockSpanData();
    when(spanData.getTags()).thenReturn(Collections.singletonMap(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_CLIENT));

    MicrometerMetricsReporter reporter = MicrometerMetricsReporter.newMetricsReporter()
            .withConstLabel("span.kind", Tags.SPAN_KIND_CLIENT)
            .build();

    // test
    reporter.reportSpan(spanData);

    // verify
    List<Tag> tags = defaultTags();

    assertEquals(100, (long) registry.find("span").timer().totalTime(TimeUnit.MILLISECONDS));
    assertEquals(1, Metrics.timer("span", tags).count());
}
 
Example #11
Source File: PackagesProvider.java    From MtgDesktopCompanion with GNU General Public License v3.0 6 votes vote down vote up
public List<MagicEdition> listEditions() {

		if (!list.isEmpty())
			return list;

		try {
			XPath xPath = XPathFactory.newInstance().newXPath();
			String expression = "//edition/@id";
			NodeList nodeList = (NodeList) xPath.compile(expression).evaluate(document, XPathConstants.NODESET);
			for (int i = 0; i < nodeList.getLength(); i++)
			{
				list.add(MTGControler.getInstance().getEnabled(MTGCardsProvider.class).getSetById(nodeList.item(i).getNodeValue()));
			}
			
			Collections.sort(list);
		} catch (Exception e) {
			logger.error("Error retrieving IDs ", e);
		}
		return list;
	}
 
Example #12
Source File: CompositeComponentWizardIterator.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public Set<DataObject> instantiate(TemplateWizard wiz) throws IOException {
    DataObject result = null;
    String targetName = Templates.getTargetName(wizard);
    FileObject targetDir = Templates.getTargetFolder(wizard);
    DataFolder df = DataFolder.findFolder(targetDir);

    FileObject template = Templates.getTemplate( wizard );
    DataObject dTemplate = DataObject.find(template);
    HashMap<String, Object> templateProperties = new HashMap<String, Object>();
    if (selectedText != null) {
        templateProperties.put("implementation", selectedText);   //NOI18N
    }
    Project project = Templates.getProject(wizard);
    WebModule webModule = WebModule.getWebModule(project.getProjectDirectory());
    if (webModule != null) {
        JSFVersion version = JSFVersion.forWebModule(webModule);
        if (version != null && version.isAtLeast(JSFVersion.JSF_2_2)) {
            templateProperties.put("isJSF22", Boolean.TRUE); //NOI18N
        }
    }

    result  = dTemplate.createFromTemplate(df,targetName,templateProperties);
    return Collections.singleton(result);
}
 
Example #13
Source File: FiscoDepth.java    From cryptotrader with GNU Affero General Public License v3.0 6 votes vote down vote up
@VisibleForTesting
NavigableMap<BigDecimal, BigDecimal> convert(BigDecimal[][] values, Comparator<BigDecimal> comparator) {

    if (values == null) {
        return null;
    }

    NavigableMap<BigDecimal, BigDecimal> map = new TreeMap<>(comparator);

    Stream.of(values)
            .filter(ArrayUtils::isNotEmpty)
            .filter(ps -> ps.length == 2)
            .filter(ps -> ps[0] != null)
            .filter(ps -> ps[1] != null)
            .forEach(ps -> map.put(ps[0], ps[1]))
    ;

    return Collections.unmodifiableNavigableMap(map);

}
 
Example #14
Source File: RulesServiceTest.java    From gocd with Apache License 2.0 6 votes vote down vote up
@Test
void shouldErrorOutWhenMaterialIsReferringToNoneExistingSecretConfig() {
    GitMaterial gitMaterial = new GitMaterial("http://example.com");
    gitMaterial.setPassword("{{SECRET:[secret_config_id][password]}}");

    PipelineConfig up42 = PipelineConfigMother.pipelineConfig("up42", new MaterialConfigs(gitMaterial.config()));
    PipelineConfigs defaultGroup = PipelineConfigMother.createGroup("default", up42);
    CruiseConfig cruiseConfig = defaultCruiseConfig();
    cruiseConfig.setGroup(new PipelineGroups(defaultGroup));

    when(goConfigService.cruiseConfig()).thenReturn(cruiseConfig);
    when(goConfigService.pipelinesWithMaterial(gitMaterial.getFingerprint())).thenReturn(Collections.singletonList(new CaseInsensitiveString("up42")));
    when(goConfigService.findGroupByPipeline(new CaseInsensitiveString("up42"))).thenReturn(defaultGroup);
    when(goConfigService.findPipelineByName(new CaseInsensitiveString("up42"))).thenReturn(up42);

    assertThatCode(() -> rulesService.validateSecretConfigReferences(gitMaterial))
            .isInstanceOf(RulesViolationException.class)
            .hasMessage("Pipeline 'up42' is referring to none-existent secret config 'secret_config_id'.");
}
 
Example #15
Source File: StatusInfoTest.java    From ditto with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void compositeReturnsStatusUpWhenAllChildrenAreUp() {
    final Map<String, StatusInfo> childrenMap = new LinkedHashMap<>();
    final String upChild1Label = "up-child-1-label";
    childrenMap.put(upChild1Label, KNOWN_UP_STATUS_INFO_WITH_WARN_MSG);
    final String upChild2Label = "up-child-2-label";
    childrenMap.put(upChild2Label, KNOWN_UP_STATUS_INFO_WITH_WARN_MSG);

    final StatusInfo actual = StatusInfo.composite(childrenMap);

    final List<StatusDetailMessage> expectedDetails = Collections.singletonList(
            (createExpectedCompositeDetailMessage(KNOWN_MESSAGE_WARN.getLevel(),
                    Arrays.asList(upChild1Label, upChild2Label))));
    final List<StatusInfo> expectedLabeledChildren =
            Arrays.asList(KNOWN_UP_STATUS_INFO_WITH_WARN_MSG.label(upChild1Label),
                    KNOWN_UP_STATUS_INFO_WITH_WARN_MSG.label(upChild2Label));
    final StatusInfo expected =
            StatusInfo.of(StatusInfo.Status.UP, expectedDetails, expectedLabeledChildren, null);
    assertThat(actual).isEqualTo(expected);
    assertThat(actual.isComposite()).isTrue();
}
 
Example #16
Source File: ConcurrentHashMapTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Elements of classes with erased generic type parameters based
 * on Comparable can be inserted and found.
 */
public void testGenericComparable() {
    int size = 120;         // makes measured test run time -> 60ms
    ConcurrentHashMap<Object, Boolean> m =
        new ConcurrentHashMap<Object, Boolean>();
    for (int i = 0; i < size; i++) {
        BI bi = new BI(i);
        BS bs = new BS(String.valueOf(i));
        LexicographicList<BI> bis = new LexicographicList<BI>(bi);
        LexicographicList<BS> bss = new LexicographicList<BS>(bs);
        assertTrue(m.putIfAbsent(bis, true) == null);
        assertTrue(m.containsKey(bis));
        if (m.putIfAbsent(bss, true) == null)
            assertTrue(m.containsKey(bss));
        assertTrue(m.containsKey(bis));
    }
    for (int i = 0; i < size; i++) {
        assertTrue(m.containsKey(Collections.singletonList(new BI(i))));
    }
}
 
Example #17
Source File: DateTimeTextProvider.java    From desugar_jdk_libs with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructor.
 *
 * @param valueTextMap  the map of values to text to store, assigned and not altered, not null
 */
LocaleStore(Map<TextStyle, Map<Long, String>> valueTextMap) {
    this.valueTextMap = valueTextMap;
    Map<TextStyle, List<Entry<String, Long>>> map = new HashMap<>();
    List<Entry<String, Long>> allList = new ArrayList<>();
    for (Map.Entry<TextStyle, Map<Long, String>> vtmEntry : valueTextMap.entrySet()) {
        Map<String, Entry<String, Long>> reverse = new HashMap<>();
        for (Map.Entry<Long, String> entry : vtmEntry.getValue().entrySet()) {
            if (reverse.put(entry.getValue(), createEntry(entry.getValue(), entry.getKey())) != null) {
                // TODO: BUG: this has no effect
                continue;  // not parsable, try next style
            }
        }
        List<Entry<String, Long>> list = new ArrayList<>(reverse.values());
        Collections.sort(list, COMPARATOR);
        map.put(vtmEntry.getKey(), list);
        allList.addAll(list);
        map.put(null, allList);
    }
    Collections.sort(allList, COMPARATOR);
    this.parsable = map;
}
 
Example #18
Source File: FileSystemUtilitiesTest.java    From jaxb2-maven-plugin with Apache License 2.0 6 votes vote down vote up
private List<String> getRelativeCanonicalPaths( final List<File> fileList, final File cutoff )
{

    final String cutoffPath = FileSystemUtilities.getCanonicalPath( cutoff ).replace( File.separator, "/" );
    final List<String> toReturn = new ArrayList<String>();

    for ( File current : fileList )
    {

        final String canPath = FileSystemUtilities.getCanonicalPath( current ).replace( File.separator, "/" );
        if ( !canPath.startsWith( cutoffPath ) )
        {
            throw new IllegalArgumentException(
                    "Illegal cutoff provided. Cutoff: [" + cutoffPath + "] must be a parent to CanonicalPath [" + canPath + "]" );
        }

        toReturn.add( canPath.substring( cutoffPath.length() ) );
    }
    Collections.sort( toReturn );

    return toReturn;
}
 
Example #19
Source File: NodeTest.java    From sofa-jraft with Apache License 2.0 5 votes vote down vote up
@Test
public void testAutoSnapshot() throws Exception {
    final Endpoint addr = new Endpoint(TestUtils.getMyIp(), TestUtils.INIT_PORT);
    NodeManager.getInstance().addAddress(addr);
    final NodeOptions nodeOptions = createNodeOptionsWithSharedTimer();
    final MockStateMachine fsm = new MockStateMachine(addr);
    nodeOptions.setFsm(fsm);
    nodeOptions.setLogUri(this.dataPath + File.separator + "log");
    nodeOptions.setSnapshotUri(this.dataPath + File.separator + "snapshot");
    nodeOptions.setRaftMetaUri(this.dataPath + File.separator + "meta");
    nodeOptions.setSnapshotIntervalSecs(10);
    nodeOptions.setInitialConf(new Configuration(Collections.singletonList(new PeerId(addr, 0))));

    final Node node = new NodeImpl("unittest", new PeerId(addr, 0));
    assertTrue(node.init(nodeOptions));
    // wait node elect self as leader
    Thread.sleep(2000);

    sendTestTaskAndWait(node);

    // wait for auto snapshot
    Thread.sleep(10000);
    // first snapshot will be triggered randomly
    final int times = fsm.getSaveSnapshotTimes();
    assertTrue("snapshotTimes=" + times, times >= 1);
    assertTrue(fsm.getSnapshotIndex() > 0);

    final CountDownLatch latch = new CountDownLatch(1);
    node.shutdown(new ExpectClosure(latch));
    node.join();
    waitLatch(latch);
}
 
Example #20
Source File: PerWorldInventoryCommandTest.java    From PerWorldInventory with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void shouldDisplayInformation() {
    // given
    ExecutableCommand command = new PerWorldInventoryCommand();
    CommandSender sender = mock(CommandSender.class);

    // when
    command.executeCommand(sender, Collections.<String>emptyList());

    // then
    ArgumentCaptor<String> messagesCaptor = ArgumentCaptor.forClass(String.class);
    verify(sender, times(2)).sendMessage(messagesCaptor.capture());
    assertThat(messagesCaptor.getAllValues().get(0), containsString("/pwi help"));
    assertThat(messagesCaptor.getAllValues().get(1), containsString("/pwi version"));
}
 
Example #21
Source File: EntityManagerTest.java    From dal with Apache License 2.0 5 votes vote down vote up
@Test
public void testGrandParentColumnNames() {
    try {
        String[] columnNames = getAllColumnNames(grandParentClass);
        List<String> actualColumnNames = Arrays.asList(columnNames);
        Collections.sort(actualColumnNames);

        List<String> expectedColumnNames = getExpectedColumnNamesOfGrandParent();
        Collections.sort(expectedColumnNames);

        Assert.assertEquals(actualColumnNames, expectedColumnNames);
    } catch (Exception e) {
        Assert.fail();
    }
}
 
Example #22
Source File: FunctionImportITCase.java    From olingo-odata4 with Apache License 2.0 5 votes vote down vote up
@Test
public void FICRTStringTwoParamNull() {
  ODataInvokeRequest<ClientProperty> request = getClient().getInvokeRequestFactory()
      .getFunctionInvokeRequest(getClient().newURIBuilder(TecSvcConst.BASE_URI)
          .appendOperationCallSegment("FICRTStringTwoParam").build(),
          ClientProperty.class,
          Collections.<String, ClientValue> singletonMap("ParameterInt16",
              getFactory().newPrimitiveValueBuilder().buildInt32(1)));
  setCookieHeader(request);
  final ODataInvokeResponse<ClientProperty> response = request.execute();
  saveCookieHeader(response);
  assertEquals(HttpStatusCode.NO_CONTENT.getStatusCode(), response.getStatusCode());
}
 
Example #23
Source File: SimpleExoPlayer.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void stop(boolean reset) {
  verifyApplicationThread();
  player.stop(reset);
  if (mediaSource != null) {
    mediaSource.removeEventListener(analyticsCollector);
    analyticsCollector.resetForNewMediaSource();
    if (reset) {
      mediaSource = null;
    }
  }
  audioFocusManager.handleStop();
  currentCues = Collections.emptyList();
}
 
Example #24
Source File: BridgeConfigReconciliationTask.java    From ovsdb with Eclipse Public License 1.0 5 votes vote down vote up
@VisibleForTesting
void reconcileBridgeConfigurations(final Map<InstanceIdentifier<?>, DataObject> changes) {
    DataChangeEvent changeEvents = new DataChangeEvent() {
        @Override
        public Map<InstanceIdentifier<?>, DataObject> getCreatedData() {
            return changes;
        }

        @Override
        public Map<InstanceIdentifier<?>, DataObject> getUpdatedData() {
            return Collections.emptyMap();
        }

        @Override
        public Map<InstanceIdentifier<?>, DataObject> getOriginalData() {
            return Collections.emptyMap();
        }

        @Override
        public Set<InstanceIdentifier<?>> getRemovedPaths() {
            return Collections.emptySet();
        }
    };

    connectionInstance.transact(new TransactCommandAggregator(),
            new BridgeOperationalState(reconciliationManager.getDb(), changeEvents),
            new DataChangesManagedByOvsdbNodeEvent(
                    reconciliationManager.getDb(),
                    connectionInstance.getInstanceIdentifier(),
                    changeEvents), instanceIdentifierCodec);
}
 
Example #25
Source File: XStudent.java    From unitime with Apache License 2.0 5 votes vote down vote up
public XStudent(org.cpsolver.studentsct.model.Student student, Assignment<Request, Enrollment> assignment) {
 	super(student);
 	iStatus = student.getStatus();
 	iAllowDisabled = student.isAllowDisabled();
 	iEmailTimeStamp = (student.getEmailTimeStamp() == null ? null : new Date(student.getEmailTimeStamp()));
 	if (student.hasMaxCredit())
 		iMaxCredit = student.getMaxCredit();
 	for (AreaClassificationMajor acm: student.getAreaClassificationMajors()) {
 		iMajors.add(new XAreaClassificationMajor(acm.getArea(), acm.getClassification(), acm.getMajor()));
 	}
 	for (int i = 0; i < Math.min(student.getAcademicAreaClasiffications().size(), student.getMajors().size()); i++) {
 		iMajors.add(new XAreaClassificationMajor(student.getMajors().get(i).getArea(), student.getAcademicAreaClasiffications().get(i).getCode(), student.getMajors().get(i).getCode()));
 	}
 	if (iMajors.size() > 1) Collections.sort(iMajors);
 	for (AcademicAreaCode aac: student.getMinors()) {
 		if ("A".equals(aac.getArea()))
	iAccomodations.add(aac.getCode());
else
	iGroups.add(new XGroup(aac));
 	}
 	for (Instructor advisor: student.getAdvisors())
 		iAdvisors.add(new XAdvisor(advisor.getExternalId(), advisor.getName(), advisor.getEmail()));
 	for (Request request: student.getRequests()) {
 		if (request instanceof FreeTimeRequest) {
 			iRequests.add(new XFreeTimeRequest((FreeTimeRequest)request));
 		} else if (request instanceof CourseRequest) {
 			iRequests.add(new XCourseRequest((CourseRequest)request, assignment == null ? null : assignment.getValue(request)));
 		}
 	}
 }
 
Example #26
Source File: JdbcThinDatabaseMetadata.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override public ResultSet getFunctions(String catalog, String schemaPtrn,
    String functionNamePtrn) throws SQLException {
    // TODO: IGNITE-6028
    return new JdbcThinResultSet(Collections.<List<Object>>emptyList(), asList(
        new JdbcColumnMeta(null, null, "FUNCTION_CAT", String.class),
        new JdbcColumnMeta(null, null, "FUNCTION_SCHEM", String.class),
        new JdbcColumnMeta(null, null, "FUNCTION_NAME", String.class),
        new JdbcColumnMeta(null, null, "REMARKS", String.class),
        new JdbcColumnMeta(null, null, "FUNCTION_TYPE", String.class),
        new JdbcColumnMeta(null, null, "SPECIFIC_NAME", String.class)
    ));
}
 
Example #27
Source File: DiffFactory.java    From javers with Apache License 2.0 5 votes vote down vote up
public DiffFactory(TypeMapper typeMapper, List<NodeChangeAppender> nodeChangeAppenders, List<PropertyChangeAppender> propertyChangeAppender, LiveGraphFactory graphFactory, JaversCoreConfiguration javersCoreConfiguration) {
    this.typeMapper = typeMapper;
    this.nodeChangeAppenders = nodeChangeAppenders;
    this.graphFactory = graphFactory;
    this.javersCoreConfiguration = javersCoreConfiguration;

    //sort by priority
    Collections.sort(propertyChangeAppender, (p1, p2) -> ((Integer)p1.priority()).compareTo(p2.priority()));
    this.propertyChangeAppender = propertyChangeAppender;
}
 
Example #28
Source File: PackageVersionCheckerTest.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
@Test
public void checkInstancesHaveAllMandatoryPackageVersionOk() {
    when(instanceMetadataUpdater.collectInstancesWithMissingPackageVersions(anySet())).thenReturn(Collections.emptyMap());

    CheckResult result = underTest.checkInstancesHaveAllMandatoryPackageVersion(Collections.emptySet());

    assertEquals(EventStatus.OK, result.getStatus());
}
 
Example #29
Source File: BufferingDoFnRunnerTest.java    From beam with Apache License 2.0 5 votes vote down vote up
@Test
public void
    testRestoreWithoutConcurrentCheckpointsWithPendingCheckpointFromConcurrentCheckpointing()
        throws Exception {
  BufferingDoFnRunner bufferingDoFnRunner =
      createBufferingDoFnRunner(
          1, Collections.singletonList(new BufferingDoFnRunner.CheckpointIdentifier(5, 42)));
  assertThat(bufferingDoFnRunner.currentStateIndex, is(0));
  assertThat(bufferingDoFnRunner.numCheckpointBuffers, is(6));
}
 
Example #30
Source File: Util.java    From subsonic with GNU General Public License v3.0 5 votes vote down vote up
public static List<Integer> toIntegerList(int[] values) {
    if (values == null) {
        return Collections.emptyList();
    }
    List<Integer> result = new ArrayList<Integer>(values.length);
    for (int value : values) {
        result.add(value);
    }
    return result;
}