Search in sources :

Example 6 with LAOState

use of com.github.dedis.popstellar.repository.LAOState in project popstellar by dedis.

the class ConsensusHandlerTest method setup.

@Before
public void setup() throws GeneralSecurityException, DataHandlingException, IOException {
    lenient().when(keyManager.getMainKeyPair()).thenReturn(ORGANIZER_KEY);
    lenient().when(keyManager.getMainPublicKey()).thenReturn(ORGANIZER);
    when(messageSender.subscribe(any())).then(args -> Completable.complete());
    laoRepository = new LAORepository();
    messageHandler = new MessageHandler(DataRegistryModule.provideDataRegistry(), keyManager);
    lao = new Lao(LAO_ID);
    laoRepository.getLaoById().put(LAO_ID, new LAOState(lao));
    MessageGeneral createLaoMessage = getMsg(ORGANIZER_KEY, CREATE_LAO);
    messageHandler.handleMessage(laoRepository, messageSender, lao.getChannel(), createLaoMessage);
    electMsg = getMsg(NODE_2_KEY, elect);
    messageId = electMsg.getMessageId();
}
Also used : LAOState(com.github.dedis.popstellar.repository.LAOState) MessageGeneral(com.github.dedis.popstellar.model.network.method.message.MessageGeneral) LAORepository(com.github.dedis.popstellar.repository.LAORepository) CreateLao(com.github.dedis.popstellar.model.network.method.message.data.lao.CreateLao) Lao(com.github.dedis.popstellar.model.objects.Lao) Before(org.junit.Before)

Example 7 with LAOState

use of com.github.dedis.popstellar.repository.LAOState in project popstellar by dedis.

the class LaoHandlerTest method setup.

@Before
public void setup() throws GeneralSecurityException, IOException {
    lenient().when(keyManager.getMainKeyPair()).thenReturn(SENDER_KEY);
    lenient().when(keyManager.getMainPublicKey()).thenReturn(SENDER);
    when(messageSender.subscribe(any())).then(args -> Completable.complete());
    laoRepository = new LAORepository();
    messageHandler = new MessageHandler(DataRegistryModule.provideDataRegistry(), keyManager);
    // Create one LAO and add it to the LAORepository
    lao = new Lao(CREATE_LAO.getName(), CREATE_LAO.getOrganizer(), CREATE_LAO.getCreation());
    lao.setLastModified(lao.getCreation());
    laoRepository.getLaoById().put(lao.getId(), new LAOState(lao));
    laoRepository.setAllLaoSubject();
    // Add the CreateLao message to the LAORepository
    createLaoMessage = new MessageGeneral(SENDER_KEY, CREATE_LAO, GSON);
    laoRepository.getMessageById().put(createLaoMessage.getMessageId(), createLaoMessage);
}
Also used : LAOState(com.github.dedis.popstellar.repository.LAOState) MessageGeneral(com.github.dedis.popstellar.model.network.method.message.MessageGeneral) LAORepository(com.github.dedis.popstellar.repository.LAORepository) StateLao(com.github.dedis.popstellar.model.network.method.message.data.lao.StateLao) CreateLao(com.github.dedis.popstellar.model.network.method.message.data.lao.CreateLao) Lao(com.github.dedis.popstellar.model.objects.Lao) UpdateLao(com.github.dedis.popstellar.model.network.method.message.data.lao.UpdateLao) Before(org.junit.Before)

Example 8 with LAOState

use of com.github.dedis.popstellar.repository.LAOState in project popstellar by dedis.

the class RollCallHandlerTest method setup.

@Before
public void setup() throws GeneralSecurityException, IOException, KeyException {
    lenient().when(keyManager.getMainKeyPair()).thenReturn(SENDER_KEY);
    lenient().when(keyManager.getMainPublicKey()).thenReturn(SENDER);
    lenient().when(keyManager.getValidPoPToken(any(), any())).thenReturn(POP_TOKEN);
    when(messageSender.subscribe(any())).then(args -> Completable.complete());
    laoRepository = new LAORepository();
    messageHandler = new MessageHandler(DataRegistryModule.provideDataRegistry(), keyManager);
    // Create one LAO
    Lao lao = new Lao(CREATE_LAO.getName(), CREATE_LAO.getOrganizer(), CREATE_LAO.getCreation());
    lao.setLastModified(lao.getCreation());
    // Create one Roll Call and add it to the LAO
    rollCall = new RollCall(lao.getId(), Instant.now().getEpochSecond(), "roll call 1");
    rollCall.setLocation("EPFL");
    lao.setRollCalls(new HashMap<String, RollCall>() {

        {
            put(rollCall.getId(), rollCall);
        }
    });
    // Add the LAO to the LAORepository
    laoRepository.getLaoById().put(lao.getId(), new LAOState(lao));
    laoRepository.setAllLaoSubject();
    // Add the CreateLao message to the LAORepository
    MessageGeneral createLaoMessage = new MessageGeneral(SENDER_KEY, CREATE_LAO, GSON);
    laoRepository.getMessageById().put(createLaoMessage.getMessageId(), createLaoMessage);
}
Also used : LAOState(com.github.dedis.popstellar.repository.LAOState) MessageGeneral(com.github.dedis.popstellar.model.network.method.message.MessageGeneral) LAORepository(com.github.dedis.popstellar.repository.LAORepository) CreateRollCall(com.github.dedis.popstellar.model.network.method.message.data.rollcall.CreateRollCall) CloseRollCall(com.github.dedis.popstellar.model.network.method.message.data.rollcall.CloseRollCall) OpenRollCall(com.github.dedis.popstellar.model.network.method.message.data.rollcall.OpenRollCall) RollCall(com.github.dedis.popstellar.model.objects.RollCall) CreateLao(com.github.dedis.popstellar.model.network.method.message.data.lao.CreateLao) Lao(com.github.dedis.popstellar.model.objects.Lao) Before(org.junit.Before)

Aggregations

LAOState (com.github.dedis.popstellar.repository.LAOState)8 CreateLao (com.github.dedis.popstellar.model.network.method.message.data.lao.CreateLao)7 LAORepository (com.github.dedis.popstellar.repository.LAORepository)7 Lao (com.github.dedis.popstellar.model.objects.Lao)6 MessageGeneral (com.github.dedis.popstellar.model.network.method.message.MessageGeneral)5 Before (org.junit.Before)5 Manifest (android.Manifest)2 Application (android.app.Application)2 PackageManager (android.content.pm.PackageManager)2 Log (android.util.Log)2 Toast (android.widget.Toast)2 NonNull (androidx.annotation.NonNull)2 ActivityCompat (androidx.core.app.ActivityCompat)2 AndroidViewModel (androidx.lifecycle.AndroidViewModel)2 LiveData (androidx.lifecycle.LiveData)2 LiveDataReactiveStreams (androidx.lifecycle.LiveDataReactiveStreams)2 MutableLiveData (androidx.lifecycle.MutableLiveData)2 R (com.github.dedis.popstellar.R)2 SingleEvent (com.github.dedis.popstellar.SingleEvent)2 StateLao (com.github.dedis.popstellar.model.network.method.message.data.lao.StateLao)2