aboutsummaryrefslogtreecommitdiffstats
path: root/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/RequestTest.java
blob: adbf24bc4d103a6c930600e9ddadf8372010813d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.clustercontroller.core.restapiv2;

import com.yahoo.vespa.clustercontroller.utils.staterestapi.errors.InternalFailure;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.fail;

public class RequestTest {

    @Test
    void testGetResultBeforeCompletion() {
        Request<String> r = new Request<>(Request.MasterState.MUST_BE_MASTER) {
            @Override
            public String calculateResult(Context context) {
                return "foo";
            }
        };
        try {
            r.getResult();
            fail();
        } catch (InternalFailure e) {
        } catch (Exception e) {
            fail();
        }
        r.notifyCompleted();
        try {
            r.getResult();
            fail();
        } catch (InternalFailure e) {
        } catch (Exception e) {
            fail();
        }
    }

}