Package org.apache.sirona.status

Examples of org.apache.sirona.status.ValidationResult


    public static void addStatus() {
        IoCs.findOrCreateInstance(Repository.class);
        IoCs.getInstance(NodeStatusDataStore.class).statuses()
            .put("node1",
                new NodeStatus(
                    new ValidationResult[] { new ValidationResult("validation #1", Status.OK, "all is fine") },
                    new Date()));
    }
View Full Code Here


        try {
            c = ds.getConnection();
            final PreparedStatement statement = c.prepareStatement(query);
            try {
                if (!statement.execute()) {
                    return new ValidationResult(name, Status.KO, "validation query didn't execute correctly");
                }
                return new ValidationResult(name, Status.OK, "validation query executed correctly");
            } finally {
                statement.close();
            }
        } catch (final SQLException e) {
            LOGGER.log(Level.WARNING, e.getMessage());
            return new ValidationResult(name, Status.KO, e.getMessage());
        } finally {
            try {
                if (c != null) {
                    c.close();
                }
View Full Code Here

        Thread.sleep(150);

        final NodeStatus result = IoCs.getInstance(NodeStatusDataStore.class).statuses().values().iterator().next();
        assertEquals(1, result.getResults().length);

        final ValidationResult validationResult = result.getResults()[0];
        assertEquals("tomee-datasource-db", validationResult.getName());
        assertEquals(Status.OK, validationResult.getStatus());
    }
View Full Code Here

                } else if (maxDate.compareTo(value) < 0) {
                    maxDate = value;
                }

                final ColumnSlice<String, String> slice = subResult.get();
                validations.add(new ValidationResult(
                    slice.getColumnByName("name").getValue(),
                    Status.valueOf(slice.getColumnByName("status").getValue()),
                    slice.getColumnByName("description").getValue()));
            }
            statuses.put(status.getKey(), new NodeStatus(validations.toArray(new ValidationResult[validations.size()]), maxDate));
View Full Code Here

@RunWith(CassandraRunner.class)
public class AgentStatusTest {
    @Test
    public void checkPersistence() {
        new CassandraCollectorNodeStatusDataStore().store("node1", new NodeStatus(new ValidationResult[] {
            new ValidationResult("v1", Status.OK, "m1"), new ValidationResult("v2", Status.KO, "m2") }, new Date()));
        new CassandraCollectorNodeStatusDataStore().store("node2", new NodeStatus(new ValidationResult[] {
            new ValidationResult("v3", Status.OK, "m3"), new ValidationResult("v4", Status.KO, "m4") }, new Date()));

        final Map<String, NodeStatus> statuses = new CassandraCollectorNodeStatusDataStore().statuses();

        assertEquals(2, statuses.size());
View Full Code Here

            @Override
            protected NodeStatusReporter newNodeStatusReporter() {
                return new NodeStatusReporter() {
                    @Override
                    public synchronized NodeStatus computeStatus() {
                        return new NodeStatus(new ValidationResult[]{new ValidationResult("sample", Status.OK, "msg")}, new Date());
                    }
                };
            }

            @Override
            protected int getPeriod(final String prefix) {
                return 100;
            }
        });

        assertEquals(0, store.statuses().size());

        Thread.sleep(250);
        store.shutdown();

        final Map<String,NodeStatus> statuses = store.statuses();
        assertEquals(1, statuses.size());
        assertTrue(statuses.containsKey("test"));

        final ValidationResult[] results = statuses.get("test").getResults();
        assertEquals(1, results.length);

        final ValidationResult validationResult = results[0];
        assertEquals("sample", validationResult.getName());
        assertEquals("msg", validationResult.getMessage());
        assertEquals(Status.OK, validationResult.getStatus());
    }
View Full Code Here

                if (validations.size() > 0) {
                    final Collection<ValidationResult> results = new ArrayList<ValidationResult>(validations.size());
                    for (final Event event : validations) {
                        final Map<String, Object> data = event.getData();
                        results.add(new ValidationResult(
                            (String) data.get("name"),
                            Status.valueOf((String) data.get("status")),
                            (String) data.get("message")));
                    }
View Full Code Here

import org.apache.sirona.status.ValidationResult;

public class ReFakeValidation implements Validation {
    @Override
    public ValidationResult validate() {
        return new ValidationResult("refake", Status.OK, "descr");
    }
View Full Code Here

import org.apache.sirona.status.ValidationResult;

public class FakeValidation implements Validation {
    @Override
    public ValidationResult validate() {
        return new ValidationResult("fake", Status.OK, "descr");
    }
View Full Code Here

                if (validations.size() > 0) {
                    final Collection<ValidationResult> results = new ArrayList<ValidationResult>(validations.size());
                    for (final Event event : validations) {
                        final Map<String, Object> data = event.getData();
                        results.add(new ValidationResult(
                            (String) data.get("name"),
                            Status.valueOf((String) data.get("status")),
                            (String) data.get("message")));
                    }
View Full Code Here

TOP

Related Classes of org.apache.sirona.status.ValidationResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.