<commit_before>package org.distbc.data.structures;

import co.paralleluniverse.galaxy.Grid;
import co.paralleluniverse.galaxy.TimeoutException;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;

public class GalaxyDataBlockTest {

    private static Grid grid;

    @BeforeClass
    public static void startupGalaxy() {
        try {
            grid = Grid.getInstance("../config/peer.xml", "../config/peer.properties");
            if (!grid.cluster().isOnline()) {
                grid.goOnline();
            }
        } catch (Exception xcp) {
            // when we catch any exception, there's no point in bringing this node online
            // fail the startup
            throw new RuntimeException(xcp);
        }
    }

    @AfterClass
    public static void shutdownGalaxy() {
        grid.cluster().goOffline();
    }

    @Test
    public void testPutGet() throws TimeoutException {
        DataBlock<Integer, Long> db = new DataBlock<>();
        db.put(123, 123L);
        long dbId = grid.store().put(db, null);
        grid.store().release(dbId);
        // time goes by
        DataBlock<Integer, Long> db2 = new DataBlock<>();
        grid.store().get(dbId, db2);
        assertEquals(Long.valueOf(123), db2.get(123));
        assertNull(db2.get(125));
    }
}<commit_msg>- adding preliminary test coverage<commit_after>package org.distbc.data.structures;

import co.paralleluniverse.galaxy.Grid;
import co.paralleluniverse.galaxy.TimeoutException;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;

public class GalaxyDataBlockTest {

    private static Grid grid;

    @BeforeClass
    public static void startupGalaxy() {
        try {
            grid = Grid.getInstance("../config/peer.xml", "../config/peer.properties");
            if (!grid.cluster().isOnline()) {
                grid.goOnline();
            }
        } catch (Exception xcp) {
            // when we catch any exception, there's no point in bringing this node online
            // fail the startup
            throw new RuntimeException(xcp);
        }
    }

    @AfterClass
    public static void shutdownGalaxy() {
        grid.cluster().goOffline();
    }

    @Test
    public void testPutGet() throws TimeoutException {
        DataBlock<Integer, Long> db = new DataBlock<>();
        db.put(123, 123L);
        long dbId = grid.store().put(db, null);
        grid.store().release(dbId);
        // time goes by
        DataBlock<Integer, Long> db2 = new DataBlock<>();
        grid.store().get(dbId, db2);
        assertEquals(Long.valueOf(123), db2.get(123));
        assertNull(db2.get(125));
    }

    @Test
    @Ignore // until I figured out how I can get this stupid DI working
    public void testCtorWithId() throws TimeoutException {
        DataBlock<Integer, Long> db = new DataBlock<>();
        db.put(123, 123L);
        long dbId = grid.store().put(db, null);
        grid.store().release(dbId);

        // tic toc tic toc
        DataBlock<Integer, Long> db2 = new DataBlock<>(dbId);
        assertEquals(Long.valueOf(123L), db2.get(123));
    }
}
{'fraction_non_alphanumeric': 0.121929298981426, 'fraction_numerical': 0.015578190533253445, 'mean_word_length': 2.478125, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1092591', 'n_tokens_mistral': 997, 'n_tokens_neox': 937, 'n_words': 240}