aboutsummaryrefslogtreecommitdiffstats
path: root/configserver/src/test/java/com/yahoo/vespa/config/server/configchange/ReindexActionsFormatterTest.java
blob: a944f00da83a86a1c3084fdba616ad7cf4ed381f (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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.config.server.configchange;

import org.junit.Test;

import static com.yahoo.vespa.config.server.configchange.Utils.CHANGE_ID;
import static com.yahoo.vespa.config.server.configchange.Utils.CHANGE_ID_2;
import static com.yahoo.vespa.config.server.configchange.Utils.CHANGE_MSG;
import static com.yahoo.vespa.config.server.configchange.Utils.CHANGE_MSG_2;
import static com.yahoo.vespa.config.server.configchange.Utils.CLUSTER;
import static com.yahoo.vespa.config.server.configchange.Utils.DOC_TYPE;
import static com.yahoo.vespa.config.server.configchange.Utils.DOC_TYPE_2;
import static com.yahoo.vespa.config.server.configchange.Utils.SERVICE_NAME;
import static org.junit.Assert.assertEquals;

/**
 * @author bjorncs
 */
public class ReindexActionsFormatterTest {

    @Test
    public void formatting_of_single_action() {
        ReindexActions actions = new ConfigChangeActionsBuilder().
                reindex(CHANGE_ID, CHANGE_MSG, DOC_TYPE, CLUSTER, SERVICE_NAME).
                build().getReindexActions();
        assertEquals("field-type-change: Consider re-indexing document type 'music' in cluster 'foo' because:\n" +
                        "    1) change\n",
                new ReindexActionsFormatter(actions).format());
    }

    @Test
    public void formatting_of_multiple_actions() {
        ReindexActions actions = new ConfigChangeActionsBuilder().
                reindex(CHANGE_ID, CHANGE_MSG, DOC_TYPE, CLUSTER, SERVICE_NAME).
                reindex(CHANGE_ID, CHANGE_MSG_2, DOC_TYPE, CLUSTER, SERVICE_NAME).
                reindex(CHANGE_ID_2, CHANGE_MSG_2, DOC_TYPE, CLUSTER, SERVICE_NAME).
                reindex(CHANGE_ID_2, CHANGE_MSG_2, DOC_TYPE, CLUSTER, SERVICE_NAME).
                reindex(CHANGE_ID, CHANGE_MSG_2, DOC_TYPE_2, CLUSTER, SERVICE_NAME).
                build().getReindexActions();
        assertEquals("field-type-change: Consider re-indexing document type 'book' in cluster 'foo' because:\n" +
                        "    1) other change\n" +
                        "field-type-change: Consider re-indexing document type 'music' in cluster 'foo' because:\n" +
                        "    1) change\n" +
                        "    2) other change\n" +
                        "indexing-change: Consider re-indexing document type 'music' in cluster 'foo' because:\n" +
                        "    1) other change\n",
                new ReindexActionsFormatter(actions).format());
    }


}