Search in sources :

Example 6 with CreateLao

use of com.github.dedis.popstellar.model.network.method.message.data.lao.CreateLao 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

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